Skip to content

Commit 97f68c7

Browse files
authored
Fix intermittent ItMultiDomainModelsWithLoadBalancer.testLivenessProbe failure in release/3.4 nightly (#3509)
* Fix intermittent ItMultiDomainModelsWithLoadBalancer.testLivenessProbe failure in release/3.4 nightly
1 parent 06697a2 commit 97f68c7

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMultiDomainModelsWithLoadBalancer.java

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@
7171
import static oracle.weblogic.kubernetes.actions.TestActions.startDomain;
7272
import static oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes.copyFileToPod;
7373
import static oracle.weblogic.kubernetes.assertions.TestAssertions.adminNodePortAccessible;
74+
import static oracle.weblogic.kubernetes.assertions.TestAssertions.isNginxReady;
7475
import static oracle.weblogic.kubernetes.assertions.impl.Domain.doesDomainExist;
7576
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndCheckForServerNameInResponse;
7677
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
78+
import static oracle.weblogic.kubernetes.utils.CommonLBTestUtils.checkIngressReady;
7779
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
7880
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
7981
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.scaleAndVerifyCluster;
@@ -151,6 +153,7 @@ class ItMultiDomainModelsWithLoadBalancer {
151153
private static String opServiceAccount = null;
152154
private static NginxParams nginxHelmParams = null;
153155
private static int nodeportshttp = 0;
156+
private static int nodeportshttps = 0;
154157
private static int externalRestHttpsPort = 0;
155158
private static List<Domain> domains = new ArrayList<>();
156159
private static LoggingFacade logger = null;
@@ -160,6 +163,7 @@ class ItMultiDomainModelsWithLoadBalancer {
160163
private static String miiDomainNegativeNamespace = null;
161164
private static String miiImage = null;
162165
private static String encryptionSecretName = "encryptionsecret";
166+
private static String nginxNamespace = null;
163167
private String curlCmd = null;
164168

165169
/**
@@ -182,7 +186,7 @@ public static void initAll(@Namespaces(6) List<String> namespaces) {
182186
// get a unique NGINX namespace
183187
logger.info("Get a unique namespace for NGINX");
184188
assertNotNull(namespaces.get(1), "Namespace list is null");
185-
String nginxNamespace = namespaces.get(1);
189+
nginxNamespace = namespaces.get(1);
186190

187191
// get unique namespaces for three different type of domains
188192
logger.info("Getting unique namespaces for three different type of domains");
@@ -222,6 +226,8 @@ public static void initAll(@Namespaces(6) List<String> namespaces) {
222226
logger.info("NGINX service name: {0}", nginxServiceName);
223227
nodeportshttp = getServiceNodePort(nginxNamespace, nginxServiceName, "http");
224228
logger.info("NGINX http node port: {0}", nodeportshttp);
229+
nodeportshttps = getServiceNodePort(nginxNamespace, nginxServiceName, "https");
230+
logger.info("NGINX https node port: {0}", nodeportshttps);
225231
}
226232
}
227233

@@ -488,11 +494,22 @@ void testLivenessProbe() {
488494
domainNamespace);
489495
}
490496

497+
// check the NGINX pod is ready.
498+
testUntil(isNginxReady(nginxNamespace),
499+
logger,
500+
"Nginx is ready in namespace {0}",
501+
nginxNamespace);
502+
503+
// check the ingress is ready
504+
String ingressHost = domainUid + "." + domainNamespace + "." + clusterName + ".test";
505+
logger.info("Checking for the ingress is ready");
506+
checkIngressReady(true, ingressHost, false, nodeportshttp, nodeportshttps, "");
507+
491508
//access application in managed servers through NGINX load balancer
492509
logger.info("Accessing the sample app through NGINX load balancer");
493510
String curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
494511
List<String> managedServers = listManagedServersBeforeScale(numClusters, clusterName, replicaCount);
495-
testUntil(() -> callWebAppAndCheckForServerNameInResponse(curlCmd, managedServers, 20),
512+
testUntil(withLongRetryPolicy, () -> callWebAppAndCheckForServerNameInResponse(curlCmd, managedServers, 20),
496513
logger,
497514
"NGINX can access the test web app from all managed servers {0} in the domain",
498515
managedServers);
@@ -684,16 +701,19 @@ void testMiiMultiClustersRollingRestart() {
684701
testUntil(
685702
checkDomainEvent(opNamespace, miiDomainNamespace, miiDomainUid, DOMAIN_CHANGED, "Normal", timestamp),
686703
logger,
687-
"domain event {0} to be logged",
688-
DOMAIN_CHANGED);
704+
"domain event {0} to be logged in namespace {1}",
705+
DOMAIN_CHANGED,
706+
miiDomainNamespace);
689707

690708
// wait for longer time for DomainCompleted event
691709
testUntil(
692710
withLongRetryPolicy,
693711
checkDomainEvent(opNamespace, miiDomainNamespace, miiDomainUid, DOMAIN_PROCESSING_COMPLETED,
694712
"Normal", timestamp),
695713
logger,
696-
DOMAIN_PROCESSING_COMPLETED);
714+
"domain event {0} to be logged in namespace {1}",
715+
DOMAIN_PROCESSING_COMPLETED,
716+
miiDomainNamespace);
697717

698718
// Verify that pod termination and started events are logged only once for each managed server in each cluster
699719
for (int i = 1; i <= NUMBER_OF_CLUSTERS_MIIDOMAIN; i++) {
@@ -703,20 +723,25 @@ void testMiiMultiClustersRollingRestart() {
703723

704724
logger.info("Checking that managed server pod {0} is terminated and restarted once in namespace {1}",
705725
managedServerPodName, miiDomainNamespace);
726+
String stopEventMsg = "Stopping container weblogic-server";
706727
testUntil(
707728
withLongRetryPolicy,
708-
checkPodEventLoggedOnce(miiDomainNamespace, managedServerPodName, POD_TERMINATED, timestamp),
729+
checkPodEventLoggedOnce(miiDomainNamespace, managedServerPodName, POD_TERMINATED, stopEventMsg, timestamp),
709730
logger,
710-
"event {0} to be logged for pod {1}",
731+
"event {0} to be logged for pod {1} in namespace {2}",
711732
POD_TERMINATED,
712-
managedServerPodName);
733+
managedServerPodName,
734+
miiDomainNamespace);
735+
736+
String startedEventMsg = "Started container weblogic-server";
713737
testUntil(
714738
withLongRetryPolicy,
715-
checkPodEventLoggedOnce(miiDomainNamespace, managedServerPodName, POD_STARTED, timestamp),
739+
checkPodEventLoggedOnce(miiDomainNamespace, managedServerPodName, POD_STARTED, startedEventMsg, timestamp),
716740
logger,
717-
"event {0} to be logged for pod {1}",
741+
"event {0} to be logged for pod {1} in namespace {2}",
718742
POD_STARTED,
719-
managedServerPodName);
743+
managedServerPodName,
744+
miiDomainNamespace);
720745
}
721746
}
722747

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonLBTestUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,10 @@ public static void checkIngressReady(boolean isHostRouting, String ingressHost,
608608
}
609609
}
610610
getLogger().info("Executing curl command {0}", curlCmd);
611-
assertTrue(callWebAppAndWaitTillReady(curlCmd, 60));
611+
testUntil(() -> callWebAppAndWaitTillReady(curlCmd, 5),
612+
getLogger(),
613+
"ingress can access ready app using {0}",
614+
curlCmd);
612615
}
613616
}
614617

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/K8sEvents.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,17 +406,19 @@ public static int getEventCount(
406406
* @param domainNamespace namespace in which the domain exists
407407
* @param serverName server pod name for which event is checked
408408
* @param reason event to check for Started, Killing etc
409+
* @param eventMsg event msg for the event
409410
* @param timestamp the timestamp after which to see events
410411
*/
411412
public static Callable<Boolean> checkPodEventLoggedOnce(
412-
String domainNamespace, String serverName, String reason, OffsetDateTime timestamp) {
413+
String domainNamespace, String serverName, String reason, String eventMsg, OffsetDateTime timestamp) {
413414
return () -> {
414415
logger.info("Verifying {0} event is logged for {1} pod in the domain namespace {2}",
415416
reason, serverName, domainNamespace);
416417
try {
417418
return isEventLoggedOnce(serverName, Kubernetes.listNamespacedEvents(domainNamespace).stream()
418419
.filter(e -> e.getInvolvedObject().getName().equals(serverName))
419420
.filter(e -> e.getReason().contains(reason))
421+
.filter(e -> e.getMessage().contains(eventMsg))
420422
.filter(e -> isEqualOrAfter(timestamp, e)).collect(Collectors.toList()).size());
421423
} catch (ApiException ex) {
422424
Logger.getLogger(K8sEvents.class.getName()).log(Level.SEVERE, null, ex);

0 commit comments

Comments
 (0)