From a3c8a84834cf835274cc0f586791358b20a6d93d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= <radoslaw.piliszek@gmail.com>
Date: Thu, 21 Nov 2019 13:57:08 +0100
Subject: [PATCH] CI: Wait for Zun to delete the test container

We fail randomly on check-failure.sh which checks for
containers being down.
Since we share Docker with Zun, the script sees Zun test container
and may fail when it is stopped but not yet removed.

Change-Id: If8b001f7507663e49e8e535f1889592e5f428ab5
Closes-bug: #1853452
---
 tests/test-zun.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tests/test-zun.sh b/tests/test-zun.sh
index d2d3c265c..1c5d6b34d 100755
--- a/tests/test-zun.sh
+++ b/tests/test-zun.sh
@@ -30,6 +30,22 @@ function test_zun_logged {
     openstack appcontainer list
     openstack appcontainer show test
     openstack appcontainer delete --force --stop test
+
+    # NOTE(yoctozepto): We have to wait for the container to be deleted due to
+    # check-failure.sh checking stopped containers and failing.
+    # It is also nice to test that deleting actually works.
+    attempt=1
+    while openstack appcontainer show test; do
+        echo "Container not deleted yet"
+        attempt=$((attempt+1))
+        if [[ $attempt -eq 10 ]]; then
+            echo "Zun failed to delete the container"
+            openstack appcontainer show test
+            return 1
+        fi
+        sleep 10
+    done
+
     echo "SUCCESS: Zun"
 }
 
-- 
GitLab