8000 Explicitly use other deployment names for test · abhinavcoder/python@8d41478 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d41478

Browse files
committed
Explicitly use other deployment names for test
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
1 parent 2b83c68 commit 8d41478

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

kubernetes/e2e_test/test_utils.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,20 @@ def test_create_apps_deployment_from_yaml(self):
5151

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

5757
utils.create_from_yaml(
5858
k8s_client, yaml_str)
5959

6060
app_api = client.AppsV1beta1Api(k8s_client)
61-
dep = app_api.read_namespaced_deployment(name="nginx-app",
61+
dep = app_api.read_namespaced_deployment(name="nginx-app-2",
6262
namespace="default")
6363
self.assertIsNotNone(dep)
6464
while True:
6565
try:
6666
app_api.delete_namespaced_deployment(
67-
name="nginx-app", namespace="default",
67+
name="nginx-app-2", namespace="default",
6868
body={})
6969
break
7070
except ApiException:
@@ -75,21 +75,17 @@ def test_create_apps_deployment_from_yaml_obj(self):
7575
with open(self.path_prefix + "apps-deployment.yaml") as f:
7676
yml_obj = yaml.safe_load(f)
7777

78-
utils.create_from_dict(
79-
k8s_client, yml_obj)
78+
yml_obj["metadata"]["name"] = "nginx-app-3"
79+
80+
utils.create_from_dict(k8s_client, yml_obj)
8081

8182
app_api = client.AppsV1beta1Api(k8s_client)
82-
dep = app_api.read_namespaced_deployment(name="nginx-app",
83+
dep = app_api.read_namespaced_deployment(name="nginx-app-3",
8384
namespace="default")
8485
self.assertIsNotNone(dep)
85-
while True:
86-
try:
87-
app_api.delete_namespaced_deployment(
88-
name="nginx-app", namespace="default",
89-
body={})
90-
break
91-
except ApiException:
92-
continue
86+
app_api.delete_namespaced_deployment(
87+
name="nginx-app-3", namespace="default",
88+
body={})
9389

9490
def test_create_extensions_deployment_from_yaml(self):
9591
"""
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: nginx-app-2
5+
labels:
6+
app: nginx
7+
spec:
8+
replicas: 3
9+
selector:
10+
matchLabels:
11+
app: nginx
12+
template:
13+
metadata:
14+
labels:
15+
app: nginx
16+
spec:
17+
containers:
18+
- name: nginx
19+
image: nginx:1.15.4
20+
ports:
21+
- containerPort: 80

0 commit comments

Comments
 (0)
0