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
44package oracle .weblogic .kubernetes ;
5454import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
5555import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .configMapExist ;
5656import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapFromFiles ;
57+ import static oracle .weblogic .kubernetes .utils .DomainUtils .checkDomainStatusMessageContainsExpectedMsg ;
5758import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
5859import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainResourceForDomainInImage ;
5960import 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" ;
0 commit comments