Skip to content

Commit 9071bea

Browse files
authored
Fix multiple intermittent test issues (#3758)
* fix intermittent test issue
1 parent 6cbe700 commit 9071bea

File tree

3 files changed

+94
-39
lines changed

3 files changed

+94
-39
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ void testCompleteAvailableConditionWithReplicaExceedMaxSizeAndIntrospectVersionC
387387
patch = new V1Patch(patchStr);
388388
assertTrue(patchClusterCustomResource(clusterResName, domainNamespace1, patch,
389389
V1Patch.PATCH_FORMAT_JSON_PATCH), "Failed to patch cluster");
390-
390+
391+
// wait for the managed server2 get deleted
392+
checkPodDoesNotExist(managedServerPodNamePrefix + 2, domainUid, domainNamespace1);
393+
391394
int newReplicaCount = maxClusterSize + 1;
392395
logger.info("patch the domain resource with new introspectVersion and replicas higher than max cluster size");
393396
patchStr = "["

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

Lines changed: 84 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@
4646
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
4747
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO;
4848
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET_NAME;
49+
import static oracle.weblogic.kubernetes.TestConstants.CLUSTER_VERSION;
4950
import static oracle.weblogic.kubernetes.TestConstants.DB_IMAGE_TO_USE_IN_SPEC;
5051
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
5152
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE;
5253
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_STATUS_CONDITION_COMPLETED_TYPE;
5354
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_STATUS_CONDITION_FAILED_TYPE;
55+
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
5456
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_NAME;
5557
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TAG;
5658
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TO_USE_IN_SPEC;
@@ -64,6 +66,8 @@
6466
import static oracle.weblogic.kubernetes.actions.TestActions.deleteConfigMap;
6567
import static oracle.weblogic.kubernetes.actions.TestActions.patchClusterCustomResource;
6668
import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource;
69+
import static oracle.weblogic.kubernetes.assertions.TestAssertions.clusterExists;
70+
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
6771
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainStatusReasonMatches;
6872
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterAndVerify;
6973
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResource;
@@ -72,6 +76,7 @@
7276
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
7377
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
7478
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
79+
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.configMapExist;
7580
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapFromFiles;
7681
import static oracle.weblogic.kubernetes.utils.DbUtils.createRcuAccessSecret;
7782
import static oracle.weblogic.kubernetes.utils.DbUtils.setupDBandRCUschema;
@@ -108,16 +113,13 @@ class ItDiagnosticsFailedCondition {
108113

109114
private static String domainNamespace = null;
110115
int replicaCount = 2;
111-
String wlClusterName = "cluster-1";
116+
private String wlClusterName = "cluster-1";
112117

113118

114119
private static String adminSecretName;
115120
private static String encryptionSecretName;
116121
private static final String domainUid = "diagnosticsdomain";
117122

118-
private static String opServiceAccount = null;
119-
private static String opNamespace = null;
120-
121123
private static LoggingFacade logger = null;
122124
private static List<String> ns;
123125

@@ -134,14 +136,14 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
134136
logger = getLogger();
135137
logger.info("Assign a unique namespace for operator");
136138
assertNotNull(namespaces.get(0), "Namespace is null");
137-
opNamespace = namespaces.get(0);
139+
String opNamespace = namespaces.get(0);
138140

139141
logger.info("Assign a unique namespace for WebLogic domain");
140142
assertNotNull(namespaces.get(1), "Namespace is null");
141143
domainNamespace = namespaces.get(1);
142144

143145
// set the service account name for the operator
144-
opServiceAccount = opNamespace + "-sa";
146+
String opServiceAccount = opNamespace + "-sa";
145147

146148
// install and verify operator with REST API
147149
installAndVerifyOperator(opNamespace, opServiceAccount, true, 0, domainNamespace);
@@ -206,9 +208,15 @@ void testBadModelFileStatus() {
206208
if (!testPassed) {
207209
LoggingUtil.generateLog(this, ns);
208210
}
209-
deleteDomainResource(domainNamespace, domainName);
210-
deleteConfigMap(badModelFileCm, domainNamespace);
211-
deleteClusterCustomResource(clusterResName, domainNamespace);
211+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
212+
deleteDomainResource(domainNamespace, domainName);
213+
}
214+
if (assertDoesNotThrow(() -> configMapExist(domainNamespace, badModelFileCm).call())) {
215+
deleteConfigMap(badModelFileCm, domainNamespace);
216+
}
217+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
218+
deleteClusterCustomResource(clusterResName, domainNamespace);
219+
}
212220
}
213221
}
214222

@@ -244,17 +252,19 @@ void testReplicasTooHigh() {
244252
"waiting for domain status condition reason ReplicasTooHigh exists"
245253
);
246254

