Skip to content

Commit 9972326

Browse files
authored
fix domain status msg failure (#4130)
1 parent 1a1442c commit 9972326

File tree

3 files changed

+71
-19
lines changed

3 files changed

+71
-19
lines changed

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -54,6 +54,7 @@
5454
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
5555
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.configMapExist;
5656
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapFromFiles;
57+
import static oracle.weblogic.kubernetes.utils.DomainUtils.checkDomainStatusMessageContainsExpectedMsg;
5758
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
5859
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainResourceForDomainInImage;
5960
import static oracle.weblogic.kubernetes.utils.DomainUtils.createMiiDomainResourceWithConfigMap;
@@ -357,14 +358,12 @@ void testRetryStoppedAfterfailureRetryLimitMinutesExpired() {
357358
DomainResource domain = createDomainResourceForRetryTest(failureRetryLimitMinutes, replicaCount,false);
358359
createDomainForRetryTest(domain);
359360

360-
String retryDoneMsgRegex = new StringBuffer(".*operator\\s*failed\\s*after\\s*retrying\\s*for\\s*")
361-
.append(failureRetryLimitMinutes.toString())
362-
.append("\\s*minutes.*Please\\s*resolve.*update\\s*domain.spec.introspectVersion\\s*")
363-
.append(".*to\\s*force\\s*another\\s*retry.*").toString();
364-
365-
// verify that the operator stops retry after failure retry limit minutes expired
366-
testUntil(() -> findStringInDomainStatusMessage(domainNamespace, domainUid, retryDoneMsgRegex),
367-
logger, "The operator stops retry after failure retry limit minutes expired");
361+
String retryDoneMsgRegex = "The operator failed after retrying for "
362+
+ failureRetryLimitMinutes
363+
+ " minutes. This time limit may be specified in spec.failureRetryLimitMinutes. "
364+
+ "Please resolve the error and then update domain.spec.introspectVersion to force another retry.";
365+
// verify that retryDoneMsgRegex message found in domain status message
366+
checkDomainStatusMessageContainsExpectedMsg(domainUid, domainNamespace, retryDoneMsgRegex);
368367
}
369368

370369
/**
@@ -382,23 +381,23 @@ void testRetryOccursAndErrorFromIntrospectorLoggedInOperator() throws Exception
382381
String badModelFileCm = "bad-model-in-cm";
383382
String badModelFileName = "bad-model-file.yaml";
384383
Path badModelFile = Paths.get(MODEL_DIR, badModelFileName);
384+
String domainUid = "retrydomain2";
385385

386386
logger.info("Creating a domain resource with bad model file from configmap");
387387
DomainResource domain =
388388
createDomainResourceForRetryTestWithConfigMap(failureRetryLimitMinutes,
389-
replicaCount, badModelFile, badModelFileCm);
389+
replicaCount, badModelFile, badModelFileCm, domainUid);
390390
createDomainAndVerify(domain, domainNamespace);
391391

392392
String createDomainFailedMsgRegex = new StringBuffer(".*SEVERE.*createDomain\\s*was\\s*unable\\s*to\\s*load.*")
393393
.append(badModelFileName).toString();
394-
String retryDoneMsgRegex = new StringBuffer(".*operator\\s*failed\\s*after\\s*retrying\\s*for\\s*")
395-
.append(failureRetryLimitMinutes.toString())
396-
.append("\\s*minutes.*Please\\s*resolve.*update\\s*domain.spec.introspectVersion\\s*")
397-
.append(".*to\\s*force\\s*another\\s*retry.*").toString();
398394

395+
String retryDoneMsgRegex = "The operator failed after retrying for "
396+
+ failureRetryLimitMinutes
397+
+ " minutes. This time limit may be specified in spec.failureRetryLimitMinutes. "
398+
+ "Please resolve the error and then update domain.spec.introspectVersion to force another retry.";
399399
// verify that retryDoneMsgRegex message found in domain status message
400-
testUntil(() -> findStringInDomainStatusMessage(domainNamespace, domainUid, retryDoneMsgRegex),
401-
logger, "{0} is found in domain status message", retryDoneMsgRegex);
400+
checkDomainStatusMessageContainsExpectedMsg(domainUid, domainNamespace, retryDoneMsgRegex);
402401

403402
// verify that SEVERE and createDomainFailedMsgRegex message found in Operator log
404403
testUntil(() -> checkPodLogContainsRegex(createDomainFailedMsgRegex, operatorPodName, opNamespace),
@@ -418,6 +417,10 @@ void testRetryOccursAndErrorFromIntrospectorLoggedInOperator() throws Exception
418417
if (configMapExist.call().booleanValue()) {
419418
deleteConfigMap(badModelFileCm, domainNamespace);
420419
}
420+
deleteClusterCustomResource(domainUid + "-" + clusterName, domainNamespace);
421+
if (domainExists(domainUid, DOMAIN_VERSION, domainNamespace).call().booleanValue()) {
422+
deleteDomainResource(domainNamespace, domainUid);
423+
}
421424
}
422425

423426
private void verifyDomainExistsAndServerStarted(int replicaCount) {
@@ -485,7 +488,8 @@ private static DomainResource createDomainResourceForRetryTest(Long failureRetry
485488
private static DomainResource createDomainResourceForRetryTestWithConfigMap(Long failureRetryLimitMinutes,
486489
int replicaCount,
487490
Path modelFile,
488-
String configmapName) {
491+
String configmapName,
492+
String domainUid) {
489493
final List<Path> modelList = Collections.singletonList(modelFile);
490494
String imageName = MII_BASIC_IMAGE_NAME;
491495
String imageTag = "empty-domain-image";

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.assertions;
@@ -622,6 +622,33 @@ public static Callable<Boolean> domainStatusReasonMatches(String domainUid, Stri
622622
};
623623
}
624624

625+
/**
626+
* Check the status message of the domain contains the expected message.
627+
* @param domainUid domain uid
628+
* @param namespace namespace in which the domain resource exists
629+
* @param statusMsg the expected status message of the domain
630+
* @return true if the status message contains the expected message, false otherwise
631+
*/
632+
public static Callable<Boolean> domainStatusMessageContainsExpectedMsg(String domainUid, String namespace,
633+
String statusMsg) {
634+
LoggingFacade logger = getLogger();
635+
return () -> {
636+
DomainResource domain = getDomainCustomResource(domainUid, namespace);
637+
if (domain != null && domain.getStatus() != null && domain.getStatus().getMessage() != null) {
638+
return domain.getStatus().getMessage().equalsIgnoreCase(statusMsg);
639+
} else {
640+
if (domain == null) {
641+
logger.info("domain is null");
642+
} else if (domain.getStatus() == null) {
643+
logger.info("domain status is null");
644+
} else if (domain.getStatus().getMessage() == null) {
645+
logger.info("domain status message is null");
646+
}
647+
return false;
648+
}
649+
};
650+
}
651+
625652
/**
626653
* Check the domain status condition type exists.
627654
* @param domainUid uid of the domain

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
106106
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainStatusConditionTypeExists;
107107
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainStatusConditionTypeHasExpectedStatus;
108+
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainStatusMessageContainsExpectedMsg;
108109
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainStatusReasonMatches;
109110
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainStatusServerStatusHasExpectedPodStatus;
110111
import static oracle.weblogic.kubernetes.assertions.TestAssertions.pvExists;
@@ -242,12 +243,32 @@ public static void checkDomainStatusReasonMatches(String domainUid, String names
242243
LoggingFacade logger = getLogger();
243244
testUntil(assertDoesNotThrow(() -> domainStatusReasonMatches(domainUid, namespace, statusReason)),
244245
logger,
245-
"the status reason of the domain {0} in namespace {1}",
246+
"the status reason of the domain {0} in namespace {1} matches {2}",
246247
domainUid,
247248
namespace,
248249
statusReason);
249250
}
250251

252+
/**
253+
* Check the status message of the domainUid contains the expected msg.
254+
*
255+
* @param domainUid domain uid
256+
* @param namespace the namespace in which the domainUid exists
257+
* @param statusMsg the expected status msg of the domainUid
258+
*/
259+
public static void checkDomainStatusMessageContainsExpectedMsg(String domainUid,
260+
String namespace,
261+
String statusMsg) {
262+
LoggingFacade logger = getLogger();
263+
testUntil(withLongRetryPolicy,
264+
assertDoesNotThrow(() -> domainStatusMessageContainsExpectedMsg(domainUid, namespace, statusMsg)),
265+
logger,
266+
"the status msg of the domain {0} in namespace {1} contains {2}",
267+
domainUid,
268+
namespace,
269+
statusMsg);
270+
}
271+
251272
/**
252273
* Check the domain status condition has expected status value.
253274
* @param domainUid Uid of the domain

0 commit comments

Comments
 (0)