78
78
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withLongRetryPolicy ;
79
79
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapForDomainCreation ;
80
80
import 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 ;
81
83
import static oracle .weblogic .kubernetes .utils .DomainUtils .verifyDomainStatusConditionTypeDoesNotExist ;
82
84
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
83
85
import static oracle .weblogic .kubernetes .utils .JobUtils .createDomainJob ;
@@ -292,15 +294,16 @@ void testDomainK8sEventsNonExistingManagedServer() {
292
294
@ Test
293
295
@ DisplayName ("Test domain Failed event for non-existing cluster" )
294
296
void testDomainK8sEventsNonExistingCluster () {
297
+ String nonExistingClusterName = "nonexisting-cluster" ;
295
298
OffsetDateTime timestamp = now ();
296
299
createClusterAndVerify (createClusterResource (
297
- "nonexisting-cluster" , "nonexisting-cluster" , domainNamespace3 , replicaCount ));
300
+ nonExistingClusterName , nonExistingClusterName , domainNamespace3 , replicaCount ));
298
301
logger .info ("patch the domain resource with new cluster" );
299
302
try {
300
303
String patchStr
301
304
= "["
302
305
+ "{\" op\" : \" add\" ,\" path\" : \" /spec/clusters/-\" , \" value\" : "
303
- + " {\" name\" : \" nonexisting-cluster \" }"
306
+ + " {\" name\" : \" " + nonExistingClusterName + " \" }"
304
307
+ "}]" ;
305
308
logger .info ("Updating domain configuration using patch string: {0}\n " , patchStr );
306
309
V1Patch patch = new V1Patch (patchStr );
@@ -311,12 +314,7 @@ void testDomainK8sEventsNonExistingCluster() {
311
314
} finally {
312
315
//remove the cluster from domain resource
313
316
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 ));
320
318
// verify the Changed event is generated
321
319
checkEvent (opNamespace , domainNamespace3 , domainUid , DOMAIN_CHANGED , "Normal" , timestamp );
322
320
}
@@ -478,7 +476,7 @@ void testScaleDomainAndVerifyCompletedEvent() {
478
476
createDomain (domainNamespace4 , domainUid , pvName4 , pvcName4 );
479
477
scaleDomainAndVerifyCompletedEvent (1 , ScaleAction .scaleDown , true , domainNamespace4 );
480
478
scaleDomainAndVerifyCompletedEvent (2 , ScaleAction .scaleUp , true , domainNamespace4 );
481
- shutdownDomain ( domainUid , domainNamespace4 );
479
+ deleteDomainResource ( domainNamespace4 , domainUid );
482
480
}
483
481
484
482
/**
@@ -991,4 +989,5 @@ private void scaleDomainAndVerifyCompletedEvent(int replicaCount, ScaleAction te
991
989
opNamespace , namespace , domainUid , DOMAIN_COMPLETED , "Normal" , timestamp , countBefore );
992
990
}
993
991
}
992
+
994
993
}
0 commit comments