diff --git a/ceilometer/tests/ipmi/platform/test_intel_node_manager.py b/ceilometer/tests/ipmi/platform/test_intel_node_manager.py index bc5513e71..a7cb03f29 100644 --- a/ceilometer/tests/ipmi/platform/test_intel_node_manager.py +++ b/ceilometer/tests/ipmi/platform/test_intel_node_manager.py @@ -29,6 +29,12 @@ class TestNodeManager(base.BaseTestCase): utils.execute = mock.Mock(side_effect=fake_utils.execute_with_nm) self.nm = node_manager.NodeManager() + @classmethod + def tearDownClass(cls): + # reset inited to force an initialization of singleton for next test + node_manager.NodeManager()._inited = False + super(TestNodeManager, cls).tearDownClass() + def test_read_power_all(self): power = self.nm.read_power_all() @@ -52,7 +58,6 @@ class TestNodeManager(base.BaseTestCase): min_val = node_manager._hex(temperature["Minimum_value"]) cur_val = node_manager._hex(temperature["Current_value"]) - self.assertTrue(self.nm.nm_support) # see ipmi_test_data.py for raw data self.assertEqual(23, cur_val) self.assertEqual(22, min_val) @@ -67,11 +72,17 @@ class TestNonNodeManager(base.BaseTestCase): utils.execute = mock.Mock(side_effect=fake_utils.execute_without_nm) self.nm = node_manager.NodeManager() - self.nm.nm_support = False + + @classmethod + def tearDownClass(cls): + # reset inited to force an initialization of singleton for next test + node_manager.NodeManager()._inited = False + super(TestNonNodeManager, cls).tearDownClass() def test_read_power_all(self): power = self.nm.read_power_all() + self.assertFalse(self.nm.nm_support) # Non-Node Manager platform return empty data self.assertEqual({}, power) diff --git a/ceilometer/tests/ipmi/platform/test_ipmi_sensor.py b/ceilometer/tests/ipmi/platform/test_ipmi_sensor.py index 0fc4a8662..be2d2f8a6 100644 --- a/ceilometer/tests/ipmi/platform/test_ipmi_sensor.py +++ b/ceilometer/tests/ipmi/platform/test_ipmi_sensor.py @@ -13,13 +13,12 @@ # under the License. import mock +from oslotest import base from ceilometer.ipmi.platform import ipmi_sensor from ceilometer.tests.ipmi.platform import fake_utils from ceilometer import utils -from oslotest import base - class TestIPMISensor(base.BaseTestCase): @@ -29,9 +28,16 @@ class TestIPMISensor(base.BaseTestCase): utils.execute = mock.Mock(side_effect=fake_utils.execute_with_nm) self.ipmi = ipmi_sensor.IPMISensor() + @classmethod + def tearDownClass(cls): + # reset inited to force an initialization of singleton for next test + ipmi_sensor.IPMISensor()._inited = False + super(TestIPMISensor, cls).tearDownClass() + def test_read_sensor_temperature(self): sensors = self.ipmi.read_sensor_any('Temperature') + self.assertTrue(self.ipmi.ipmi_support) # only temperature data returned. self.assertIn('Temperature', sensors) self.assertEqual(1, len(sensors)) @@ -89,11 +95,17 @@ class TestNonIPMISensor(base.BaseTestCase): utils.execute = mock.Mock(side_effect=fake_utils.execute_without_ipmi) self.ipmi = ipmi_sensor.IPMISensor() - self.ipmi.ipmi_support = False + + @classmethod + def tearDownClass(cls): + # reset inited to force an initialization of singleton for next test + ipmi_sensor.IPMISensor()._inited = False + super(TestNonIPMISensor, cls).tearDownClass() def test_read_sensor_temperature(self): sensors = self.ipmi.read_sensor_any('Temperature') + self.assertFalse(self.ipmi.ipmi_support) # Non-IPMI platform return empty data self.assertEqual({}, sensors)