7878import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withLongRetryPolicy ;
7979import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapForDomainCreation ;
8080import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
81+ import static oracle .weblogic .kubernetes .utils .DomainUtils .deleteDomainResource ;
82+ import static oracle .weblogic .kubernetes .utils .DomainUtils .removeClusterInDomainResource ;
8183import static oracle .weblogic .kubernetes .utils .DomainUtils .verifyDomainStatusConditionTypeDoesNotExist ;
8284import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
8385import static oracle .weblogic .kubernetes .utils .JobUtils .createDomainJob ;
@@ -292,15 +294,16 @@ void testDomainK8sEventsNonExistingManagedServer() {
292294 @ Test
293295 @ DisplayName ("Test domain Failed event for non-existing cluster" )
294296 void testDomainK8sEventsNonExistingCluster () {
297+ String nonExistingClusterName = "nonexisting-cluster" ;
295298 OffsetDateTime timestamp = now ();
296299 createClusterAndVerify (createClusterResource (
297- "nonexisting-cluster" , "nonexisting-cluster" , domainNamespace3 , replicaCount ));
300+ nonExistingClusterName , nonExistingClusterName , domainNamespace3 , replicaCount ));
298301 logger .info ("patch the domain resource with new cluster" );
299302 try {
300303 String patchStr
301304 = "["
302305 + "{\" op\" : \" add\" ,\" path\" : \" /spec/clusters/-\" , \" value\" : "
303- + " {\" name\" : \" nonexisting-cluster \" }"
306+ + " {\" name\" : \" " + nonExistingClusterName + " \" }"
304307 + "}]" ;
305308 logger .info ("Updating domain configuration using patch string: {0}\n " , patchStr );
306309 V1Patch patch = new V1Patch (patchStr );
@@ -311,12 +314,7 @@ void testDomainK8sEventsNonExistingCluster() {
311314 } finally {
312315 //remove the cluster from domain resource
313316 timestamp = now ();
314- String patchStr = "[{\" op\" : \" remove\" ,\" path\" : \" /spec/clusters/1\" }]" ;
315- logger .info ("Updating domain configuration using patch string: {0}\n " , patchStr );
316- V1Patch patch = new V1Patch (patchStr );
317- assertTrue (patchDomainCustomResource (domainUid , domainNamespace3 , patch , V1Patch .PATCH_FORMAT_JSON_PATCH ),
318- "Failed to patch domain" );
319-
317+ assertDoesNotThrow (() -> removeClusterInDomainResource (nonExistingClusterName , domainUid , domainNamespace3 ));
320318 // verify the Changed event is generated
321319 checkEvent (opNamespace , domainNamespace3 , domainUid , DOMAIN_CHANGED , "Normal" , timestamp );
322320 }
@@ -478,7 +476,7 @@ void testScaleDomainAndVerifyCompletedEvent() {
478476 createDomain (domainNamespace4 , domainUid , pvName4 , pvcName4 );
479477 scaleDomainAndVerifyCompletedEvent (1 , ScaleAction .scaleDown , true , domainNamespace4 );
480478 scaleDomainAndVerifyCompletedEvent (2 , ScaleAction .scaleUp , true , domainNamespace4 );
481- shutdownDomain ( domainUid , domainNamespace4 );
479+ deleteDomainResource ( domainNamespace4 , domainUid );
482480 }
483481
484482 /**
@@ -991,4 +989,5 @@ private void scaleDomainAndVerifyCompletedEvent(int replicaCount, ScaleAction te
991989 opNamespace , namespace , domainUid , DOMAIN_COMPLETED , "Normal" , timestamp , countBefore );
992990 }
993991 }
992+
994993}
0 commit comments