@@ -295,54 +295,84 @@ void testDomainK8sEventsNonExistingCluster() {
295
295
}
296
296
297
297
/**
298
- * Test the following domain events are logged when domain resource goes through various life cycle stages.
299
- * Patch the domain resource to remove the webLogicCredentialsSecret and verify DomainChanged is
300
- * logged when operator processes the domain resource changes.
301
- * Verifies DomainProcessingRetrying is logged when operator retries the failed domain resource
302
- * changes since webLogicCredentialsSecret is still missing.
298
+ * Test the following domain events are logged when domain resource goes through introspector failure.
299
+ * Patch the domain resource to shutdown servers.
300
+ * Patch the domain resource to point to a bad DOMAIN_HOME and update serverStartPolicy to IF_NEEDED.
301
+ * Verifies DomainProcessingFailed event is logged.
303
302
* Verifies DomainProcessingAborted is logged when operator exceeds the maximum retries and gives
304
303
* up processing the domain resource.
304
+ * Cleanup by patching the domain resource to a valid location and introspectVersion to bring up all servers again.
305
305
*/
306
306
@ Order (4 )
307
307
@ Test
308
308
@ DisplayName ("Test domain events for failed/retried domain life cycle changes" )
309
309
void testDomainK8SEventsFailed () {
310
310
V1Patch patch ;
311
311
String patchStr ;
312
+ Domain domain = assertDoesNotThrow (() -> getDomainCustomResource (domainUid , domainNamespace1 ));
313
+ String originalDomainHome = domain .getSpec ().getDomainHome ();
312
314
313
315
OffsetDateTime timestamp = now ();
314
316
try {
315
- logger .info ("remove the webLogicCredentialsSecret to verify the following events"
317
+ logger .info ("Shutting down all servers in domain with serverStartPolicy : NEVER" );
318
+ patchStr = "[{\" op\" : \" replace\" , \" path\" : \" /spec/serverStartPolicy\" , \" value\" : \" NEVER\" }]" ;
319
+ patch = new V1Patch (patchStr );
320
+ assertTrue (patchDomainCustomResource (domainUid , domainNamespace1 , patch , V1Patch .PATCH_FORMAT_JSON_PATCH ),
321
+ "patchDomainCustomResource failed" );
322
+
323
+ logger .info ("Checking if the admin server {0} is shutdown in namespace {1}" ,
324
+ adminServerPodName , domainNamespace1 );
325
+ checkPodDoesNotExist (adminServerPodName , domainUid , domainNamespace1 );
326
+
327
+ for (int i = 1 ; i <= replicaCount ; i ++) {
328
+ logger .info ("Checking if the managed server {0} is shutdown in namespace {1}" ,
329
+ managedServerPodNamePrefix + i , domainNamespace1 );
330
+ checkPodDoesNotExist (managedServerPodNamePrefix + i , domainUid , domainNamespace1 );
331
+ }
332
+
333
+ logger .info ("Replace the domainHome to a nonexisting location to verify the following events"
316
334
+ " DomainChanged, DomainProcessingRetrying and DomainProcessingAborted are logged" );
317
- patchStr = "[{\" op\" : \" remove\" , \" path\" : \" /spec/webLogicCredentialsSecret\" }]" ;
318
- logger .info ("PatchStr for webLogicCredentialsSecret: {0}" , patchStr );
335
+ patchStr = "[{\" op\" : \" replace\" , "
336
+ + "\" path\" : \" /spec/domainHome\" , \" value\" : \" " + originalDomainHome + "bad\" },"
337
+ + "{\" op\" : \" replace\" , \" path\" : \" /spec/serverStartPolicy\" , \" value\" : \" IF_NEEDED\" }]" ;
338
+ logger .info ("PatchStr for domainHome: {0}" , patchStr );
319
339
320
340
patch = new V1Patch (patchStr );
321
341
assertTrue (patchDomainCustomResource (domainUid , domainNamespace1 , patch , V1Patch .PATCH_FORMAT_JSON_PATCH ),
322
342
"patchDomainCustomResource failed" );
323
343
324
344
logger .info ("verify domain changed event is logged" );
325
345
checkEvent (opNamespace , domainNamespace1 , domainUid , DOMAIN_CHANGED , "Normal" , timestamp );
326
-
327
346
logger .info ("verify domain processing retrying event" );
328
347
checkEvent (opNamespace , domainNamespace1 , domainUid , DOMAIN_PROCESSING_RETRYING , "Normal" , timestamp );
329
-
330
348
logger .info ("verify domain processing aborted event" );
331
349
checkEvent (opNamespace , domainNamespace1 , domainUid , DOMAIN_PROCESSING_ABORTED , "Warning" , timestamp );
332
350
} finally {
351
+ logger .info ("Restoring the domain with valid location and bringing up all servers" );
333
352
timestamp = now ();
334
- // add back the webLogicCredentialsSecret
335
- patchStr = "[{\" op\" : \" add\" , \" path\" : \" /spec/webLogicCredentialsSecret\" , "
336
- + "\" value\" : {\" name\" :\" " + wlSecretName + "\" , \" namespace\" :\" " + domainNamespace1 + "\" }"
337
- + "}]" ;
338
- logger .info ("PatchStr for webLogicCredentialsSecret: {0}" , patchStr );
353
+ String introspectVersion = assertDoesNotThrow (() -> getNextIntrospectVersion (domainUid , domainNamespace1 ));
354
+ // add back the original domain home
355
+ patchStr = "["
356
+ + "{\" op\" : \" replace\" , \" path\" : \" /spec/domainHome\" , \" value\" : \" " + originalDomainHome + "\" },"
357
+ + "{\" op\" : \" add\" , \" path\" : \" /spec/introspectVersion\" , \" value\" : \" " + introspectVersion + "\" }"
358
+ + "]" ;
359
+ logger .info ("PatchStr for domainHome: {0}" , patchStr );
339
360
340
361
patch = new V1Patch (patchStr );
341
362
assertTrue (patchDomainCustomResource (domainUid , domainNamespace1 , patch , V1Patch .PATCH_FORMAT_JSON_PATCH ),
342
363
"patchDomainCustomResource failed" );
343
364
344
365
logger .info ("verify domain changed event is logged" );
345
366
checkEvent (opNamespace , domainNamespace1 , domainUid , DOMAIN_CHANGED , "Normal" , timestamp );
367
+ logger .info ("verifying the admin server is created and started" );
368
+ checkPodReadyAndServiceExists (adminServerPodName , domainUid , domainNamespace1 );
369
+
370
+ // verify managed server services created
371
+ for (int i = 1 ; i <= replicaCount ; i ++) {
372
+ logger .info ("Checking managed server service/pod {0} is created in namespace {1}" ,
373
+ managedServerPodNamePrefix + i , domainNamespace1 );
374
+ checkPodReadyAndServiceExists (managedServerPodNamePrefix + i , domainUid , domainNamespace1 );
375
+ }
346
376
}
347
377
}
348
378
0 commit comments