Skip to content

Commit

Permalink
Fix for a flaky test failing because k8s is slow
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oz123 committed Apr 8, 2019
1 parent 0779fc9 commit 2b83c68
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions kubernetes/e2e_test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import yaml
from kubernetes import utils, client
from kubernetes.client.rest import ApiException
from kubernetes.e2e_test import base


Expand All @@ -39,9 +40,14 @@ def test_create_apps_deployment_from_yaml(self):
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)
Expand All @@ -55,9 +61,14 @@ def test_create_apps_deployment_from_yaml_string(self):
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)
Expand All @@ -71,9 +82,14 @@ def test_create_apps_deployment_from_yaml_obj(self):
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):
"""
Expand Down

0 comments on commit 2b83c68

Please sign in to comment.