Merge "Fix IPMI unit test to cover different platforms"

This commit is contained in:
Jenkins 2015-02-02 18:45:09 +00:00 committed by Gerrit Code Review
commit 186f634881
2 changed files with 28 additions and 5 deletions

View File

@ -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)

View File

@ -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)