Commit b78e0d90 authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review

Merge "Fixed corner cases of incorrect use of oslo.config"

parents a7be8f3b 13f6b72f
......@@ -249,6 +249,12 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_polling', mock.MagicMock())
def setUp(self):
super(BaseAgentManagerTestCase, self).setUp()
self.CONF = self.useFixture(fixture_config.Config()).conf
self.CONF.set_override(
'pipeline_cfg_file',
self.path_get('etc/ceilometer/pipeline.yaml')
)
self.CONF(args=[])
self.mgr = self.create_manager()
self.mgr.extensions = self.create_extension_list()
self.mgr.partition_coordinator = mock.MagicMock()
......@@ -269,11 +275,6 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
'publishers': ["test"]}]
}
self.setup_polling()
self.CONF = self.useFixture(fixture_config.Config()).conf
self.CONF.set_override(
'pipeline_cfg_file',
self.path_get('etc/ceilometer/pipeline.yaml')
)
self.useFixture(mockpatch.PatchObject(
publisher, 'get_publisher', side_effect=self.get_publisher))
......
......@@ -19,6 +19,7 @@ import shutil
from keystoneclient import exceptions as ks_exceptions
import mock
from novaclient import client as novaclient
from oslo_config import fixture as fixture_config
from oslo_service import service as os_service
from oslo_utils import fileutils
from oslotest import base
......@@ -49,6 +50,10 @@ class TestPollsterBuilder(agentbase.TestPollster):
'BaseComputePollster.setup_environment',
mock.Mock(return_value=None))
class TestManager(base.BaseTestCase):
def setUp(self):
super(TestManager, self).setUp()
self.conf = self.useFixture(fixture_config.Config()).conf
self.conf(args=[])
@mock.patch('ceilometer.pipeline.setup_polling', mock.MagicMock())
def test_load_plugins(self):
......
......@@ -25,7 +25,6 @@ from ceilometer import declarative
from ceilometer.hardware.inspector import base as inspector_base
from ceilometer.hardware.pollsters import generic
from ceilometer import sample
from ceilometer import service as ceilometer_service
from ceilometer.tests import base as test_base
......@@ -114,7 +113,7 @@ class TestGenericPollsters(test_base.BaseTestCase):
self.useFixture(mockpatch.Patch(
'ceilometer.hardware.inspector.get_inspector',
self.faux_get_inspector))
ceilometer_service.prepare_service(argv=[], config_files=[])
self.conf(args=[])
self.pollster = generic.GenericHardwareDeclarativePollster()
def __setup_meter_def_file(self, cfg):
......@@ -130,7 +129,6 @@ class TestGenericPollsters(test_base.BaseTestCase):
{}, self.conf.hardware.meter_definitions_file)
return cfg
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def _check_get_samples(self, name, definition,
expected_value, expected_type, expected_unit=None):
self.pollster._update_meter_definition(definition)
......@@ -178,6 +176,8 @@ class TestGenericPollsters(test_base.BaseTestCase):
snmp_inspector=param)]})
self.__setup_meter_def_file(meter_cfg)
pollster = generic.GenericHardwareDeclarativePollster
# Clear cached mapping
pollster.mapping = None
exts = pollster.get_pollsters_extensions()
self.assertEqual(2, len(exts))
self.assertIn(exts[0].name, ['hardware.test1', 'hardware.test2.abc'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment