summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-07-05 22:20:58 +0000
committerGerrit Code Review <review@openstack.org>2012-07-05 22:20:58 +0000
commitefa69b44ccdacc788a39b893d46168a725c95ec2 (patch)
treea87defd95abff8ee5c746abd38acb7b81f96b0e8 /nova/tests
parent6335e66e1c1a825c28cb7beb46ef913401693bae (diff)
parent6222385d837f90f769c94f21d003999741c4f800 (diff)
Merge "Get hypervisor uptime."
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_hypervisors.py41
-rw-r--r--nova/tests/compute/test_compute.py13
-rw-r--r--nova/tests/compute/test_rpcapi.py3
-rw-r--r--nova/tests/test_virt_drivers.py4
-rw-r--r--nova/tests/test_xenapi.py4
5 files changed, 65 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_hypervisors.py b/nova/tests/api/openstack/compute/contrib/test_hypervisors.py
index b00497ecc..6a9a1fc25 100644
--- a/nova/tests/api/openstack/compute/contrib/test_hypervisors.py
+++ b/nova/tests/api/openstack/compute/contrib/test_hypervisors.py
@@ -231,6 +231,36 @@ class HypervisorsTest(test.TestCase):
cpu_info='cpu_info',
disk_available_least=100)))
+ def test_uptime_noid(self):
+ req = fakes.HTTPRequest.blank('/v2/fake/os-hypervisors/3')
+ self.assertRaises(exc.HTTPNotFound, self.controller.show, req, '3')
+
+ def test_uptime_notimplemented(self):
+ def fake_get_host_uptime(context, hyp):
+ raise exc.HTTPNotImplemented()
+
+ self.stubs.Set(self.controller.api, 'get_host_uptime',
+ fake_get_host_uptime)
+
+ req = fakes.HTTPRequest.blank('/v2/fake/os-hypervisors/1')
+ self.assertRaises(exc.HTTPNotImplemented,
+ self.controller.uptime, req, '1')
+
+ def test_uptime_implemented(self):
+ def fake_get_host_uptime(context, hyp):
+ return "fake uptime"
+
+ self.stubs.Set(self.controller.api, 'get_host_uptime',
+ fake_get_host_uptime)
+
+ req = fakes.HTTPRequest.blank('/v2/fake/os-hypervisors/1')
+ result = self.controller.uptime(req, '1')
+
+ self.assertEqual(result, dict(hypervisor=dict(
+ id=1,
+ hypervisor_hostname="hyper1",
+ uptime="fake uptime")))
+
def test_search(self):
req = fakes.HTTPRequest.blank('/v2/fake/os-hypervisors/hyper/search')
result = self.controller.search(req, 'hyper')
@@ -374,6 +404,17 @@ class HypervisorsSerializersTest(test.TestCase):
self.compare_to_exemplar(exemplar['hypervisor'], tree)
+ def test_uptime_serializer(self):
+ serializer = hypervisors.HypervisorUptimeTemplate()
+ exemplar = dict(hypervisor=dict(
+ hypervisor_hostname="hyper1",
+ id=1,
+ uptime='fake uptime'))
+ text = serializer.serialize(exemplar)
+ tree = etree.fromstring(text)
+
+ self.compare_to_exemplar(exemplar['hypervisor'], tree)
+
def test_servers_serializer(self):
serializer = hypervisors.HypervisorServersTemplate()
exemplar = dict(hypervisors=[
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index bd7db1c37..784054d0e 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -4057,6 +4057,19 @@ class ComputeHostAPITestCase(BaseTestCase):
'args': {'enabled': 'fake_enabled'},
'version': compute_rpcapi.ComputeAPI.RPC_API_VERSION})
+ def test_get_host_uptime(self):
+ ctxt = context.RequestContext('fake', 'fake')
+ call_info = {}
+ self._rpc_call_stub(call_info)
+
+ self.host_api.get_host_uptime(ctxt, 'fake_host')
+ self.assertEqual(call_info['context'], ctxt)
+ self.assertEqual(call_info['topic'], 'compute.fake_host')
+ self.assertEqual(call_info['msg'],
+ {'method': 'get_host_uptime',
+ 'args': {},
+ 'version': compute_rpcapi.ComputeAPI.RPC_API_VERSION})
+
def test_host_power_action(self):
ctxt = context.RequestContext('fake', 'fake')
call_info = {}
diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py
index 37427477f..4f606c7b5 100644
--- a/nova/tests/compute/test_rpcapi.py
+++ b/nova/tests/compute/test_rpcapi.py
@@ -281,6 +281,9 @@ class ComputeRpcAPITestCase(test.TestCase):
self._test_compute_api('set_host_enabled', 'call',
enabled='enabled', host='host')
+ def test_get_host_uptime(self):
+ self._test_compute_api('get_host_uptime', 'call', host='host')
+
def test_snapshot_instance(self):
self._test_compute_api('snapshot_instance', 'cast',
instance=self.fake_instance, image_id='id', image_type='type',
diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py
index 56efc75f9..e95d15ae5 100644
--- a/nova/tests/test_virt_drivers.py
+++ b/nova/tests/test_virt_drivers.py
@@ -522,6 +522,10 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
self.connection.set_host_enabled('a useless argument?', True)
@catch_notimplementederror
+ def test_get_host_uptime(self):
+ self.connection.get_host_uptime('a useless argument?')
+
+ @catch_notimplementederror
def test_host_power_action_reboot(self):
self.connection.host_power_action('a useless argument?', 'reboot')
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index e39049d34..3138ef0b9 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -1162,6 +1162,10 @@ class XenAPIHostTestCase(stubs.XenAPITestBase):
def test_set_enable_host_disable(self):
self._test_host_action(self.conn.set_host_enabled, False, 'disabled')
+ def test_get_host_uptime(self):
+ result = self.conn.get_host_uptime('host')
+ self.assertEqual(result, 'fake uptime')
+
class XenAPIAutoDiskConfigTestCase(stubs.XenAPITestBase):
def setUp(self):