Skip to content

Commit 73e4e14

Browse files
committed
add private method for operator upgrade domainNS
1 parent 620b618 commit 73e4e14

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITUsabilityOperatorHelmChart.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -599,29 +599,23 @@ public void testAddRemoveDomainUpdateOperatorHC() throws Exception {
599599
Map<String, Object> operatorMap = TestUtils.createOperatorMap(number, true);
600600
Operator operator = new Operator(operatorMap, RESTCertType.SELF_SIGNED);
601601
operator.callHelmInstall();
602-
Domain domain = null;
603-
Domain domainnew = null;
602+
Domain domain, domainnew = null;
604603
boolean testCompletedSuccessfully = false;
605604
try {
606605
logger.info("kubectl create namespace test" + (number + 1));
607606
ExecCommand.exec("kubectl create namespace test" + (number + 1));
608607
domain = createVerifyDomain(number, operator);
609-
logger.info("update operator with new target domain");
610-
operator.callHelmUpgrade("domainNamespaces={test" + number + ",test" + (number + 1) + "}");
611-
612608
ArrayList<String> targetDomainsNS =
613609
(ArrayList<String>) (operator.getOperatorMap().get("domainNamespaces"));
614610
targetDomainsNS.add("test" + (number + 1));
615-
operatorMap.replace("domainNamespaces", targetDomainsNS);
611+
upgradeVerifyOperatorDomainNamespaces(operator, targetDomainsNS);
616612
domainnew = createVerifyDomain(number + 1, operator);
617613
logger.info("verify that old domain is managed by operator after upgrade");
618614
operator.verifyDomainExists(domain.getDomainUid());
619615
logger.info("Upgrade to remove first domain");
620-
operator.callHelmUpgrade("domainNamespaces={test" + (number + 1) + "}");
621-
targetDomainsNS = (ArrayList<String>) (operator.getOperatorMap().get("domainNamespaces"));
622616
targetDomainsNS.remove("test" + (number));
623-
operatorMap.replace("domainNamespaces", targetDomainsNS);
624-
Thread.sleep(30 * 1000);
617+
upgradeVerifyOperatorDomainNamespaces(operator, targetDomainsNS);
618+
Thread.sleep(60 * 1000);
625619
logger.info("verify that old domain is not managed by operator");
626620
operator.verifyDomainExists(domain.getDomainUid());
627621
throw new RuntimeException(
@@ -658,10 +652,8 @@ public void testDeleteOperatorButNotDomain() throws Exception {
658652
Assume.assumeFalse(QUICKTEST);
659653
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
660654
logTestBegin(testMethodName);
661-
662655
logger.info("Creating Operator & waiting for the script to complete execution");
663656
// create operator
664-
665657
Operator operator = null;
666658
Domain domain = null;
667659
boolean testCompletedSuccessfully = false;
@@ -673,7 +665,7 @@ public void testDeleteOperatorButNotDomain() throws Exception {
673665
logger.info("Deleting operator to check that domain functionality is not effected");
674666
operator.destroy();
675667
operator = null;
676-
Thread.sleep(20 * 1000);
668+
Thread.sleep(60 * 1000);
677669
domain.testWlsLivenessProbe();
678670
testCompletedSuccessfully = true;
679671
} finally {
@@ -699,4 +691,19 @@ private Domain createVerifyDomain(int number, Operator operator) throws Exceptio
699691
operator.verifyDomainExists(domain.getDomainUid());
700692
return domain;
701693
}
694+
695+
private void upgradeVerifyOperatorDomainNamespaces(
696+
Operator operator, ArrayList<String> targetNamespaces) throws Exception {
697+
logger.info("update operator with new target domain");
698+
String upgradeSet =
699+
"domainNamespaces="
700+
+ targetNamespaces
701+
.toString()
702+
.replaceAll("\\[", "{")
703+
.replaceAll("\\]", "}")
704+
.replaceAll(" ", "");
705+
logger.info("update operator with new target domain " + upgradeSet);
706+
operator.callHelmUpgrade(upgradeSet);
707+
operator.getOperatorMap().replace("domainNamespaces", targetNamespaces);
708+
}
702709
}

0 commit comments

Comments
 (0)