Skip to content

Commit b901019

Browse files
hzhao-githubhuizhao
andauthored
Investigate an intermittent issue from testSameSessionStickinessUsingVoyager (#2297)
* investigate an intermittent issue from testSameSessionStickinessUsingVoyager Co-authored-by: huizhao <[email protected]>
1 parent c43f4ab commit b901019

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyTraefik;
6262
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installAndVerifyVoyager;
6363
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.installVoyagerIngressAndVerify;
64+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.isVoyagerPodReady;
6465
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.setPodAntiAffinity;
6566
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
6667
import static org.assertj.core.api.Assertions.assertThat;
@@ -202,12 +203,41 @@ public void testSameSessionStickinessUsingVoyager() {
202203
final String ingressName = domainUid + "-ingress-host-routing";
203204
final String ingressServiceName = VOYAGER_CHART_NAME + "-" + ingressName;
204205
final String channelName = "tcp-80";
206+
final int maxRetry = 60;
205207

206208
// create Voyager ingress resource
207209
Map<String, Integer> clusterNameMsPortMap = new HashMap<>();
208210
clusterNameMsPortMap.put(clusterName, managedServerPort);
209-
List<String> hostNames =
210-
installVoyagerIngressAndVerify(domainUid, domainNamespace, ingressName, clusterNameMsPortMap);
211+
212+
List<String> hostNames = null;
213+
214+
for (int i = 0; i < maxRetry; i++) {
215+
hostNames =
216+
installVoyagerIngressAndVerify(domainUid, domainNamespace, ingressName, clusterNameMsPortMap);
217+
218+
if (hostNames != null && !hostNames.isEmpty()) {
219+
break;
220+
}
221+
222+
try {
223+
// sometimes the ingress may not be ready even the condition check is ready, sleep a little bit
224+
Thread.sleep(1000);
225+
} catch (InterruptedException ignore) {
226+
// ignore
227+
}
228+
}
229+
230+
withStandardRetryPolicy
231+
.conditionEvaluationListener(
232+
condition -> logger.info("Waiting for pod {0} to be created in namespace {1} "
233+
+ "(elapsed time {2}ms, remaining time {3}ms)",
234+
ingressServiceName,
235+
domainNamespace,
236+
condition.getElapsedTimeInMS(),
237+
condition.getRemainingTimeInMS()))
238+
.until(assertDoesNotThrow(() -> isVoyagerPodReady(domainNamespace, ingressServiceName),
239+
String.format("podExists failed with ApiException for pod %s in namespace %s",
240+
ingressServiceName, domainNamespace)));
211241

212242
// get Voyager ingress service Nodeport
213243
int ingressServiceNodePort =

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,15 @@ public static List<String> installVoyagerIngressAndVerify(String domainUid,
14921492
return ingressHostList;
14931493
}
14941494

1495+
/**
1496+
* Check Voyager pod is running in the specified namespace.
1497+
*
1498+
* @param podName pod name to check
1499+
* @param namespace the namespace in which the pod is running
1500+
*/
1501+
public static Callable<Boolean> isVoyagerPodReady(String namespace, String podName) {
1502+
return isVoyagerReady(namespace, podName);
1503+
}
14951504

14961505
/**
14971506
* Execute command inside a pod and assert the execution.

0 commit comments

Comments
 (0)