Skip to content

Commit

Permalink
Explicitly use other deployment names for test
Browse files Browse the repository at this point in the history
Using `nginx-app` deployment multiple times, is problematic because we get
conflicts or not found error.

Instead of trying to handle all cases, explicit different names
are used now. The tests now runs more reliably
  • Loading branch information
oz123 committed Apr 8, 2019
1 parent 2b83c68 commit 8d41478
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
24 changes: 10 additions & 14 deletions kubernetes/e2e_test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ def test_create_apps_deployment_from_yaml(self):

def test_create_apps_deployment_from_yaml_string(self):
k8s_client = client.api_client.ApiClient(configuration=self.config)
with open(self.path_prefix + "apps-deployment.yaml") as f:
with open(self.path_prefix + "apps-deployment-2.yaml") as f:
yaml_str = f.read()

utils.create_from_yaml(
k8s_client, yaml_str)

app_api = client.AppsV1beta1Api(k8s_client)
dep = app_api.read_namespaced_deployment(name="nginx-app",
dep = app_api.read_namespaced_deployment(name="nginx-app-2",
namespace="default")
self.assertIsNotNone(dep)
while True:
try:
app_api.delete_namespaced_deployment(
name="nginx-app", namespace="default",
name="nginx-app-2", namespace="default",
body={})
break
except ApiException:
Expand All @@ -75,21 +75,17 @@ def test_create_apps_deployment_from_yaml_obj(self):
with open(self.path_prefix + "apps-deployment.yaml") as f:
yml_obj = yaml.safe_load(f)

utils.create_from_dict(
k8s_client, yml_obj)
yml_obj["metadata"]["name"] = "nginx-app-3"

utils.create_from_dict(k8s_client, yml_obj)

app_api = client.AppsV1beta1Api(k8s_client)
dep = app_api.read_namespaced_deployment(name="nginx-app",
dep = app_api.read_namespaced_deployment(name="nginx-app-3",
namespace="default")
self.assertIsNotNone(dep)
while True:
try:
app_api.delete_namespaced_deployment(
name="nginx-app", namespace="default",
body={})
break
except ApiException:
continue
app_api.delete_namespaced_deployment(
name="nginx-app-3", namespace="default",
body={})

def test_create_extensions_deployment_from_yaml(self):
"""
Expand Down
21 changes: 21 additions & 0 deletions kubernetes/e2e_test/test_yaml/apps-deployment-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: nginx-app-2
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.15.4
ports:
- containerPort: 80

0 comments on commit 8d41478

Please sign in to comment.