1
- // Copyright (c) 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2022, 2023, Oracle and/or its affiliates.
2
2
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
3
4
4
package oracle .weblogic .kubernetes ;
54
54
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
55
55
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .configMapExist ;
56
56
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapFromFiles ;
57
+ import static oracle .weblogic .kubernetes .utils .DomainUtils .checkDomainStatusMessageContainsExpectedMsg ;
57
58
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
58
59
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainResourceForDomainInImage ;
59
60
import static oracle .weblogic .kubernetes .utils .DomainUtils .createMiiDomainResourceWithConfigMap ;
@@ -357,14 +358,12 @@ void testRetryStoppedAfterfailureRetryLimitMinutesExpired() {
357
358
DomainResource domain = createDomainResourceForRetryTest (failureRetryLimitMinutes , replicaCount ,false );
358
359
createDomainForRetryTest (domain );
359
360
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 );
368
367
}
369
368
370
369
/**
@@ -382,23 +381,23 @@ void testRetryOccursAndErrorFromIntrospectorLoggedInOperator() throws Exception
382
381
String badModelFileCm = "bad-model-in-cm" ;
383
382
String badModelFileName = "bad-model-file.yaml" ;
384
383
Path badModelFile = Paths .get (MODEL_DIR , badModelFileName );
384
+ String domainUid = "retrydomain2" ;
385
385
386
386
logger .info ("Creating a domain resource with bad model file from configmap" );
387
387
DomainResource domain =
388
388
createDomainResourceForRetryTestWithConfigMap (failureRetryLimitMinutes ,
389
- replicaCount , badModelFile , badModelFileCm );
389
+ replicaCount , badModelFile , badModelFileCm , domainUid );
390
390
createDomainAndVerify (domain , domainNamespace );
391
391
392
392
String createDomainFailedMsgRegex = new StringBuffer (".*SEVERE.*createDomain\\ s*was\\ s*unable\\ s*to\\ s*load.*" )
393
393
.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 ();
398
394
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." ;
399
399
// 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 );
402
401
403
402
// verify that SEVERE and createDomainFailedMsgRegex message found in Operator log
404
403
testUntil (() -> checkPodLogContainsRegex (createDomainFailedMsgRegex , operatorPodName , opNamespace ),
@@ -418,6 +417,10 @@ void testRetryOccursAndErrorFromIntrospectorLoggedInOperator() throws Exception
418
417
if (configMapExist .call ().booleanValue ()) {
419
418
deleteConfigMap (badModelFileCm , domainNamespace );
420
419
}
420
+ deleteClusterCustomResource (domainUid + "-" + clusterName , domainNamespace );
421
+ if (domainExists (domainUid , DOMAIN_VERSION , domainNamespace ).call ().booleanValue ()) {
422
+ deleteDomainResource (domainNamespace , domainUid );
423
+ }
421
424
}
422
425
423
426
private void verifyDomainExistsAndServerStarted (int replicaCount ) {
@@ -485,7 +488,8 @@ private static DomainResource createDomainResourceForRetryTest(Long failureRetry
485
488
private static DomainResource createDomainResourceForRetryTestWithConfigMap (Long failureRetryLimitMinutes ,
486
489
int replicaCount ,
487
490
Path modelFile ,
488
- String configmapName ) {
491
+ String configmapName ,
492
+ String domainUid ) {
489
493
final List <Path > modelList = Collections .singletonList (modelFile );
490
494
String imageName = MII_BASIC_IMAGE_NAME ;
491
495
String imageTag = "empty-domain-image" ;
0 commit comments