Merge "Delete created allocations"
This commit is contained in:
commit
ae26e96f4b
@ -104,7 +104,7 @@ class BaseBaremetalTest(api_version_utils.BaseMicroversionTest,
|
|||||||
cls.power_timeout = CONF.baremetal.power_timeout
|
cls.power_timeout = CONF.baremetal.power_timeout
|
||||||
cls.unprovision_timeout = CONF.baremetal.unprovision_timeout
|
cls.unprovision_timeout = CONF.baremetal.unprovision_timeout
|
||||||
cls.created_objects = {}
|
cls.created_objects = {}
|
||||||
for resource in RESOURCE_TYPES:
|
for resource in RESOURCE_TYPES + ['allocation']:
|
||||||
cls.created_objects[resource] = set()
|
cls.created_objects[resource] = set()
|
||||||
cls.deployed_nodes = set()
|
cls.deployed_nodes = set()
|
||||||
|
|
||||||
@ -122,6 +122,14 @@ class BaseBaremetalTest(api_version_utils.BaseMicroversionTest,
|
|||||||
except lib_exc.BadRequest:
|
except lib_exc.BadRequest:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Delete allocations explicitly after unprovisioning instances, but
|
||||||
|
# before deleting nodes.
|
||||||
|
for allocation in cls.created_objects['allocation']:
|
||||||
|
try:
|
||||||
|
cls.client.delete_allocation(allocation)
|
||||||
|
except lib_exc.NotFound:
|
||||||
|
pass
|
||||||
|
|
||||||
for node in cls.created_objects['node']:
|
for node in cls.created_objects['node']:
|
||||||
try:
|
try:
|
||||||
cls.client.update_node(node, instance_uuid=None)
|
cls.client.update_node(node, instance_uuid=None)
|
||||||
@ -452,3 +460,15 @@ class BaseBaremetalTest(api_version_utils.BaseMicroversionTest,
|
|||||||
res=resource,
|
res=resource,
|
||||||
uuid=uuid)
|
uuid=uuid)
|
||||||
self.assertEqual(expected_link, link)
|
self.assertEqual(expected_link, link)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@creates('allocation')
|
||||||
|
def create_allocation(cls, resource_class, **kwargs):
|
||||||
|
"""Wrapper utility for creating test allocations.
|
||||||
|
|
||||||
|
:param resource_class: Resource class to request.
|
||||||
|
:param kwargs: Other fields to pass.
|
||||||
|
:return: A tuple with the server response and the created allocation.
|
||||||
|
"""
|
||||||
|
resp, body = cls.client.create_allocation(resource_class, **kwargs)
|
||||||
|
return resp, body
|
||||||
|
@ -46,7 +46,7 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
@decorators.idempotent_id('9203ea28-3c61-4108-8498-22247b654ff6')
|
@decorators.idempotent_id('9203ea28-3c61-4108-8498-22247b654ff6')
|
||||||
def test_create_show_allocation(self):
|
def test_create_show_allocation(self):
|
||||||
self.assertIsNone(self.node['allocation_uuid'])
|
self.assertIsNone(self.node['allocation_uuid'])
|
||||||
_, body = self.client.create_allocation(self.resource_class)
|
_, body = self.create_allocation(self.resource_class)
|
||||||
uuid = body['uuid']
|
uuid = body['uuid']
|
||||||
|
|
||||||
self.assertTrue(uuid)
|
self.assertTrue(uuid)
|
||||||
@ -74,7 +74,7 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
self.client.set_node_traits(node2['uuid'], ['CUSTOM_MEOW'])
|
self.client.set_node_traits(node2['uuid'], ['CUSTOM_MEOW'])
|
||||||
self.provide_node(node2['uuid'])
|
self.provide_node(node2['uuid'])
|
||||||
|
|
||||||
_, body = self.client.create_allocation(self.resource_class,
|
_, body = self.create_allocation(self.resource_class,
|
||||||
traits=['CUSTOM_MEOW'])
|
traits=['CUSTOM_MEOW'])
|
||||||
uuid = body['uuid']
|
uuid = body['uuid']
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
name=node_name)
|
name=node_name)
|
||||||
self.provide_node(node2['uuid'])
|
self.provide_node(node2['uuid'])
|
||||||
|
|
||||||
_, body = self.client.create_allocation(self.resource_class,
|
_, body = self.create_allocation(self.resource_class,
|
||||||
candidate_nodes=[node_name])
|
candidate_nodes=[node_name])
|
||||||
uuid = body['uuid']
|
uuid = body['uuid']
|
||||||
|
|
||||||
@ -114,23 +114,21 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
|
|
||||||
@decorators.idempotent_id('84eb3c21-4e16-4f33-9551-dce0f8689462')
|
@decorators.idempotent_id('84eb3c21-4e16-4f33-9551-dce0f8689462')
|
||||||
def test_delete_allocation(self):
|
def test_delete_allocation(self):
|
||||||
_, body = self.client.create_allocation(self.resource_class)
|
_, body = self.create_allocation(self.resource_class)
|
||||||
self.client.delete_allocation(body['uuid'])
|
self.client.delete_allocation(body['uuid'])
|
||||||
self.assertRaises(lib_exc.NotFound, self.client.show_allocation,
|
self.assertRaises(lib_exc.NotFound, self.client.show_allocation,
|
||||||
body['uuid'])
|
body['uuid'])
|
||||||
|
|
||||||
@decorators.idempotent_id('5e30452d-ee92-4342-82c1-5eea5e55c937')
|
@decorators.idempotent_id('5e30452d-ee92-4342-82c1-5eea5e55c937')
|
||||||
def test_delete_allocation_by_name(self):
|
def test_delete_allocation_by_name(self):
|
||||||
_, body = self.client.create_allocation(self.resource_class,
|
_, body = self.create_allocation(self.resource_class, name='banana')
|
||||||
name='banana')
|
|
||||||
self.client.delete_allocation('banana')
|
self.client.delete_allocation('banana')
|
||||||
self.assertRaises(lib_exc.NotFound, self.client.show_allocation,
|
self.assertRaises(lib_exc.NotFound, self.client.show_allocation,
|
||||||
'banana')
|
'banana')
|
||||||
|
|
||||||
@decorators.idempotent_id('fbbc13bc-86da-438b-af01-d1bc1bab57d6')
|
@decorators.idempotent_id('fbbc13bc-86da-438b-af01-d1bc1bab57d6')
|
||||||
def test_show_by_name(self):
|
def test_show_by_name(self):
|
||||||
_, body = self.client.create_allocation(self.resource_class,
|
_, body = self.create_allocation(self.resource_class, name='banana')
|
||||||
name='banana')
|
|
||||||
_, loaded_body = self.client.show_allocation('banana')
|
_, loaded_body = self.client.show_allocation('banana')
|
||||||
# The allocation will likely have been processed by this time, so do
|
# The allocation will likely have been processed by this time, so do
|
||||||
# not compare the whole body.
|
# not compare the whole body.
|
||||||
@ -139,7 +137,7 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
|
|
||||||
@decorators.idempotent_id('4ca123c4-160d-4d8d-a3f7-15feda812263')
|
@decorators.idempotent_id('4ca123c4-160d-4d8d-a3f7-15feda812263')
|
||||||
def test_list_allocations(self):
|
def test_list_allocations(self):
|
||||||
_, body = self.client.create_allocation(self.resource_class)
|
_, body = self.create_allocation(self.resource_class)
|
||||||
|
|
||||||
_, listing = self.client.list_allocations()
|
_, listing = self.client.list_allocations()
|
||||||
self.assertIn(body['uuid'],
|
self.assertIn(body['uuid'],
|
||||||
@ -152,8 +150,8 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
|
|
||||||
@decorators.idempotent_id('092b7148-9ff0-4107-be57-2cfcd21eb5d7')
|
@decorators.idempotent_id('092b7148-9ff0-4107-be57-2cfcd21eb5d7')
|
||||||
def test_list_allocations_by_state(self):
|
def test_list_allocations_by_state(self):
|
||||||
_, body = self.client.create_allocation(self.resource_class)
|
_, body = self.create_allocation(self.resource_class)
|
||||||
_, body2 = self.client.create_allocation(self.resource_class + 'foo2')
|
_, body2 = self.create_allocation(self.resource_class + 'foo2')
|
||||||
|
|
||||||
waiters.wait_for_allocation(self.client, body['uuid'])
|
waiters.wait_for_allocation(self.client, body['uuid'])
|
||||||
waiters.wait_for_allocation(self.client, body2['uuid'],
|
waiters.wait_for_allocation(self.client, body2['uuid'],
|
||||||
@ -177,7 +175,7 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
@decorators.attr(type=['negative'])
|
@decorators.attr(type=['negative'])
|
||||||
@decorators.idempotent_id('bf7e1375-019a-466a-a294-9c1052827ada')
|
@decorators.idempotent_id('bf7e1375-019a-466a-a294-9c1052827ada')
|
||||||
def test_create_allocation_resource_class_mismatch(self):
|
def test_create_allocation_resource_class_mismatch(self):
|
||||||
_, body = self.client.create_allocation(self.resource_class + 'foo')
|
_, body = self.create_allocation(self.resource_class + 'foo')
|
||||||
|
|
||||||
_, body = waiters.wait_for_allocation(self.client, body['uuid'],
|
_, body = waiters.wait_for_allocation(self.client, body['uuid'],
|
||||||
expect_error=True)
|
expect_error=True)
|
||||||
@ -187,7 +185,7 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
@decorators.attr(type=['negative'])
|
@decorators.attr(type=['negative'])
|
||||||
@decorators.idempotent_id('b4eeddee-ca34-44f9-908b-490b78b18486')
|
@decorators.idempotent_id('b4eeddee-ca34-44f9-908b-490b78b18486')
|
||||||
def test_create_allocation_traits_mismatch(self):
|
def test_create_allocation_traits_mismatch(self):
|
||||||
_, body = self.client.create_allocation(
|
_, body = self.create_allocation(
|
||||||
self.resource_class, traits=['CUSTOM_DOES_NOT_EXIST'])
|
self.resource_class, traits=['CUSTOM_DOES_NOT_EXIST'])
|
||||||
|
|
||||||
_, body = waiters.wait_for_allocation(self.client, body['uuid'],
|
_, body = waiters.wait_for_allocation(self.client, body['uuid'],
|
||||||
@ -201,7 +199,7 @@ class TestAllocations(base.BaseBaremetalTest):
|
|||||||
_, node2 = self.create_node(self.chassis['uuid'],
|
_, node2 = self.create_node(self.chassis['uuid'],
|
||||||
resource_class=self.resource_class + 'alt')
|
resource_class=self.resource_class + 'alt')
|
||||||
# Mismatch between the resource class and the candidate node
|
# Mismatch between the resource class and the candidate node
|
||||||
_, body = self.client.create_allocation(
|
_, body = self.create_allocation(
|
||||||
self.resource_class, candidate_nodes=[node2['uuid']])
|
self.resource_class, candidate_nodes=[node2['uuid']])
|
||||||
|
|
||||||
_, body = waiters.wait_for_allocation(self.client, body['uuid'],
|
_, body = waiters.wait_for_allocation(self.client, body['uuid'],
|
||||||
|
Loading…
Reference in New Issue
Block a user