Skip to content

Commit 74c6934

Browse files
authored
Owls85476 attempt to fix intermittent integration test issues in nightlies (#2037)
* switch to kubectl and improve the test code * change testAddSecondApp to use kubectl as well * more changes * check main thread done as well * minor update * minor change
1 parent 46b42a5 commit 74c6934

File tree

3 files changed

+54
-56
lines changed

3 files changed

+54
-56
lines changed

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

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.HashMap;
1313
import java.util.List;
1414
import java.util.Map;
15-
import java.util.concurrent.TimeUnit;
15+
import java.util.concurrent.Callable;
1616

1717
import io.kubernetes.client.custom.V1Patch;
1818
import io.kubernetes.client.openapi.models.V1ConfigMap;
@@ -44,6 +44,7 @@
4444
import org.junit.jupiter.params.ParameterizedTest;
4545
import org.junit.jupiter.params.provider.MethodSource;
4646

47+
import static java.util.concurrent.TimeUnit.MILLISECONDS;
4748
import static java.util.concurrent.TimeUnit.MINUTES;
4849
import static java.util.concurrent.TimeUnit.SECONDS;
4950
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
@@ -122,6 +123,7 @@ class ItMiiDomain {
122123
private String miiImageAddSecondApp = null;
123124
private String miiImage = null;
124125
private static LoggingFacade logger = null;
126+
private static volatile boolean mainThreadDone = false;
125127

126128
/**
127129
* Install Operator.
@@ -137,9 +139,9 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
137139
.atMost(6, MINUTES).await();
138140

139141
// create a reusable quick retry policy
140-
withQuickRetryPolicy = with().pollDelay(0, SECONDS)
141-
.and().with().pollInterval(4, SECONDS)
142-
.atMost(10, SECONDS).await();
142+
withQuickRetryPolicy = with().pollDelay(1, SECONDS)
143+
.and().with().pollInterval(2, SECONDS)
144+
.atMost(15, SECONDS).await();
143145

144146
// get a new unique opNamespace
145147
logger.info("Creating unique namespace for Operator");
@@ -334,7 +336,7 @@ public void testPatchAppV2() {
334336
accountingThread =
335337
new Thread(
336338
() -> {
337-
collectAppAvaiability(
339+
collectAppAvailability(
338340
domainNamespace,
339341
appAvailability,
340342
managedServerPrefix,
@@ -394,7 +396,7 @@ public void testPatchAppV2() {
394396
MII_APP_RESPONSE_V2 + i);
395397
}
396398
} finally {
397-
399+
mainThreadDone = true;
398400
if (accountingThread != null) {
399401
try {
400402
accountingThread.join();
@@ -1060,56 +1062,74 @@ private void checkPodImagePatched(
10601062
namespace)));
10611063
}
10621064

1063-
private static void collectAppAvaiability(
1065+
private static void collectAppAvailability(
10641066
String namespace,
10651067
List<Integer> appAvailability,
10661068
String managedServerPrefix,
10671069
int replicaCount,
10681070
String internalPort,
10691071
String appPath
10701072
) {
1071-
boolean v2AppAvailable = false;
1073+
with().pollDelay(2, SECONDS)
1074+
.and().with().pollInterval(200, MILLISECONDS)
1075+
.atMost(15, MINUTES)
1076+
.await()
1077+
.conditionEvaluationListener(
1078+
condition -> logger.info("Waiting for patched application running on all managed servers in namespace {1} "
1079+
+ "(elapsed time {2}ms, remaining time {3}ms)",
1080+
namespace,
1081+
condition.getElapsedTimeInMS(),
1082+
condition.getRemainingTimeInMS()))
1083+
.until(assertDoesNotThrow(() -> checkContinuousAvailability(
1084+
namespace, appAvailability, managedServerPrefix, replicaCount, internalPort, appPath),
1085+
String.format(
1086+
"App is not available on all managed servers in namespace %s.",
1087+
namespace)));
10721088

1073-
// Access the pod periodically to check application's availability across the duration
1074-
// of patching the domain with newer version of the application.
1075-
while (!v2AppAvailable) {
1076-
v2AppAvailable = true;
1089+
}
1090+
1091+
private static Callable<Boolean> checkContinuousAvailability(
1092+
String namespace,
1093+
List<Integer> appAvailability,
1094+
String managedServerPrefix,
1095+
int replicaCount,
1096+
String internalPort,
1097+
String appPath) {
1098+
return () -> {
1099+
boolean v2AppAvailable = true;
1100+
10771101
for (int i = 1; i <= replicaCount; i++) {
10781102
v2AppAvailable = v2AppAvailable && appAccessibleInPod(
10791103
namespace,
1080-
managedServerPrefix + i,
1081-
internalPort,
1082-
appPath,
1104+
managedServerPrefix + i,
1105+
internalPort,
1106+
appPath,
10831107
MII_APP_RESPONSE_V2 + i);
10841108
}
10851109

10861110
int count = 0;
10871111
for (int i = 1; i <= replicaCount; i++) {
10881112
if (appAccessibleInPod(
10891113
namespace,
1090-
managedServerPrefix + i,
1091-
internalPort,
1092-
appPath,
1093-
"Hello World")) {
1114+
managedServerPrefix + i,
1115+
internalPort,
1116+
appPath,
1117+
"Hello World")) {
10941118
count++;
10951119
}
10961120
}
10971121
appAvailability.add(count);
1098-
1122+
10991123
if (count == 0) {
1100-
logger.info("XXXXXXXXXXX: application not available XXXXXXXX");
1101-
break;
1102-
} else {
1103-
logger.fine("YYYYYYYYYYY: application available YYYYYYYY count = " + count);
1124+
logger.info("NNNNNNNNNNN: application not available NNNNNNNN");
1125+
return true;
11041126
}
1105-
try {
1106-
TimeUnit.MILLISECONDS.sleep(200);
1107-
} catch (InterruptedException ie) {
1108-
// do nothing
1109-
}
1110-
}
1127+
1128+
logger.fine("YYYYYYYYYYY: application available YYYYYYYY count = " + count);
1129+
return v2AppAvailable || mainThreadDone;
1130+
};
11111131
}
1112-
1132+
11131133
private static boolean appAlwaysAvailable(List<Integer> appAvailability) {
11141134
for (Integer count: appAvailability) {
11151135
if (count == 0) {

integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/TestAssertions.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ public static Callable<Boolean> credentialsNotValid(
431431
}
432432

433433
/**
434-
* Check if an application is accessible inside a WebLogic server pod using
435-
* Kubernetes Java client API.
434+
* Check if an application is accessible inside a WebLogic server pod.
436435
*
437436
* @param namespace Kubernetes namespace where the WebLogic server pod is running
438437
* @param podName name of the WebLogic server pod
@@ -447,27 +446,6 @@ public static boolean appAccessibleInPod(
447446
String port,
448447
String appPath,
449448
String expectedResponse
450-
) {
451-
return Application.appAccessibleInPod(namespace, podName, port, appPath, expectedResponse);
452-
}
453-
454-
/**
455-
* Check if an application is accessible inside a WebLogic server pod using
456-
* "kubectl exec" command.
457-
*
458-
* @param namespace Kubernetes namespace where the WebLogic server pod is running
459-
* @param podName name of the WebLogic server pod
460-
* @param port internal port of the managed server running in the pod
461-
* @param appPath path to access the application
462-
* @param expectedResponse the expected response from the application
463-
* @return true if the command succeeds
464-
*/
465-
public static boolean appAccessibleInPodKubectl(
466-
String namespace,
467-
String podName,
468-
String port,
469-
String appPath,
470-
String expectedResponse
471449
) {
472450
return Application.appAccessibleInPodKubectl(namespace, podName, port, appPath, expectedResponse);
473451
}
@@ -489,7 +467,7 @@ public static boolean appNotAccessibleInPod(
489467
String appPath,
490468
String expectedResponse
491469
) {
492-
return !Application.appAccessibleInPod(namespace, podName, port, appPath, expectedResponse);
470+
return !Application.appAccessibleInPodKubectl(namespace, podName, port, appPath, expectedResponse);
493471
}
494472

495473
/**

integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static boolean appAccessibleInPod(
8383
}
8484

8585
/**
86-
* Check if an application is accessible inside a WebLogic server pod.
86+
* Check if an application is accessible inside a WebLogic server pod using "kubectl exec" command.
8787
*
8888
* @param namespace Kubernetes namespace where the WebLogic server pod is running
8989
* @param podName name of the WebLogic server pod

0 commit comments

Comments
 (0)