Exemple #1
0
 def test_create(self, mock_get, mock_create):
     mock_create.return_value = fake_compute_node
     compute = compute_node.ComputeNode(context=self.context)
     compute.service_id = 456
     compute.uuid = uuidsentinel.fake_compute_node
     compute.stats = fake_stats
     # NOTE (pmurray): host_ip is coerced to an IPAddress
     compute.host_ip = fake_host_ip
     compute.supported_hv_specs = fake_supported_hv_specs
     with mock.patch('oslo_utils.uuidutils.generate_uuid') as mock_gu:
         compute.create()
         self.assertFalse(mock_gu.called)
     self.compare_obj(compute,
                      fake_compute_node,
                      subs=self.subs(),
                      comparators=self.comparators())
     param_dict = {
         'service_id': 456,
         'stats': fake_stats_db_format,
         'host_ip': fake_host_ip,
         'supported_instances': fake_supported_hv_specs_db_format,
         'uuid': uuidsentinel.fake_compute_node
     }
     mock_create.assert_called_once_with(self.context, param_dict)
 def test_save(self, mock_get):
     self.mox.StubOutWithMock(db, 'compute_node_update')
     db.compute_node_update(
         self.context, 123,
         {
             'vcpus_used': 3,
             'stats': fake_stats_db_format,
             'host_ip': fake_host_ip,
             'supported_instances': fake_supported_hv_specs_db_format,
             'uuid': uuidsentinel.fake_compute_node,
         }).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode(context=self.context)
     compute.id = 123
     compute.vcpus_used = 3
     compute.stats = fake_stats
     compute.uuid = uuidsentinel.fake_compute_node
     # NOTE (pmurray): host_ip is coerced to an IPAddress
     compute.host_ip = fake_host_ip
     compute.supported_hv_specs = fake_supported_hv_specs
     compute.save()
     self.compare_obj(compute, fake_compute_node,
                      subs=self.subs(),
                      comparators=self.comparators())
Exemple #3
0
 def test_compat_supported_hv_specs(self):
     compute = compute_node.ComputeNode()
     compute.supported_hv_specs = fake_supported_hv_specs
     primitive = compute.obj_to_primitive(target_version='1.5')
     self.assertNotIn('supported_hv_specs', primitive)
Exemple #4
0
 def test_compat_numa_topology(self):
     compute = compute_node.ComputeNode()
     primitive = compute.obj_to_primitive(target_version='1.4')
     self.assertNotIn('numa_topology', primitive)
Exemple #5
0
 def test_set_id_failure(self, db_mock):
     compute = compute_node.ComputeNode()
     compute.create(self.context)
     self.assertRaises(exception.ReadOnlyFieldError, setattr, compute, 'id',
                       124)
 def test_compat_disk_allocation_ratio(self):
     compute = compute_node.ComputeNode()
     primitive = compute.obj_to_primitive(target_version='1.15')
     self.assertNotIn('disk_allocation_ratio', primitive)
 def test_compat_allocation_ratios(self):
     compute = compute_node.ComputeNode()
     primitive = compute.obj_to_primitive(target_version='1.13')
     self.assertNotIn('cpu_allocation_ratio', primitive)
     self.assertNotIn('ram_allocation_ratio', primitive)
 def test_compat_host(self):
     compute = compute_node.ComputeNode()
     primitive = compute.obj_to_primitive(target_version='1.6')
     self.assertNotIn('host', primitive)
 def test_compat_numa_topology(self):
     compute = compute_node.ComputeNode()
     versions = ovo_base.obj_tree_get_versions('ComputeNode')
     primitive = compute.obj_to_primitive(target_version='1.4',
                                          version_manifest=versions)
     self.assertNotIn('numa_topology', primitive)
 def test_set_id_failure(self, mock_get, db_mock):
     compute = compute_node.ComputeNode(context=self.context,
                                        uuid=fake_compute_node['uuid'])
     compute.create()
     self.assertRaises(ovo_exc.ReadOnlyFieldError, setattr, compute, 'id',
                       124)
Exemple #11
0
 def test_compat_pci_device_pools(self):
     compute = compute_node.ComputeNode()
     compute.pci_device_pools = fake_pci_device_pools.fake_pool_list
     primitive = compute.obj_to_primitive(target_version='1.8')
     self.assertNotIn('pci_device_pools', primitive)
 def test_destroy(self, mock_delete):
     compute = compute_node.ComputeNode(context=self.context)
     compute.id = 123
     compute.destroy()
     mock_delete.assert_called_once_with(self.context, 123)