Do not use system config file for test
Use dummy config file so that test depends on default config opts instead of system config file. Change-Id: I4ffbd389f80bbdb6076cdd99d3b25ffb4a26f32e Closes-Bug: #1482695
This commit is contained in:
parent
ca4c452bfc
commit
53c73ec2f8
@ -112,7 +112,7 @@ cfg.CONF.register_opt(COLL_OPT, 'collector')
|
|||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def prepare_service(argv=None):
|
def prepare_service(argv=None, config_files=None):
|
||||||
oslo_i18n.enable_lazy()
|
oslo_i18n.enable_lazy()
|
||||||
log.register_options(cfg.CONF)
|
log.register_options(cfg.CONF)
|
||||||
log_levels = (cfg.CONF.default_log_levels +
|
log_levels = (cfg.CONF.default_log_levels +
|
||||||
@ -121,7 +121,8 @@ def prepare_service(argv=None):
|
|||||||
if argv is None:
|
if argv is None:
|
||||||
argv = sys.argv
|
argv = sys.argv
|
||||||
cfg.CONF(argv[1:], project='ceilometer', validate_default_values=True,
|
cfg.CONF(argv[1:], project='ceilometer', validate_default_values=True,
|
||||||
version=version.version_info.version_string())
|
version=version.version_info.version_string(),
|
||||||
|
default_config_files=config_files)
|
||||||
log.setup(cfg.CONF, 'ceilometer')
|
log.setup(cfg.CONF, 'ceilometer')
|
||||||
# NOTE(liusheng): guru cannot run with service under apache daemon, so when
|
# NOTE(liusheng): guru cannot run with service under apache daemon, so when
|
||||||
# ceilometer-api running with mod_wsgi, the argv is [], we don't start
|
# ceilometer-api running with mod_wsgi, the argv is [], we don't start
|
||||||
|
@ -56,7 +56,7 @@ class ConfigFixture(fixture.GabbiFixture):
|
|||||||
if db_url is None:
|
if db_url is None:
|
||||||
raise case.SkipTest('No database connection configured')
|
raise case.SkipTest('No database connection configured')
|
||||||
|
|
||||||
service.prepare_service([])
|
service.prepare_service(argv=[], config_files=[])
|
||||||
conf = fixture_config.Config().conf
|
conf = fixture_config.Config().conf
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
opts.set_defaults(self.conf)
|
opts.set_defaults(self.conf)
|
||||||
|
@ -199,7 +199,8 @@ class BaseRealNotification(tests_base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseRealNotification, self).setUp()
|
super(BaseRealNotification, self).setUp()
|
||||||
self.CONF = self.useFixture(fixture_config.Config()).conf
|
self.CONF = self.useFixture(fixture_config.Config()).conf
|
||||||
service.prepare_service([])
|
# Dummy config file to avoid looking for system config
|
||||||
|
service.prepare_service(argv=[], config_files=[])
|
||||||
self.setup_messaging(self.CONF, 'nova')
|
self.setup_messaging(self.CONF, 'nova')
|
||||||
|
|
||||||
pipeline_cfg_file = self.setup_pipeline(['instance', 'memory'])
|
pipeline_cfg_file = self.setup_pipeline(['instance', 'memory'])
|
||||||
@ -452,7 +453,7 @@ class TestRealNotificationMultipleAgents(tests_base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRealNotificationMultipleAgents, self).setUp()
|
super(TestRealNotificationMultipleAgents, self).setUp()
|
||||||
self.CONF = self.useFixture(fixture_config.Config()).conf
|
self.CONF = self.useFixture(fixture_config.Config()).conf
|
||||||
service.prepare_service([])
|
service.prepare_service(argv=[], config_files=[])
|
||||||
self.setup_messaging(self.CONF, 'nova')
|
self.setup_messaging(self.CONF, 'nova')
|
||||||
|
|
||||||
pipeline_cfg_file = self.setup_pipeline(['instance', 'memory'])
|
pipeline_cfg_file = self.setup_pipeline(['instance', 'memory'])
|
||||||
|
@ -53,7 +53,7 @@ class DispatcherTest(base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DispatcherTest, self).setUp()
|
super(DispatcherTest, self).setUp()
|
||||||
self.conf = self.useFixture(config_fixture.Config())
|
self.conf = self.useFixture(config_fixture.Config())
|
||||||
ceilometer_service.prepare_service([])
|
ceilometer_service.prepare_service(argv=[], config_files=[])
|
||||||
self.conf.config(
|
self.conf.config(
|
||||||
resources_definition_file=self.path_get(
|
resources_definition_file=self.path_get(
|
||||||
'etc/ceilometer/gnocchi_resources.yaml'),
|
'etc/ceilometer/gnocchi_resources.yaml'),
|
||||||
@ -330,7 +330,7 @@ class DispatcherWorkflowTest(base.BaseTestCase,
|
|||||||
return_value=ks_client))
|
return_value=ks_client))
|
||||||
self.ks_client = ks_client
|
self.ks_client = ks_client
|
||||||
|
|
||||||
ceilometer_service.prepare_service([])
|
ceilometer_service.prepare_service(argv=[], config_files=[])
|
||||||
self.conf.config(
|
self.conf.config(
|
||||||
resources_definition_file=self.path_get(
|
resources_definition_file=self.path_get(
|
||||||
'etc/ceilometer/gnocchi_resources.yaml'),
|
'etc/ceilometer/gnocchi_resources.yaml'),
|
||||||
|
@ -193,7 +193,7 @@ class TestMeterProcessing(test.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestMeterProcessing, self).setUp()
|
super(TestMeterProcessing, self).setUp()
|
||||||
self.CONF = self.useFixture(fixture_config.Config()).conf
|
self.CONF = self.useFixture(fixture_config.Config()).conf
|
||||||
ceilometer_service.prepare_service([])
|
ceilometer_service.prepare_service(argv=[], config_files=[])
|
||||||
self.handler = notifications.ProcessMeterNotifications(mock.Mock())
|
self.handler = notifications.ProcessMeterNotifications(mock.Mock())
|
||||||
|
|
||||||
def test_fallback_meter_path(self):
|
def test_fallback_meter_path(self):
|
||||||
|
@ -25,7 +25,7 @@ class TestOpencontrailClient(base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestOpencontrailClient, self).setUp()
|
super(TestOpencontrailClient, self).setUp()
|
||||||
self.conf = self.useFixture(config_fixture.Config())
|
self.conf = self.useFixture(config_fixture.Config())
|
||||||
ceilometer_service.prepare_service([])
|
ceilometer_service.prepare_service(argv=[], config_files=[])
|
||||||
self.client = client.Client('http://127.0.0.1:8081', {'arg1': 'aaa'})
|
self.client = client.Client('http://127.0.0.1:8081', {'arg1': 'aaa'})
|
||||||
|
|
||||||
self.get_resp = mock.MagicMock()
|
self.get_resp = mock.MagicMock()
|
||||||
|
@ -32,7 +32,7 @@ class TestClientHTTPBasicAuth(base.BaseTestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestClientHTTPBasicAuth, self).setUp()
|
super(TestClientHTTPBasicAuth, self).setUp()
|
||||||
self.conf = self.useFixture(config_fixture.Config())
|
self.conf = self.useFixture(config_fixture.Config())
|
||||||
ceilometer_service.prepare_service([])
|
ceilometer_service.prepare_service(argv=[], config_files=[])
|
||||||
self.parsed_url = urlparse.urlparse(
|
self.parsed_url = urlparse.urlparse(
|
||||||
'http://127.0.0.1:8080/controller/nb/v2?container_name=default&'
|
'http://127.0.0.1:8080/controller/nb/v2?container_name=default&'
|
||||||
'container_name=egg&auth=%s&user=admin&password=admin_pass&'
|
'container_name=egg&auth=%s&user=admin&password=admin_pass&'
|
||||||
|
Loading…
Reference in New Issue
Block a user