@@ -419,38 +419,40 @@ void testLivenessProbe() {
419
419
int numClusters = domain .getSpec ().getClusters ().size ();
420
420
421
421
String serverName ;
422
+ String serverNamePrefix ;
422
423
if (numClusters > 1 ) {
423
- serverName = domainUid + "-" + clusterName + "-" + MANAGED_SERVER_NAME_BASE + "1" ;
424
+ serverNamePrefix = domainUid + "-" + clusterName + "-" + MANAGED_SERVER_NAME_BASE ;
424
425
} else {
425
- serverName = domainUid + "-" + MANAGED_SERVER_NAME_BASE + "1" ;
426
+ serverNamePrefix = domainUid + "-" + MANAGED_SERVER_NAME_BASE ;
426
427
}
427
428
428
429
// create file to kill server process
429
430
File killServerScript = assertDoesNotThrow (() -> createScriptToKillServer (),
430
431
"Failed to create script to kill server" );
431
432
logger .info ("File/script created to kill server {0}" , killServerScript );
432
433
433
- checkPodReady (serverName , domainUid , domainNamespace );
434
+ String server1Name = serverNamePrefix + "1" ;
435
+ checkPodReady (server1Name , domainUid , domainNamespace );
434
436
435
437
// copy script to pod
436
438
String destLocation = "/u01/killserver.sh" ;
437
- assertDoesNotThrow (() -> copyFileToPod (domainNamespace , serverName , "weblogic-server" ,
439
+ assertDoesNotThrow (() -> copyFileToPod (domainNamespace , server1Name , "weblogic-server" ,
438
440
killServerScript .toPath (), Paths .get (destLocation )),
439
441
String .format ("Failed to copy file %s to pod %s in namespace %s" ,
440
- killServerScript , serverName , domainNamespace ));
441
- logger .info ("File copied to Pod {0} in namespace {1}" , serverName , domainNamespace );
442
+ killServerScript , server1Name , domainNamespace ));
443
+ logger .info ("File copied to Pod {0} in namespace {1}" , server1Name , domainNamespace );
442
444
443
445
// get the restart count of the container in pod before liveness probe restarts
444
446
final int beforeRestartCount =
445
- assertDoesNotThrow (() -> getContainerRestartCount (domainNamespace , null , serverName , null ),
447
+ assertDoesNotThrow (() -> getContainerRestartCount (domainNamespace , null , server1Name , null ),
446
448
String .format ("Failed to get the restart count of the container from pod {0} in namespace {1}" ,
447
- serverName , domainNamespace ));
449
+ server1Name , domainNamespace ));
448
450
logger .info ("Restart count before liveness probe {0}" , beforeRestartCount );
449
451
450
452
// change file permissions
451
- ExecResult execResult = assertDoesNotThrow (() -> execCommand (domainNamespace , serverName , null ,
453
+ ExecResult execResult = assertDoesNotThrow (() -> execCommand (domainNamespace , server1Name , null ,
452
454
true , "/bin/sh" , "-c" , "chmod +x " + destLocation ),
453
- String .format ("Failed to change permissions for file %s in pod %s" , destLocation , serverName ));
455
+ String .format ("Failed to change permissions for file %s in pod %s" , destLocation , server1Name ));
454
456
assertTrue (execResult .exitValue () == 0 ,
455
457
String .format ("Failed to change file %s permissions, stderr %s stdout %s" , destLocation ,
456
458
execResult .stderr (), execResult .stdout ()));
@@ -461,10 +463,10 @@ void testLivenessProbe() {
461
463
* initiates a container restart.
462
464
*/
463
465
for (int i = 0 ; i < 3 ; i ++) {
464
- execResult = assertDoesNotThrow (() -> execCommand (domainNamespace , serverName , null ,
465
- true , "/bin/sh" , "-c" , destLocation + " " + serverName ),
466
+ execResult = assertDoesNotThrow (() -> execCommand (domainNamespace , server1Name , null ,
467
+ true , "/bin/sh" , "-c" , destLocation + " " + server1Name ),
466
468
String .format ("Failed to execute script %s in pod %s namespace %s" , destLocation ,
467
- serverName , domainNamespace ));
469
+ server1Name , domainNamespace ));
468
470
logger .info ("Command executed to kill server inside pod, exit value {0}, stdout {1}, stderr {2}" ,
469
471
execResult .exitValue (), execResult .stdout (), execResult .stderr ());
470
472
@@ -476,16 +478,26 @@ void testLivenessProbe() {
476
478
}
477
479
478
480
// check pod is ready
479
- checkPodReady (serverName , domainUid , domainNamespace );
481
+ checkPodReady (server1Name , domainUid , domainNamespace );
480
482
481
483
// get the restart count of the container in pod after liveness probe restarts
482
484
int afterRestartCount = assertDoesNotThrow (() ->
483
- getContainerRestartCount (domainNamespace , null , serverName , null ),
485
+ getContainerRestartCount (domainNamespace , null , server1Name , null ),
484
486
String .format ("Failed to get the restart count of the container from pod {0} in namespace {1}" ,
485
- serverName , domainNamespace ));
487
+ server1Name , domainNamespace ));
486
488
assertTrue (afterRestartCount - beforeRestartCount == 1 ,
487
489
String .format ("Liveness probe did not start the container in pod %s in namespace %s" ,
488
- serverName , domainNamespace ));
490
+ server1Name , domainNamespace ));
491
+
492
+ // check the sample app is accessible from admin server pod
493
+ for (int i = 1 ; i <= replicaCount ; i ++) {
494
+ testUntil (
495
+ checkSampleAppReady (domainUid , domainNamespace , serverNamePrefix + i ),
496
+ logger ,
497
+ "sample app is accessible from server {0} in namespace {1}" ,
498
+ serverNamePrefix + i ,
499
+ domainNamespace );
500
+ }
489
501
490
502
//access application in managed servers through NGINX load balancer
491
503
logger .info ("Accessing the sample app through NGINX load balancer" );
@@ -1240,4 +1252,15 @@ private void verifyAdminConsoleLoginUsingIngressController(String domainUid, Str
1240
1252
}
1241
1253
}
1242
1254
1255
+ private Callable <Boolean > checkSampleAppReady (String domainUid , String domainNamespace , String serverName ) {
1256
+ return () -> {
1257
+ String curlCmd = String .format ("curl http://%s:%s/sample-war/index.jsp" , serverName , MANAGED_SERVER_PORT );
1258
+ String adminServerPodName = domainUid + "-" + ADMIN_SERVER_NAME_BASE ;
1259
+ ExecResult execResult = assertDoesNotThrow (() -> execCommand (domainNamespace , adminServerPodName , null ,
1260
+ true , "/bin/sh" , "-c" , curlCmd ),
1261
+ String .format ("Failed to execute curl command %s from pod %s in namespace %s" , curlCmd ,
1262
+ adminServerPodName , domainNamespace ));
1263
+ return execResult .stdout ().contains (serverName .substring (domainUid .length () + 1 ));
1264
+ };
1265
+ }
1243
1266
}
0 commit comments