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 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 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") self.mconf = self.load_conf(self.cfg.zaqar.config) validator = validation.Validator(self.mconf) self.limits = validator._limits_conf transport_base._config_options() self.resource_defaults = transport_base.ResourceDefaults(self.mconf) 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.client = http.Client() else: if self.server_class == ZaqarAdminServer: self.mconf.pooling = True self.mconf.admin_mode = True self.client = http.WSGIClient( bootstrap.Bootstrap(self.mconf).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 = set(['location', 'content-type']) self.client.set_headers(self.headers)
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-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()
# 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.queues.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.queues 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
def _bootstrap(self, conf_file): 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) conf.admin_mode = False return server.run
def get_target(self, conf): server = bootstrap.Bootstrap(conf) return server.run