Skip to content

Commit 7c47656

Browse files
Improve remove interfaces check in cluster testing (#4150)
1 parent 8e8876e commit 7c47656

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

tests/test-cluster.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,17 @@ def test_calico_interfaces_removed_on_snap_remove(self):
383383
print("Waiting for machine {}".format(vm.vm_name))
384384
vm.run("/snap/bin/microk8s.status --wait-ready --timeout 240")
385385
timeout = time.time() + 240
386-
while time.time() <= timeout:
387-
pods = vm.run("/snap/bin/microk8s.kubectl get po -n kube-system -o wide")
388-
for line in pods.decode().splitlines():
389-
if "calico" in line and "Running" in line:
390-
break
386+
ready = False
387+
while time.time() <= timeout and not ready:
388+
try:
389+
pods = vm.run("/snap/bin/microk8s.kubectl get po -n kube-system -o wide")
390+
for line in pods.decode().splitlines():
391+
if "calico" in line and "Running" in line:
392+
ready = True
393+
except ChildProcessError:
394+
print("Waiting for k8s pods to come up")
391395
time.sleep(5)
396+
assert ready
392397
vm.run("snap remove --purge microk8s")
393398
interfaces = vm.run("/sbin/ip a")
394399
assert "cali" not in interfaces.decode()

0 commit comments

Comments
 (0)