@@ -883,6 +883,39 @@ def test_delete_from_list_in_multi_resource_yaml(self):
883
883
self .assertFalse (pod1_status )
884
884
self .assertFalse (deploy_status )
885
885
886
+ def test_delete_apps_deployment_from_yaml_with_apply (self ):
887
+ """
888
+ Should be able to create and delete an apps/v1 deployment using apply.
889
+ """
890
+ k8s_client = client .api_client .ApiClient (configuration = self .config )
891
+ # Create the deployment
892
+ utils .process_from_yaml (
893
+ k8s_client , self .path_prefix + "apps-deployment.yaml" , apply = True )
894
+ app_api = client .AppsV1Api (k8s_client )
895
+ dep = app_api .read_namespaced_deployment (name = "nginx-app" ,
896
+ namespace = "default" )
897
+ self .assertIsNotNone (dep )
898
+ self .assertEqual ("nginx-app" , dep .metadata .name )
899
+ self .assertEqual (
900
+ "nginx:1.15.4" , dep .spec .template .spec .containers [0 ].image )
901
+ self .assertEqual (
902
+ 80 , dep .spec .template .spec .containers [0 ].ports [0 ].container_port )
903
+ self .assertEqual (
904
+ "nginx" , dep .spec .template .spec .containers [0 ].name )
905
+ self .assertEqual ("nginx" , dep .spec .template .metadata .labels ["app" ])
906
+ self .assertEqual (3 , dep .spec .replicas )
907
+
908
+ # Delete the deployment using apply
909
+ utils .process_from_yaml (
910
+ k8s_client , self .path_prefix + "apps-deployment.yaml" , apply = True , action = "delete" )
911
+ time .sleep (10 ) # Wait for the deletion to propagate
912
+
913
+ # Verify the deployment is deleted
914
+ with self .assertRaises (ApiException ) as cm :
915
+ app_api .read_namespaced_deployment (name = "nginx-app" ,
916
+ namespace = "default" )
917
+ self .assertEqual (cm .exception .status , 404 )
918
+
886
919
887
920
class TestUtilsUnitTests (unittest .TestCase ):
888
921
0 commit comments