Fix for a flaky test failing because k8s is slow
We create a deployment and do the following: ``` self.assertIsNotNone(dep) ``` Which does not fail, and then the code proceeds to deletion and fails with a 404 execption in 80% of the time, but sometimes it works. The deployment is there, but for some reason not available for deletion. Travis CI also showed inconsitent behaviour on this. Python3.5 passed but all other version failed. With this commit we wait for the deployment to become available for deletion and only then continue.
This commit is contained in:
parent
0779fc9c66
commit
2b83c683f8
@ -16,6 +16,7 @@ import unittest
|
||||
|
||||
import yaml
|
||||
from kubernetes import utils, client
|
||||
from kubernetes.client.rest import ApiException
|
||||
from kubernetes.e2e_test import base
|
||||
|
||||
|
||||
@ -39,9 +40,14 @@ class TestUtils(unittest.TestCase):
|
||||
dep = app_api.read_namespaced_deployment(name="nginx-app",
|
||||
namespace="default")
|
||||
self.assertIsNotNone(dep)
|
||||
app_api.delete_namespaced_deployment(
|
||||
name="nginx-app", namespace="default",
|
||||
body={})
|
||||
while True:
|
||||
try:
|
||||
app_api.delete_namespaced_deployment(
|
||||
name="nginx-app", namespace="default",
|
||||
body={})
|
||||
break
|
||||
except ApiException:
|
||||
continue
|
||||
|
||||
def test_create_apps_deployment_from_yaml_string(self):
|
||||
k8s_client = client.api_client.ApiClient(configuration=self.config)
|
||||
@ -55,9 +61,14 @@ class TestUtils(unittest.TestCase):
|
||||
dep = app_api.read_namespaced_deployment(name="nginx-app",
|
||||
namespace="default")
|
||||
self.assertIsNotNone(dep)
|
||||
app_api.delete_namespaced_deployment(
|
||||
name="nginx-app", namespace="default",
|
||||
body={})
|
||||
while True:
|
||||
try:
|
||||
app_api.delete_namespaced_deployment(
|
||||
name="nginx-app", namespace="default",
|
||||
body={})
|
||||
break
|
||||
except ApiException:
|
||||
continue
|
||||
|
||||
def test_create_apps_deployment_from_yaml_obj(self):
|
||||
k8s_client = client.api_client.ApiClient(configuration=self.config)
|
||||
@ -71,9 +82,14 @@ class TestUtils(unittest.TestCase):
|
||||
dep = app_api.read_namespaced_deployment(name="nginx-app",
|
||||
namespace="default")
|
||||
self.assertIsNotNone(dep)
|
||||
app_api.delete_namespaced_deployment(
|
||||
name="nginx-app", namespace="default",
|
||||
body={})
|
||||
while True:
|
||||
try:
|
||||
app_api.delete_namespaced_deployment(
|
||||
name="nginx-app", namespace="default",
|
||||
body={})
|
||||
break
|
||||
except ApiException:
|
||||
continue
|
||||
|
||||
def test_create_extensions_deployment_from_yaml(self):
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user