def test_diagnostics(self): cpu_details = [diagnostics.CpuDiagnostics()] nic_details = [diagnostics.NicDiagnostics()] disk_details = [diagnostics.DiskDiagnostics()] memory_details = diagnostics.MemoryDiagnostics(maximum=1, used=1) diags = diagnostics.Diagnostics(state='running', driver='libvirt', hypervisor_os='fake-os', uptime=1, cpu_details=cpu_details, nic_details=nic_details, disk_details=disk_details, config_drive=True, memory_details=memory_details) self.assertEqual('running', diags.state) self.assertEqual('libvirt', diags.driver) self.assertEqual('fake-os', diags.hypervisor_os) self.assertEqual(1, diags.uptime) self.assertTrue(diags.config_drive) self.assertEqual(1, len(diags.cpu_details)) self.assertEqual(1, len(diags.nic_details)) self.assertEqual(1, len(diags.disk_details)) self.assertEqual(1, diags.num_cpus) self.assertEqual(1, diags.num_disks) self.assertEqual(1, diags.num_nics) self.assertEqual(1, diags.memory_details.maximum) self.assertEqual(1, diags.memory_details.used) self.assertEqual('1.0', diags.VERSION)
def get_instance_diagnostics(self, instance): diags = diagnostics_obj.Diagnostics(state='running', driver='libvirt', hypervisor='kvm', hypervisor_os='ubuntu', uptime=46664, config_drive=True) diags.add_cpu(id=0, time=17300000000, utilisation=15) diags.add_nic(mac_address='01:23:45:67:89:ab', rx_octets=2070139, rx_errors=100, rx_drop=200, rx_packets=26701, rx_rate=300, tx_octets=140208, tx_errors=400, tx_drop=500, tx_packets=662, tx_rate=600) diags.add_disk(read_bytes=262144, read_requests=112, write_bytes=5778432, write_requests=488, errors_count=1) diags.memory_details = diagnostics_obj.MemoryDiagnostics( maximum=524288, used=0) return diags
def test_memory_diagnostics(self): memory = diagnostics.MemoryDiagnostics(maximum=1, used=2) self.assertEqual(1, memory.maximum) self.assertEqual(2, memory.used)