@@ -295,54 +295,84 @@ void testDomainK8sEventsNonExistingCluster() {
295295 }
296296
297297 /**
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.
303302 * Verifies DomainProcessingAborted is logged when operator exceeds the maximum retries and gives
304303 * up processing the domain resource.
304+ * Cleanup by patching the domain resource to a valid location and introspectVersion to bring up all servers again.
305305 */
306306 @ Order (4 )
307307 @ Test
308308 @ DisplayName ("Test domain events for failed/retried domain life cycle changes" )
309309 void testDomainK8SEventsFailed () {
310310 V1Patch patch ;
311311 String patchStr ;
312+ Domain domain = assertDoesNotThrow (() -> getDomainCustomResource (domainUid , domainNamespace1 ));
313+ String originalDomainHome = domain .getSpec ().getDomainHome ();
312314
313315 OffsetDateTime timestamp = now ();
314316 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"
316334 + " 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 );
319339
320340 patch = new V1Patch (patchStr );
321341 assertTrue (patchDomainCustomResource (domainUid , domainNamespace1 , patch , V1Patch .PATCH_FORMAT_JSON_PATCH ),
322342 "patchDomainCustomResource failed" );
323343
324344 logger .info ("verify domain changed event is logged" );
325345 checkEvent (opNamespace , domainNamespace1 , domainUid , DOMAIN_CHANGED , "Normal" , timestamp );
326-
327346 logger .info ("verify domain processing retrying event" );
328347 checkEvent (opNamespace , domainNamespace1 , domainUid , DOMAIN_PROCESSING_RETRYING , "Normal" , timestamp );
329-
330348 logger .info ("verify domain processing aborted event" );
331349 checkEvent (opNamespace , domainNamespace1 , domainUid , DOMAIN_PROCESSING_ABORTED , "Warning" , timestamp );
332350 } finally {
351+ logger .info ("Restoring the domain with valid location and bringing up all servers" );
333352 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 );
339360
340361 patch = new V1Patch (patchStr );
341362 assertTrue (patchDomainCustomResource (domainUid , domainNamespace1 , patch , V1Patch .PATCH_FORMAT_JSON_PATCH ),
342363 "patchDomainCustomResource failed" );
343364
344365 logger .info ("verify domain changed event is logged" );
345366 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+ }
346376 }
347377 }
348378
0 commit comments