summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>2012-10-10 19:43:46 -0400
committerMauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>2012-10-22 07:12:24 -0400
commitad2d4c379c5d424bde1832b664f36aa29432d64f (patch)
treed76c02f84009d6c42298b37ee62b09967206e361
parent8cb329b2a03f1d04f13c38244477e53ca4a321f0 (diff)
downloadnova-ad2d4c379c5d424bde1832b664f36aa29432d64f.tar.gz
nova-ad2d4c379c5d424bde1832b664f36aa29432d64f.tar.xz
nova-ad2d4c379c5d424bde1832b664f36aa29432d64f.zip
Add meaningful server diagnostic information to fake hypervisor
Previously the fake hypervisor didn't returned a fake information similar to the real output so this patch add this sample fake information. Also removed a duplicated check on the tests Change-Id: Iab72a867e6e2606beb15db17701375f3c8f61a79
-rw-r--r--nova/tests/compute/test_compute.py23
-rw-r--r--nova/virt/fake.py17
2 files changed, 34 insertions, 6 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 5a0c8cc2e..9ef0992b4 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -1217,16 +1217,29 @@ class ComputeTestCase(BaseTestCase):
def test_diagnostics(self):
"""Make sure we can get diagnostics for an instance."""
+ expected_diagnostic = {'cpu0_time': 17300000000,
+ 'memory': 524288,
+ 'vda_errors': -1,
+ 'vda_read': 262144,
+ 'vda_read_req': 112,
+ 'vda_write': 5778432,
+ 'vda_write_req': 488,
+ 'vnet1_rx': 2070139,
+ 'vnet1_rx_drop': 0,
+ 'vnet1_rx_errors': 0,
+ 'vnet1_rx_packets': 26701,
+ 'vnet1_tx': 140208,
+ 'vnet1_tx_drop': 0,
+ 'vnet1_tx_errors': 0,
+ 'vnet1_tx_packets': 662,
+ }
+
instance = jsonutils.to_primitive(self._create_fake_instance())
self.compute.run_instance(self.context, instance=instance)
diagnostics = self.compute.get_diagnostics(self.context,
instance=instance)
- self.assertEqual(diagnostics, 'FAKE_DIAGNOSTICS')
-
- diagnostics = self.compute.get_diagnostics(self.context,
- instance=instance)
- self.assertEqual(diagnostics, 'FAKE_DIAGNOSTICS')
+ self.assertEqual(diagnostics, expected_diagnostic)
self.compute.terminate_instance(self.context, instance=instance)
def test_add_fixed_ip_usage_notification(self):
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index 6134019b2..0996988cd 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -184,7 +184,22 @@ class FakeDriver(driver.ComputeDriver):
'cpu_time': 0}
def get_diagnostics(self, instance_name):
- return 'FAKE_DIAGNOSTICS'
+ return {'cpu0_time': 17300000000,
+ 'memory': 524288,
+ 'vda_errors': -1,
+ 'vda_read': 262144,
+ 'vda_read_req': 112,
+ 'vda_write': 5778432,
+ 'vda_write_req': 488,
+ 'vnet1_rx': 2070139,
+ 'vnet1_rx_drop': 0,
+ 'vnet1_rx_errors': 0,
+ 'vnet1_rx_packets': 26701,
+ 'vnet1_tx': 140208,
+ 'vnet1_tx_drop': 0,
+ 'vnet1_tx_errors': 0,
+ 'vnet1_tx_packets': 662,
+ }
def get_all_bw_counters(self, instances):
"""Return bandwidth usage counters for each interface on each