247-
// remove after debug
255+
// Need to patch the cluster first, otherwise the domain can not be patched
256+
// You will get this error:
257+
// the replica count of cluster 'cluster-1' would exceed the cluster size '5' when patching the domain
248258
String patchStr
249259
= "["
250260
+ "{\"op\": \"replace\", \"path\": \"/spec/replicas\", \"value\": 2}"
251261
+ "]";
252262
V1Patch patch = new V1Patch(patchStr);
253263
logger.info("Patching cluster resource using patch string {0} ", patchStr);
264+
254265
assertTrue(patchClusterCustomResource(clusterResName, domainNamespace,
255266
patch, V1Patch.PATCH_FORMAT_JSON_PATCH), "Failed to patch cluster");
256-
//end of debug
257-
267+
258268
patchStr = "[{\"op\": \"replace\", "
259269
+ "\"path\": \"/spec/webLogicCredentialsSecret/name\", \"value\": \"weblogic-credentials-foo\"}]";
260270
logger.info("PatchStr for domainHome: {0}", patchStr);
@@ -286,8 +296,12 @@ void testReplicasTooHigh() {
286296
if (!testPassed) {
287297
LoggingUtil.generateLog(this, ns);
288298
}
289-
deleteDomainResource(domainNamespace, domainName);
290-
deleteClusterCustomResource(clusterResName, domainNamespace);
299+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
300+
deleteDomainResource(domainNamespace, domainName);
301+
}
302+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
303+
deleteClusterCustomResource(clusterResName, domainNamespace);
304+
}
291305
}
292306
}
293307

@@ -334,8 +348,12 @@ void testReplicasTooHighNegative() {
334348
if (!testPassed) {
335349
LoggingUtil.generateLog(this, ns);
336350
}
337-
deleteDomainResource(domainNamespace, domainName);
338-
deleteClusterCustomResource(clusterResName, domainNamespace);
351+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
352+
deleteDomainResource(domainNamespace, domainName);
353+
}
354+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
355+
deleteClusterCustomResource(clusterResName, domainNamespace);
356+
}
339357
}
340358
}
341359

@@ -371,8 +389,12 @@ void testImageDoesnotExist() {
371389
if (!testPassed) {
372390
LoggingUtil.generateLog(this, ns);
373391
}
374-
deleteDomainResource(domainNamespace, domainName);
375-
deleteClusterCustomResource(clusterResName, domainNamespace);
392+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
393+
deleteDomainResource(domainNamespace, domainName);
394+
}
395+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
396+
deleteClusterCustomResource(clusterResName, domainNamespace);
397+
}
376398
}
377399
}
378400

@@ -408,8 +430,12 @@ void testImagePullSecretDoesnotExist() {
408430
if (!testPassed) {
409431
LoggingUtil.generateLog(this, ns);
410432
}
411-
deleteDomainResource(domainNamespace, domainName);
412-
deleteClusterCustomResource(clusterResName, domainNamespace);
433+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
434+
deleteDomainResource(domainNamespace, domainName);
435+
}
436+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
437+
deleteClusterCustomResource(clusterResName, domainNamespace);
438+
}
413439
}
414440
}
415441

@@ -448,8 +474,12 @@ void testIncorrectImagePullSecret() {
448474
if (!testPassed) {
449475
LoggingUtil.generateLog(this, ns);
450476
}
451-
deleteDomainResource(domainNamespace, domainName);
452-
deleteClusterCustomResource(clusterResName, domainNamespace);
477+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
478+
deleteDomainResource(domainNamespace, domainName);
479+
}
480+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
481+
deleteClusterCustomResource(clusterResName, domainNamespace);
482+
}
453483
}
454484
}
455485

@@ -531,8 +561,12 @@ void testNonexistentPVC() {
531561
if (!testPassed) {
532562
LoggingUtil.generateLog(this, ns);
533563
}
534-
deleteClusterCustomResource(clusterResName, domainNamespace);
535-
deleteDomainResource(domainNamespace, domainName);
564+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
565+
deleteClusterCustomResource(clusterResName, domainNamespace);
566+
}
567+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
568+
deleteDomainResource(domainNamespace, domainName);
569+
}
536570
}
537571
}
538572

@@ -567,8 +601,12 @@ void testNonexistentAdminSecret() {
567601
if (!testPassed) {
568602
LoggingUtil.generateLog(this, ns);
569603
}
570-
deleteDomainResource(domainNamespace, domainName);
571-
deleteClusterCustomResource(clusterResName, domainNamespace);
604+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
605+
deleteDomainResource(domainNamespace, domainName);
606+
}
607+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
608+
deleteClusterCustomResource(clusterResName, domainNamespace);
609+
}
572610
}
573611
}
574612

@@ -611,8 +649,12 @@ void testInvalidNodePort() {
611649
if (!testPassed) {
612650
LoggingUtil.generateLog(this, ns);
613651
}
614-
deleteDomainResource(domainNamespace, domainName);
615-
deleteClusterCustomResource(clusterResName, domainNamespace);
652+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
653+
deleteDomainResource(domainNamespace, domainName);
654+
}
655+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
656+
deleteClusterCustomResource(clusterResName, domainNamespace);
657+
}
616658
}
617659
}
618660

