def setUp(self): super(FunctionalTestBase, self).setUp() # NOTE(flaper87): Config can't be a class # attribute because it may be necessary to # modify it at runtime which will affect # other instances running instances. self.cfg = config.load_config() if not self.cfg.run_tests: self.skipTest("Functional tests disabled") config_file = self.config_file or self.cfg.zaqar.config config_file = base_helpers.override_mongo_conf(config_file, self) self.mconf = self.load_conf(config_file) validator = validation.Validator(self.mconf) self.limits = validator._limits_conf transport_base._config_options() self.resource_defaults = transport_base.ResourceDefaults(self.mconf) # Always register options self.__class__.class_bootstrap = bootstrap.Bootstrap(self.mconf) self.class_bootstrap.transport datadriver = self.class_bootstrap.storage._storage if isinstance(datadriver, redis.DataDriver): self.__class__.class_ttl_gc_interval = 1 if isinstance(datadriver, mongodb.DataDriver): # NOTE(kgriffs): MongoDB's TTL scavenger only runs once a minute self.__class__.class_ttl_gc_interval = 60 if _TEST_INTEGRATION: if not (self.server and self.server.is_alive()): self.server = self.server_class() self.server.start(self.mconf) self.addCleanup(self.server.process.terminate) self.client = http.Client() else: if self.server_class == ZaqarAdminServer: self.mconf.pooling = True self.mconf.admin_mode = True self.addCleanup(self.class_bootstrap.storage.close) self.addCleanup(self.class_bootstrap.control.close) self.client = http.WSGIClient(self.class_bootstrap.transport.app) self.headers = helpers.create_zaqar_headers(self.cfg) self.headers_response_with_body = {'location', 'content-type'} self.client.set_headers(self.headers) # Store information required for cleaning databases after # execution of test class self.wipe_dbs_projects.add(self.headers["X-Project-ID"])
def setUp(self): super(TestBase, self).setUp() if not self.config_file: self.skipTest("No config specified") self.conf.register_opts(configs._GENERAL_OPTIONS) self.conf.register_opts(validation._TRANSPORT_LIMITS_OPTIONS, group=validation._TRANSPORT_LIMITS_GROUP) self.transport_cfg = self.conf[validation._TRANSPORT_LIMITS_GROUP] self.conf.register_opts(driver._WSGI_OPTIONS, group=driver._WSGI_GROUP) self.wsgi_cfg = self.conf[driver._WSGI_GROUP] self.conf.unreliable = True self.conf.admin_mode = True self.boot = bootstrap.Bootstrap(self.conf) self.addCleanup(self.boot.storage.close) self.addCleanup(self.boot.control.close) self.app = self.boot.transport.app self.srmock = ftest.StartResponseMock() self.headers = { 'Client-ID': uuidutils.generate_uuid(), 'X-ROLES': 'admin', 'X-USER-ID': 'a12d157c7d0d41999096639078fd11fc', 'X-TENANT-ID': 'abb69142168841fcaa2785791b92467f', }
def setUp(self): super(TestBase, self).setUp() if not self.config_file: self.skipTest("No config specified") self.conf.register_opts(bootstrap._GENERAL_OPTIONS) self.conf.register_opts(validation._TRANSPORT_LIMITS_OPTIONS, group=validation._TRANSPORT_LIMITS_GROUP) self.transport_cfg = self.conf[validation._TRANSPORT_LIMITS_GROUP] self.conf.register_opts(driver._WSGI_OPTIONS, group=driver._WSGI_GROUP) self.wsgi_cfg = self.conf[driver._WSGI_GROUP] self.conf.unreliable = True self.conf.admin_mode = True self.boot = bootstrap.Bootstrap(self.conf) self.app = self.boot.transport.app self.srmock = ftest.StartResponseMock() self.headers = { 'Client-ID': str(uuid.uuid4()), }
def setUp(self): super(TestBase, self).setUp() if not self.config_file: self.skipTest("No config specified") self.conf.register_opts(default.ALL_OPTS) self.conf.register_opts(transport.ALL_OPTS, group=transport.GROUP_NAME) self.transport_cfg = self.conf[transport.GROUP_NAME] self.conf.register_opts(drivers_transport_wsgi.ALL_OPTS, group=drivers_transport_wsgi.GROUP_NAME) self.wsgi_cfg = self.conf[drivers_transport_wsgi.GROUP_NAME] self.conf.unreliable = True self.conf.admin_mode = True self.boot = bootstrap.Bootstrap(self.conf) self.addCleanup(self.boot.storage.close) self.addCleanup(self.boot.control.close) self.app = self.boot.transport.app self.srmock = ftest.StartResponseMock() self.headers = { 'Client-ID': uuidutils.generate_uuid(), 'X-ROLES': 'admin', 'X-USER-ID': 'a12d157c7d0d41999096639078fd11fc', 'X-TENANT-ID': 'abb69142168841fcaa2785791b92467f', }
def setUp(self): super(FunctionalTestBase, self).setUp() # NOTE(flaper87): Config can't be a class # attribute because it may be necessary to # modify it at runtime which will affect # other instances running instances. self.cfg = config.load_config() if not self.cfg.run_tests: self.skipTest("Functional tests disabled") config_file = self.config_file or self.cfg.zaqar.config config_file = base_helpers.override_mongo_conf(config_file, self) self.mconf = self.load_conf(config_file) validator = validation.Validator(self.mconf) self.limits = validator._limits_conf transport_base._config_options() self.resource_defaults = transport_base.ResourceDefaults(self.mconf) # Always register options wrapper = bootstrap.Bootstrap(self.mconf) wrapper.transport if _TEST_INTEGRATION: # TODO(kgriffs): This code should be replaced to use # an external wsgi server instance. # NOTE(flaper87): Use running instances. if self.cfg.zaqar.run_server: if not (self.server and self.server.is_alive()): self.server = self.server_class() self.server.start(self.mconf) self.addCleanup(self.server.process.terminate) self.client = http.Client() else: if self.server_class == ZaqarAdminServer: self.mconf.pooling = True self.mconf.admin_mode = True self.addCleanup(wrapper.storage.close) self.addCleanup(wrapper.control.close) self.client = http.WSGIClient(wrapper.transport.app) self.headers = helpers.create_zaqar_headers(self.cfg) if self.cfg.auth.auth_on: auth_token = helpers.get_keystone_token(self.cfg, self.client) self.headers["X-Auth-Token"] = auth_token self.headers_response_with_body = {'location', 'content-type'} self.client.set_headers(self.headers)
def run(): # Use the global CONF instance conf = cfg.CONF conf(project='zaqar', prog='zaqar-gc') server = bootstrap.Bootstrap(conf) LOG.debug(u'Calling the garbage collector') server.storage.gc()
def run(): # TODO(kgriffs): For now, we have to use the global config # to pick up common options from openstack.common.log, since # that module uses the global CONF instance exclusively. conf = cfg.CONF conf(project='zaqar', prog='zaqar-gc') server = bootstrap.Bootstrap(conf) LOG.debug(u'Calling the garbage collector') server.storage.gc()
def run(): # Use the global CONF instance conf = cfg.CONF gmr_opts.set_defaults(conf) # NOTE(eggmaster): register command line options for zaqar-server conf.register_cli_opts(_CLI_OPTIONS) log.register_options(conf) # NOTE(jeffrey4l): Overwrite the default vaule for # logging_context_format_string. Add project_id into it. conf.set_default( 'logging_context_format_string', '%(asctime)s.%(msecs)03d %(process)d %(levelname)s' ' %(name)s [%(request_id)s %(user_identity)s]' ' [project_id:%(project_id)s] %(message)s') conf(project='zaqar', prog='zaqar-server') log.setup(conf, 'zaqar') gmr.TextGuruMeditation.setup_autorun(version, conf=conf) server = bootstrap.Bootstrap(conf) # The following code is to daemonize zaqar-server to avoid # an issue with wsgiref writing to stdout/stderr when we don't # want it to. This is specifically needed to allow zaqar to # run under devstack, but it may also be useful for other scenarios. # Open /dev/zero and /dev/null for redirection. # Daemonizing zaqar-server is needed *just* when running under devstack # and when zaqar is invoked with `daemon` command line option. if conf.daemon: zerofd = os.open('/dev/zero', os.O_RDONLY) nullfd = os.open('/dev/null', os.O_WRONLY) # Close the stdthings and reassociate them with a non terminal os.dup2(zerofd, 0) os.dup2(nullfd, 1) os.dup2(nullfd, 2) # Detach process context, this requires 2 forks. try: pid = os.fork() if pid > 0: os._exit(0) except OSError: os._exit(1) try: pid = os.fork() if pid > 0: os._exit(0) except OSError: os._exit(2) server.run()
def run(): # TODO(kgriffs): For now, we have to use the global config # to pick up common options from openstack.common.log, since # that module uses the global CONF instance exclusively. conf = cfg.CONF # NOTE(jeffrey4l): Overwrite the default vaule for # logging_context_format_string. Add project_id into it. conf.set_default( 'logging_context_format_string', '%(asctime)s.%(msecs)03d %(process)d %(levelname)s' ' %(name)s [%(request_id)s %(user_identity)s]' ' [project_id:%(project_id)s] %(message)s') conf(project='zaqar', prog='zaqar-queues') server = bootstrap.Bootstrap(conf) # The following code is to daemonize zaqar-server to avoid # an issue with wsgiref writing to stdout/stderr when we don't # want it to. This is specifically needed to allow zaqar to # run under devstack, but it may also be useful for other scenarios. # Open /dev/zero and /dev/null for redirection. # Daemonizing zaqar-server is needed *just* when running under devstack # and when zaqar is invoked with `daemon` command line option. if conf.daemon: zerofd = os.open('/dev/zero', os.O_RDONLY) nullfd = os.open('/dev/null', os.O_WRONLY) # Close the stdthings and reassociate them with a non terminal os.dup2(zerofd, 0) os.dup2(nullfd, 1) os.dup2(nullfd, 2) # Detach process context, this requires 2 forks. try: pid = os.fork() if pid > 0: os._exit(0) except OSError: os._exit(1) try: pid = os.fork() if pid > 0: os._exit(0) except OSError: os._exit(2) server.run()
def setUp(self): super(TestBase, self).setUp() if not self.config_file: self.skipTest("No config specified") self.conf.register_opts(configs._GENERAL_OPTIONS) self.conf.register_opts(validation._TRANSPORT_LIMITS_OPTIONS, group=validation._TRANSPORT_LIMITS_GROUP) self.transport_cfg = self.conf[validation._TRANSPORT_LIMITS_GROUP] self.conf.register_opts(driver._WS_OPTIONS, group=driver._WS_GROUP) self.ws_cfg = self.conf[driver._WS_GROUP] self.conf.unreliable = True self.conf.admin_mode = True self.boot = bootstrap.Bootstrap(self.conf) self.transport = self.boot.transport self.api = self.boot.api
def setUp(self): super(TestBase, self).setUp() if not self.config_file: self.skipTest("No config specified") self.conf.register_opts(default.ALL_OPTS) self.conf.register_opts(transport.ALL_OPTS, group=transport.GROUP_NAME) self.transport_cfg = self.conf[transport.GROUP_NAME] self.conf.register_opts(drivers_transport_websocket.ALL_OPTS, group=drivers_transport_websocket.GROUP_NAME) self.ws_cfg = self.conf[drivers_transport_websocket.GROUP_NAME] self.conf.unreliable = True self.conf.admin_mode = True self.boot = bootstrap.Bootstrap(self.conf) self.addCleanup(self.boot.storage.close) self.addCleanup(self.boot.control.close) self.transport = self.boot.transport self.api = self.boot.api
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. """WSGI App for WSGI Containers This app should be used by external WSGI containers. For example: $ gunicorn zaqar.transport.wsgi.app:app NOTE: As for external containers, it is necessary to put config files in the standard paths. There's no common way to specify / pass configuration files to the WSGI app when it is called from other apps. """ from oslo_config import cfg from zaqar import bootstrap # TODO(kgriffs): For now, we have to use the global config # to pick up common options from openstack.common.log, since # that module uses the global CONF instance exclusively. conf = cfg.CONF conf(project='zaqar', prog='zaqar-queues', args=[]) boot = bootstrap.Bootstrap(conf) conf.drivers.transport = 'wsgi' app = boot.transport.app
def _bootstrap(self, conf_file): conf_file = helpers.override_mongo_conf(conf_file, self) self.conf = self.load_conf(conf_file) return bootstrap.Bootstrap(self.conf)
def get_target(self, conf): conf.admin_mode = True server = bootstrap.Bootstrap(conf) return server.run
def get_target(self, conf): server = bootstrap.Bootstrap(conf) return server.run
def _bootstrap(self, conf_file): self.conf = self.load_conf(conf_file) return bootstrap.Bootstrap(self.conf)
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. """WSGI App for WSGI Containers This app should be used by external WSGI containers. For example: $ gunicorn zaqar.transport.wsgi.app:app NOTE: As for external containers, it is necessary to put config files in the standard paths. There's no common way to specify / pass configuration files to the WSGI app when it is called from other apps. """ from oslo.config import cfg from zaqar import bootstrap # TODO(kgriffs): For now, we have to use the global config # to pick up common options from openstack.common.log, since # that module uses the global CONF instance exclusively. conf = cfg.CONF conf(project='zaqar', prog='zaqar-queues', args=[]) app = bootstrap.Bootstrap(conf).transport.app