Example #1
0
 def test_diagnostics_serialize(self):
     cpu_details = [diagnostics.CpuDiagnostics()]
     nic_details = [diagnostics.NicDiagnostics()]
     disk_details = [diagnostics.DiskDiagnostics()]
     diags = diagnostics.Diagnostics(
             state='fake-state', driver='fake-driver',
             hypervisor_os='fake-os',
             uptime=1, cpu_details=cpu_details,
             nic_details=nic_details, disk_details=disk_details,
             config_drive=True)
     expected = {'config_drive': True,
                 'cpu_details': [{'time': 0}],
                 'disk_details': [{'errors_count': 0,
                                   'id': '',
                                   'read_bytes': 0,
                                   'read_requests': 0,
                                   'write_bytes': 0,
                                   'write_requests': 0}],
                 'driver': 'fake-driver',
                 'hypervisor_os': 'fake-os',
                 'memory_details': {'maximum': 0, 'used': 0},
                 'nic_details': [{'mac_address': '00:00:00:00:00:00',
                                  'rx_drop': 0,
                                  'rx_errors': 0,
                                  'rx_octets': 0,
                                  'rx_packets': 0,
                                  'tx_drop': 0,
                                  'tx_errors': 0,
                                  'tx_octets': 0,
                                  'tx_packets': 0}],
                 'state': 'fake-state',
                 'uptime': 1,
                 'version': '1.0'}
     result = diags.serialize()
     self.assertEqual(expected, result)
Example #2
0
 def test_diagnostics(self):
     cpu_details = [diagnostics.CpuDiagnostics()]
     nic_details = [diagnostics.NicDiagnostics()]
     disk_details = [diagnostics.DiskDiagnostics()]
     diags = diagnostics.Diagnostics(
             state='fake-state', driver='fake-driver',
             hypervisor_os='fake-os',
             uptime=1, cpu_details=cpu_details,
             nic_details=nic_details, disk_details=disk_details,
             config_drive=True)
     self.assertEqual('fake-state', diags.state)
     self.assertEqual('fake-driver', 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(0, diags.memory_details.maximum)
     self.assertEqual(0, diags.memory_details.used)
     self.assertEqual('1.0', diags.version)
Example #3
0
 def test_cpu_diagnostics(self):
     cpu = diagnostics.CpuDiagnostics(time=7)
     self.assertEqual(7, cpu.time)
Example #4
0
 def test_cpu_diagnostics_default(self):
     cpu = diagnostics.CpuDiagnostics()
     self.assertEqual(0, cpu.time)