@@ -24,7 +24,17 @@ class TestUtils(unittest.TestCase):
2424 def setUpClass (cls ):
2525 cls .config = base .get_e2e_configuration ()
2626 cls .path_prefix = "kubernetes/e2e_test/test_yaml/"
27+ cls .test_namespace = "e2e-test-utils"
28+ k8s_client = client .api_client .ApiClient (configuration = cls .config )
29+ core_v1 = client .CoreV1Api (api_client = k8s_client )
30+ body = client .V1Namespace (metadata = client .V1ObjectMeta (name = cls .test_namespace ))
31+ core_v1 .create_namespace (body = body )
2732
33+ @classmethod
34+ def tearDownClass (cls ):
35+ k8s_client = client .api_client .ApiClient (configuration = cls .config )
36+ core_v1 = client .CoreV1Api (api_client = k8s_client )
37+ core_v1 .delete_namespace (name = cls .test_namespace )
2838 # Tests for creating individual API objects
2939
3040 def test_create_apps_deployment_from_yaml (self ):
@@ -331,3 +341,44 @@ def test_create_from_multi_resource_yaml_with_multi_conflicts(self):
331341 ext_api .delete_namespaced_deployment (
332342 name = "triple-nginx" , namespace = "default" ,
333343 body = {})
344+
345+ def test_create_namespaces_apps_deployment_from_yaml (self ):
346+ """
347+ Should be able to create an apps/v1beta1 deployment.
348+ """
349+ k8s_client = client .api_client .ApiClient (configuration = self .config )
350+ utils .create_from_yaml (
351+ k8s_client , self .path_prefix + "apps-deployment.yaml" , namespace = self .test_namespace )
352+ app_api = client .AppsV1beta1Api (k8s_client )
353+ dep = app_api .read_namespaced_deployment (name = "nginx-app" ,
354+ namespace = self .test_namespace )
355+ self .assertIsNotNone (dep )
356+ app_api .delete_namespaced_deployment (
357+ name = "nginx-app" , namespace = self .test_namespace ,
358+ body = {})
359+
360+ def test_create_from_list_in_multi_resource_yaml (self ):
361+ """
362+ Should be able to create the items in the PodList and a deployment
363+ specified in the multi-resource file
364+ """
365+ k8s_client = client .api_client .ApiClient (configuration = self .config )
366+ utils .create_from_yaml (
367+ k8s_client , self .path_prefix + "multi-resource-with-list.yaml" , namespace = self .test_namespace )
368+ core_api = client .CoreV1Api (k8s_client )
369+ app_api = client .AppsV1beta1Api (k8s_client )
370+ pod_0 = core_api .read_namespaced_pod (
371+ name = "mock-pod-0" , namespace = self .test_namespace )
372+ self .assertIsNotNone (pod_0 )
373+ pod_1 = core_api .read_namespaced_pod (
374+ name = "mock-pod-1" , namespace = self .test_namespace )
375+ self .assertIsNotNone (pod_1 )
376+ dep = app_api .read_namespaced_deployment (
377+ name = "mock" , namespace = self .test_namespace )
378+ self .assertIsNotNone (dep )
379+ core_api .delete_namespaced_pod (
380+ name = "mock-pod-0" , namespace = self .test_namespace , body = {})
381+ core_api .delete_namespaced_pod (
382+ name = "mock-pod-1" , namespace = self .test_namespace , body = {})
383+ app_api .delete_namespaced_deployment (
384+ name = "mock" , namespace = self .test_namespace , body = {})
0 commit comments