Use unique names in allocation tests

Using the same name can cause the tests to conflict in case of parallel
runs or insufficient clean up.

Change-Id: I745c3540389ec6bdc3f9ad4f0c3164a4d215e1d4
This commit is contained in:
Dmitry Tantsur 2019-07-10 13:42:06 +02:00
parent 9669a92f80
commit 75e91b0e5d
1 changed files with 7 additions and 6 deletions

View File

@ -124,15 +124,16 @@ class TestAllocations(Base):
@decorators.idempotent_id('5e30452d-ee92-4342-82c1-5eea5e55c937')
def test_delete_allocation_by_name(self):
_, body = self.create_allocation(self.resource_class, name='banana')
self.client.delete_allocation('banana')
self.assertRaises(lib_exc.NotFound, self.client.show_allocation,
'banana')
name = 'alloc-%s' % uuidutils.generate_uuid()
_, body = self.create_allocation(self.resource_class, name=name)
self.client.delete_allocation(name)
self.assertRaises(lib_exc.NotFound, self.client.show_allocation, name)
@decorators.idempotent_id('fbbc13bc-86da-438b-af01-d1bc1bab57d6')
def test_show_by_name(self):
_, body = self.create_allocation(self.resource_class, name='banana')
_, loaded_body = self.client.show_allocation('banana')
name = 'alloc-%s' % uuidutils.generate_uuid()
_, body = self.create_allocation(self.resource_class, name=name)
_, loaded_body = self.client.show_allocation(name)
# The allocation will likely have been processed by this time, so do
# not compare the whole body.
for field in ('name', 'uuid', 'resource_class'):