From ad2d4c379c5d424bde1832b664f36aa29432d64f Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Wed, 10 Oct 2012 19:43:46 -0400 Subject: 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 --- nova/tests/compute/test_compute.py | 23 ++++++++++++++++++----- nova/virt/fake.py | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 6 deletions(-) (limited to 'nova') 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 -- cgit