Merge "Fixes Hyper-V metrics units"

This commit is contained in:
Jenkins 2014-03-21 09:51:11 +00:00 committed by Gerrit Code Review
commit e0f83ff425
4 changed files with 20 additions and 19 deletions

View File

@ -60,9 +60,9 @@ class HyperVInspector(virt_inspector.Inspector):
parameters=None)
stats = virt_inspector.InterfaceStats(
rx_bytes=vnic_metrics['rx_bytes'],
rx_bytes=vnic_metrics['rx_mb'] * units.Mi,
rx_packets=0,
tx_bytes=vnic_metrics['tx_bytes'],
tx_bytes=vnic_metrics['tx_mb'] * units.Mi,
tx_packets=0)
yield (interface, stats)
@ -77,9 +77,9 @@ class HyperVInspector(virt_inspector.Inspector):
stats = virt_inspector.DiskStats(
read_requests=0,
# Return bytes
read_bytes=disk_metrics['read_mb'] * units.Ki,
read_bytes=disk_metrics['read_mb'] * units.Mi,
write_requests=0,
write_bytes=disk_metrics['write_mb'] * units.Ki,
write_bytes=disk_metrics['write_mb'] * units.Mi,
errors=0)
yield (disk, stats)

View File

@ -115,8 +115,8 @@ class UtilsV2(object):
metric_value_instances, [metric_def_in, metric_def_out])
yield {
'rx_bytes': metric_values[0],
'tx_bytes': metric_values[1],
'rx_mb': metric_values[0],
'tx_mb': metric_values[1],
'element_name': vnic.ElementName,
'address': vnic.Address
}

View File

@ -21,6 +21,7 @@ import mock
from ceilometer.compute.virt.hyperv import inspector as hyperv_inspector
from ceilometer.openstack.common import test
from ceilometer.openstack.common import units
class TestHyperVInspection(test.BaseTestCase):
@ -69,14 +70,14 @@ class TestHyperVInspection(test.BaseTestCase):
def test_inspect_vnics(self):
fake_instance_name = 'fake_instance_name'
fake_rx_bytes = 1000
fake_tx_bytes = 2000
fake_rx_mb = 1000
fake_tx_mb = 2000
fake_element_name = 'fake_element_name'
fake_address = 'fake_address'
self._inspector._utils.get_vnic_metrics.return_value = [{
'rx_bytes': fake_rx_bytes,
'tx_bytes': fake_tx_bytes,
'rx_mb': fake_rx_mb,
'tx_mb': fake_tx_mb,
'element_name': fake_element_name,
'address': fake_address}]
@ -91,8 +92,8 @@ class TestHyperVInspection(test.BaseTestCase):
self.assertEqual(fake_element_name, inspected_vnic.name)
self.assertEqual(fake_address, inspected_vnic.mac)
self.assertEqual(fake_rx_bytes, inspected_stats.rx_bytes)
self.assertEqual(fake_tx_bytes, inspected_stats.tx_bytes)
self.assertEqual(fake_rx_mb * units.Mi, inspected_stats.rx_bytes)
self.assertEqual(fake_tx_mb * units.Mi, inspected_stats.tx_bytes)
def test_inspect_disks(self):
fake_instance_name = 'fake_instance_name'
@ -120,5 +121,5 @@ class TestHyperVInspection(test.BaseTestCase):
self.assertEqual(fake_device, inspected_disk.device)
self.assertEqual(fake_read_mb * 1024, inspected_stats.read_bytes)
self.assertEqual(fake_write_mb * 1024, inspected_stats.write_bytes)
self.assertEqual(fake_read_mb * units.Mi, inspected_stats.read_bytes)
self.assertEqual(fake_write_mb * units.Mi, inspected_stats.write_bytes)

View File

@ -94,8 +94,8 @@ class TestUtilsV2(test.BaseTestCase):
fake_vnic_element_name = "fake_vnic_name"
fake_vnic_address = "fake_vnic_address"
fake_vnic_path = "fake_vnic_path"
fake_rx_bytes = 1000
fake_tx_bytes = 2000
fake_rx_mb = 1000
fake_tx_mb = 2000
self._utils._lookup_vm = mock.MagicMock()
self._utils._get_vm_resources = mock.MagicMock()
@ -112,13 +112,13 @@ class TestUtilsV2(test.BaseTestCase):
self._utils._get_metric_def = mock.MagicMock()
mock_get_by_defs.return_value = [fake_rx_bytes, fake_tx_bytes]
mock_get_by_defs.return_value = [fake_rx_mb, fake_tx_mb]
vnic_metrics = list(self._utils.get_vnic_metrics(fake_vm_element_name))
self.assertEqual(1, len(vnic_metrics))
self.assertEqual(fake_rx_bytes, vnic_metrics[0]['rx_bytes'])
self.assertEqual(fake_tx_bytes, vnic_metrics[0]['tx_bytes'])
self.assertEqual(fake_rx_mb, vnic_metrics[0]['rx_mb'])
self.assertEqual(fake_tx_mb, vnic_metrics[0]['tx_mb'])
self.assertEqual(fake_vnic_element_name,
vnic_metrics[0]['element_name'])
self.assertEqual(fake_vnic_address, vnic_metrics[0]['address'])