diff --git a/tests/etc/wsgi_sqlalchemy_pooled.conf b/tests/etc/wsgi_sqlalchemy_pooled.conf index 3b83fd11f..5c078dfd2 100644 --- a/tests/etc/wsgi_sqlalchemy_pooled.conf +++ b/tests/etc/wsgi_sqlalchemy_pooled.conf @@ -1,6 +1,13 @@ [DEFAULT] pooling = True +admin_mode = True [drivers] transport = wsgi storage = sqlalchemy + +[drivers:transport:wsgi] +bind = 0.0.0.0 +port = 8888 +workers = 20 + diff --git a/zaqar/queues/transport/wsgi/driver.py b/zaqar/queues/transport/wsgi/driver.py index 59c12fc94..09ce89c7e 100644 --- a/zaqar/queues/transport/wsgi/driver.py +++ b/zaqar/queues/transport/wsgi/driver.py @@ -80,14 +80,14 @@ class Driver(transport.DriverBase): """Initialize hooks and URI routes to resources.""" catalog = [ - ('/v1', v1_0.public_endpoints(self)), - ('/v1.1', v1_1.public_endpoints(self)), + ('/v1', v1_0.public_endpoints(self, self._conf)), + ('/v1.1', v1_1.public_endpoints(self, self._conf)), ] if self._conf.admin_mode: catalog.extend([ - ('/v1', v1_0.private_endpoints(self)), - ('/v1.1', v1_1.private_endpoints(self)), + ('/v1', v1_0.private_endpoints(self, self._conf)), + ('/v1.1', v1_1.private_endpoints(self, self._conf)), ]) self.app = falcon.API(before=self.before_hooks) diff --git a/zaqar/queues/transport/wsgi/v1_0/__init__.py b/zaqar/queues/transport/wsgi/v1_0/__init__.py index 32670e6df..c0ad8f4ee 100644 --- a/zaqar/queues/transport/wsgi/v1_0/__init__.py +++ b/zaqar/queues/transport/wsgi/v1_0/__init__.py @@ -22,7 +22,7 @@ from zaqar.queues.transport.wsgi.v1_0 import queues from zaqar.queues.transport.wsgi.v1_0 import stats -def public_endpoints(driver): +def public_endpoints(driver, conf): queue_controller = driver._storage.queue_controller message_controller = driver._storage.message_controller claim_controller = driver._storage.claim_controller @@ -69,7 +69,10 @@ def public_endpoints(driver): ] -def private_endpoints(driver): +def private_endpoints(driver, conf): + if not conf.pooling: + return [] + pools_controller = driver._control.pools_controller return [ diff --git a/zaqar/queues/transport/wsgi/v1_1/__init__.py b/zaqar/queues/transport/wsgi/v1_1/__init__.py index f9fcf8081..1f680a2c6 100644 --- a/zaqar/queues/transport/wsgi/v1_1/__init__.py +++ b/zaqar/queues/transport/wsgi/v1_1/__init__.py @@ -23,7 +23,7 @@ from zaqar.queues.transport.wsgi.v1_1 import queues from zaqar.queues.transport.wsgi.v1_1 import stats -def public_endpoints(driver): +def public_endpoints(driver, conf): queue_controller = driver._storage.queue_controller message_controller = driver._storage.message_controller claim_controller = driver._storage.claim_controller @@ -76,20 +76,27 @@ def public_endpoints(driver): ] -def private_endpoints(driver): - pools_controller = driver._control.pools_controller - flavors_controller = driver._control.flavors_controller +def private_endpoints(driver, conf): - return [ - ('/pools', - pools.Listing(pools_controller)), - ('/pools/{pool}', - pools.Resource(pools_controller)), + catalogue = [ # Health ('/health', health.Resource(driver._storage)), - ('/flavors', - flavors.Listing(flavors_controller)), - ('/flavors/{flavor}', - flavors.Resource(flavors_controller)), ] + + if conf.pooling: + pools_controller = driver._control.pools_controller + flavors_controller = driver._control.flavors_controller + + catalogue.extend([ + ('/pools', + pools.Listing(pools_controller)), + ('/pools/{pool}', + pools.Resource(pools_controller)), + ('/flavors', + flavors.Listing(flavors_controller)), + ('/flavors/{flavor}', + flavors.Resource(flavors_controller)), + ]) + + return catalogue diff --git a/zaqar/tests/queues/transport/wsgi/v1/test_pools.py b/zaqar/tests/queues/transport/wsgi/v1/test_pools.py index 45d6dd010..fafa86507 100644 --- a/zaqar/tests/queues/transport/wsgi/v1/test_pools.py +++ b/zaqar/tests/queues/transport/wsgi/v1/test_pools.py @@ -323,7 +323,7 @@ class PoolsBaseTest(base.V1Base): class TestPoolsMongoDB(PoolsBaseTest): - config_file = 'wsgi_mongodb.conf' + config_file = 'wsgi_mongodb_pooled.conf' @testing.requires_mongodb def setUp(self): @@ -332,7 +332,7 @@ class TestPoolsMongoDB(PoolsBaseTest): class TestPoolsSqlalchemy(PoolsBaseTest): - config_file = 'wsgi_sqlalchemy.conf' + config_file = 'wsgi_sqlalchemy_pooled.conf' def setUp(self): super(TestPoolsSqlalchemy, self).setUp() diff --git a/zaqar/tests/queues/transport/wsgi/v1_1/test_pools.py b/zaqar/tests/queues/transport/wsgi/v1_1/test_pools.py index 1a93ba8e5..8438f8cfe 100644 --- a/zaqar/tests/queues/transport/wsgi/v1_1/test_pools.py +++ b/zaqar/tests/queues/transport/wsgi/v1_1/test_pools.py @@ -327,7 +327,7 @@ class PoolsBaseTest(base.V1_1Base): class TestPoolsMongoDB(PoolsBaseTest): - config_file = 'wsgi_mongodb.conf' + config_file = 'wsgi_mongodb_pooled.conf' @testing.requires_mongodb def setUp(self): @@ -336,7 +336,7 @@ class TestPoolsMongoDB(PoolsBaseTest): class TestPoolsSqlalchemy(PoolsBaseTest): - config_file = 'wsgi_sqlalchemy.conf' + config_file = 'wsgi_sqlalchemy_pooled.conf' def setUp(self): super(TestPoolsSqlalchemy, self).setUp()