本文整理汇总了Python中nova.test函数的典型用法代码示例。如果您正苦于以下问题:Python test函数的具体用法?Python test怎么用?Python test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了test函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_instances_here_pops_problematic_properties
def test_create_instances_here_pops_problematic_properties(self,
mock_update):
values = {
'uuid': uuidsentinel.instance,
'metadata': [],
'id': 1,
'name': 'foo',
'info_cache': 'bar',
'security_groups': 'not secure',
'flavor': 'chocolate',
'pci_requests': 'no thanks',
'ec2_ids': 'prime',
}
@mock.patch.object(self.scheduler.compute_api,
'create_db_entry_for_new_instance')
def test(mock_create_db):
self.scheduler._create_instances_here(
self.ctxt, [uuidsentinel.instance], values,
objects.Flavor(), 'foo', [], [])
test()
# NOTE(danms): Make sure that only the expected properties
# are applied to the instance object. The complex ones that
# would have been mangled over RPC should be removed.
mock_update.assert_called_once_with(
{'uuid': uuidsentinel.instance,
'metadata': {}})
开发者ID:BeyondTheClouds,项目名称:nova,代码行数:29,代码来源:test_cells_scheduler.py
示例2: test_create_instances_here_pops_problematic_properties
def test_create_instances_here_pops_problematic_properties(self, mock_update):
values = {
"uuid": uuidsentinel.instance,
"metadata": [],
"id": 1,
"name": "foo",
"info_cache": "bar",
"security_groups": "not secure",
"flavor": "chocolate",
"pci_requests": "no thanks",
"ec2_ids": "prime",
}
block_device_mapping = [
objects.BlockDeviceMapping(
context=self.ctxt,
**fake_block_device.FakeDbBlockDeviceDict(
block_device.create_image_bdm(uuidsentinel.fake_image_ref), anon=True
)
)
]
@mock.patch.object(self.scheduler.compute_api, "create_db_entry_for_new_instance")
@mock.patch.object(self.scheduler.compute_api, "_bdm_validate_set_size_and_instance")
def test(mock_bdm_validate, mock_create_db):
self.scheduler._create_instances_here(
self.ctxt, [uuidsentinel.instance], values, objects.Flavor(), "foo", [], block_device_mapping
)
test()
# NOTE(danms): Make sure that only the expected properties
# are applied to the instance object. The complex ones that
# would have been mangled over RPC should be removed.
mock_update.assert_called_once_with({"uuid": uuidsentinel.instance, "metadata": {}})
开发者ID:cyx1231st,项目名称:nova,代码行数:34,代码来源:test_cells_scheduler.py
示例3: test_claim_resources_on_destination_no_source_allocations
def test_claim_resources_on_destination_no_source_allocations(self):
"""Tests the negative scenario where the instance does not have
allocations in Placement on the source compute node so no claim is
attempted on the destination compute node.
"""
reportclient = report.SchedulerReportClient()
instance = fake_instance.fake_instance_obj(self.context)
source_node = objects.ComputeNode(
uuid=uuids.source_node, host=instance.host)
dest_node = objects.ComputeNode(uuid=uuids.dest_node, host='dest-host')
@mock.patch.object(reportclient,
'get_allocs_for_consumer',
return_value={})
@mock.patch.object(reportclient,
'claim_resources',
new_callable=mock.NonCallableMock)
def test(mock_claim, mock_get_allocs):
ex = self.assertRaises(
exception.ConsumerAllocationRetrievalFailed,
utils.claim_resources_on_destination,
self.context, reportclient, instance, source_node, dest_node)
mock_get_allocs.assert_called_once_with(
self.context, instance.uuid)
self.assertIn(
'Expected to find allocations for source node resource '
'provider %s' % source_node.uuid, six.text_type(ex))
test()
开发者ID:mahak,项目名称:nova,代码行数:29,代码来源:test_utils.py
示例4: test_claim_resources_on_destination_claim_fails
def test_claim_resources_on_destination_claim_fails(self):
"""Tests the negative scenario where the resource allocation claim
on the destination compute node fails, resulting in an error.
"""
reportclient = report.SchedulerReportClient()
instance = fake_instance.fake_instance_obj(self.context)
source_node = objects.ComputeNode(
uuid=uuids.source_node, host=instance.host)
dest_node = objects.ComputeNode(uuid=uuids.dest_node, host='dest-host')
source_res_allocs = {
'allocations': {
uuids.source_node: {
'resources': {
'VCPU': instance.vcpus,
'MEMORY_MB': instance.memory_mb,
# This would really include ephemeral and swap too but
# we're lazy.
'DISK_GB': instance.root_gb
}
}
},
'consumer_generation': 1,
'project_id': uuids.project_id,
'user_id': uuids.user_id
}
dest_alloc_request = {
'allocations': {
uuids.dest_node: {
'resources': {
'VCPU': instance.vcpus,
'MEMORY_MB': instance.memory_mb,
'DISK_GB': instance.root_gb
}
}
},
}
@mock.patch.object(reportclient,
'get_allocs_for_consumer',
return_value=source_res_allocs)
@mock.patch.object(reportclient,
'claim_resources', return_value=False)
def test(mock_claim, mock_get_allocs):
# NOTE(danms): Don't pass source_node_allocations here to test
# that they are fetched if needed.
self.assertRaises(exception.NoValidHost,
utils.claim_resources_on_destination,
self.context, reportclient, instance,
source_node, dest_node)
mock_get_allocs.assert_called_once_with(
self.context, instance.uuid)
mock_claim.assert_called_once_with(
self.context, instance.uuid, dest_alloc_request,
instance.project_id, instance.user_id,
allocation_request_version='1.28', consumer_generation=1)
test()
开发者ID:mahak,项目名称:nova,代码行数:57,代码来源:test_utils.py
示例5: test_claim_resources_on_destination
def test_claim_resources_on_destination(self):
"""Happy path test where everything is successful."""
reportclient = report.SchedulerReportClient()
instance = fake_instance.fake_instance_obj(self.context)
source_node = objects.ComputeNode(
uuid=uuids.source_node, host=instance.host)
dest_node = objects.ComputeNode(uuid=uuids.dest_node, host='dest-host')
source_res_allocs = {
uuids.source_node: {
'resources': {
'VCPU': instance.vcpus,
'MEMORY_MB': instance.memory_mb,
# This would really include ephemeral and swap too but
# we're lazy.
'DISK_GB': instance.root_gb
}
}
}
dest_alloc_request = {
'allocations': {
uuids.dest_node: {
'resources': {
'VCPU': instance.vcpus,
'MEMORY_MB': instance.memory_mb,
'DISK_GB': instance.root_gb
}
}
},
}
@mock.patch.object(reportclient,
'get_allocs_for_consumer')
@mock.patch.object(reportclient,
'claim_resources', return_value=True)
def test(mock_claim, mock_get_allocs):
utils.claim_resources_on_destination(
self.context, reportclient, instance, source_node, dest_node,
source_res_allocs, consumer_generation=None)
self.assertFalse(mock_get_allocs.called)
mock_claim.assert_called_once_with(
self.context, instance.uuid, dest_alloc_request,
instance.project_id, instance.user_id,
allocation_request_version='1.28', consumer_generation=None)
test()
开发者ID:mahak,项目名称:nova,代码行数:45,代码来源:test_utils.py
示例6: test_delete_instance_no_cell_then_cell
def test_delete_instance_no_cell_then_cell(self, mock_delete,
mock_lookup_instance,
mock_local_delete,
mock_delete_while_booting):
# This checks the case where initially an instance has no cell_name,
# and therefore no host, set but instance.destroy fails because
# there is now a host.
instance = self._create_fake_instance_obj()
instance_with_cell = copy.deepcopy(instance)
instance_with_cell.cell_name = 'foo'
mock_lookup_instance.return_value = instance_with_cell
cells_rpcapi = self.compute_api.cells_rpcapi
@mock.patch.object(cells_rpcapi, 'instance_delete_everywhere')
def test(mock_inst_delete_everywhere):
self.compute_api.delete(self.context, instance)
mock_local_delete.assert_not_called()
mock_delete.assert_called_once_with(self.context,
instance_with_cell)
test()
开发者ID:Chillisystems,项目名称:nova,代码行数:22,代码来源:test_compute_cells.py
示例7: test_create_instances_here_pops_problematic_properties
def test_create_instances_here_pops_problematic_properties(self,
mock_update):
values = {
'uuid': uuidsentinel.instance,
'metadata': [],
'id': 1,
'name': 'foo',
'info_cache': 'bar',
'security_groups': 'not secure',
'flavor': 'chocolate',
'pci_requests': 'no thanks',
'ec2_ids': 'prime',
}
block_device_mapping = [
objects.BlockDeviceMapping(context=self.ctxt,
**fake_block_device.FakeDbBlockDeviceDict(
block_device.create_image_bdm(
uuidsentinel.fake_image_ref),
anon=True))
]
@mock.patch.object(self.scheduler.compute_api,
'create_db_entry_for_new_instance')
@mock.patch.object(self.scheduler.compute_api,
'_bdm_validate_set_size_and_instance')
def test(mock_bdm_validate, mock_create_db):
self.scheduler._create_instances_here(
self.ctxt, [uuidsentinel.instance], values,
objects.Flavor(), 'foo', [], block_device_mapping)
test()
# NOTE(danms): Make sure that only the expected properties
# are applied to the instance object. The complex ones that
# would have been mangled over RPC should be removed.
mock_update.assert_called_once_with(
{'uuid': uuidsentinel.instance,
'metadata': {}})
开发者ID:arbrandes,项目名称:nova,代码行数:38,代码来源:test_cells_scheduler.py
示例8: test_claim_resources_on_destination_no_source_allocations
def test_claim_resources_on_destination_no_source_allocations(self):
"""Tests the negative scenario where the instance does not have
allocations in Placement on the source compute node so no claim is
attempted on the destination compute node.
"""
reportclient = report.SchedulerReportClient()
instance = fake_instance.fake_instance_obj(self.context)
source_node = objects.ComputeNode(
uuid=uuids.source_node, host=instance.host)
dest_node = objects.ComputeNode(uuid=uuids.dest_node, host='dest-host')
@mock.patch.object(reportclient,
'get_allocations_for_consumer_by_provider',
return_value={})
@mock.patch.object(reportclient,
'claim_resources',
new_callable=mock.NonCallableMock)
def test(mock_claim, mock_get_allocs):
utils.claim_resources_on_destination(
self.context, reportclient, instance, source_node, dest_node)
mock_get_allocs.assert_called_once_with(
self.context, uuids.source_node, instance.uuid)
test()
开发者ID:klmitch,项目名称:nova,代码行数:24,代码来源:test_utils.py
注:本文中的nova.test函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论