Wait for container deletion in tests

Container deletion was changed from sync to async. If users submit a
request to delete a container, server will response immediately but
the container might not be deleted right away. Users should not assume
the container is deleted unless the container is not shown up in list.

Therefore, the tempest test case need to be updated to deal with this
change. After the delete request is issued, we add logic to wait for
the container to disappear before doing the assertion. This should
fix the intermittent failure of the gate.

Change-Id: I9160c503183a1d909dfcfe67eba0e27ae3499a14
This commit is contained in:
Hongbin Lu 2017-11-13 18:07:17 +00:00
parent aef76c557a
commit 64171f68e6

View File

@ -74,6 +74,14 @@ class ContainerTests(base.TestCase):
time.sleep(2)
count = count + 1
self.container_delete(container['name'])
# Wait for the container to be deleted
count = 0
while count < 5:
container_list = self.container_list()
if container['name'] not in [x['name'] for x in container_list]:
break
time.sleep(2)
count = count + 1
container_list = self.container_list()
self.assertNotIn(container['name'],
[x['name'] for x in container_list])