@@ -650,8 +692,12 @@ void testIntrospectorTimeoutFailure() {
650692
if (!testPassed) {
651693
LoggingUtil.generateLog(this, ns);
652694
}
653-
deleteDomainResource(domainNamespace, domainName);
654-
deleteClusterCustomResource(clusterResName, domainNamespace);
695+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
696+
deleteDomainResource(domainNamespace, domainName);
697+
}
698+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
699+
deleteClusterCustomResource(clusterResName, domainNamespace);
700+
}
655701
}
656702
}
657703

@@ -671,15 +717,13 @@ void testMSBootFailureStatus() {
671717
String domainName = getDomainName();
672718
String clusterResName = getClusterResName(domainName);
673719
try {
674-
String fmwMiiImage = null;
675720
String rcuSchemaPrefix = "FMWDOMAINMII";
676721
String oracleDbUrlPrefix = "oracledb.";
677-
String oracleDbSuffix = null;
678722
String rcuSchemaPassword = "Oradoc_db1";
679723
String modelFile = "model-singleclusterdomain-sampleapp-jrf.yaml";
680724

681725
final int dbListenerPort = getNextFreePort();
682-
oracleDbSuffix = ".svc.cluster.local:" + dbListenerPort + "/devpdb.k8s";
726+
String oracleDbSuffix = ".svc.cluster.local:" + dbListenerPort + "/devpdb.k8s";
683727
String dbUrl = oracleDbUrlPrefix + domainNamespace + oracleDbSuffix;
684728

685729
String rcuaccessSecretName = domainName + "-rcu-access";
@@ -712,7 +756,7 @@ rcuSchemaPrefix, domainNamespace, getNextFreePort(), dbUrl, dbListenerPort),
712756

713757
logger.info("Create an image with jrf model file");
714758
final List<String> modelList = Collections.singletonList(MODEL_DIR + "/" + modelFile);
715-
fmwMiiImage = createMiiImageAndVerify(
759+
String fmwMiiImage = createMiiImageAndVerify(
716760
"jrf-mii-image-status",
717761
modelList,
718762
Collections.singletonList(MII_BASIC_APP_NAME),
@@ -800,8 +844,12 @@ rcuSchemaPrefix, domainNamespace, getNextFreePort(), dbUrl, dbListenerPort),
800844
if (!testPassed) {
801845
LoggingUtil.generateLog(this, ns);
802846
}
803-
deleteClusterCustomResource(clusterResName, domainNamespace);
804-
deleteDomainResource(domainNamespace, domainName);
847+
if (assertDoesNotThrow(() -> clusterExists(clusterResName, CLUSTER_VERSION, domainNamespace).call())) {
848+
deleteClusterCustomResource(clusterResName, domainNamespace);
849+
}
850+
if (assertDoesNotThrow(() -> domainExists(domainName, DOMAIN_VERSION, domainNamespace).call())) {
851+
deleteDomainResource(domainNamespace, domainName);
852+
}
805853
}
806854
}
807855

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.junit.jupiter.api.Test;
2020
import org.junit.jupiter.api.TestMethodOrder;
2121

22+
import static java.util.concurrent.TimeUnit.MILLISECONDS;
23+
import static java.util.concurrent.TimeUnit.SECONDS;
2224
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE;
2325
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE;
2426
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_STATUS_CONDITION_COMPLETED_TYPE;
@@ -33,14 +35,14 @@
3335
import static oracle.weblogic.kubernetes.utils.ClusterUtils.checkDomainStatusClusterConditionTypeHasExpectedStatus;
3436
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createMiiDomain;
3537
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
36-
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createRetryPolicy;
3738
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withQuickRetryPolicy;
3839
import static oracle.weblogic.kubernetes.utils.DomainUtils.checkDomainStatusConditionTypeHasExpectedStatus;
3940
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
4041
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDeleted;
4142
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDoesNotExist;
4243
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodReady;
4344
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
45+
import static org.awaitility.Awaitility.with;
4446
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4547
import static org.junit.jupiter.api.Assertions.assertNotNull;
4648
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -61,7 +63,9 @@ class ItRetryImprovementMisc {
6163
private static LoggingFacade logger = null;
6264
private static String clusterName = "cluster-1";
6365

64-
private ConditionFactory shortRetryPolicy = createRetryPolicy(0, 1, 30);
66+
private ConditionFactory shortRetryPolicy = with().pollDelay(0, SECONDS)
67+
.and().with().pollInterval(100, MILLISECONDS)
68+
.atMost(30, SECONDS).await();
6569

6670
/**
6771
* Perform initialization for all the tests in this class.

0 commit comments

Comments
 (0)