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
This commit is contained in:
parent
2b83c683f8
commit
8d41478ed8
@ -51,20 +51,20 @@ class TestUtils(unittest.TestCase):
|
||||
|
||||
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:
|
||||
@ -75,21 +75,17 @@ class TestUtils(unittest.TestCase):
|
||||
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):
|
||||
"""
|
||||
|
||||
21
kubernetes/e2e_test/test_yaml/apps-deployment-2.yaml
Normal file
21
kubernetes/e2e_test/test_yaml/apps-deployment-2.yaml
Normal file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user