Skip to content

Commit 620b618

Browse files
committed
add private method for domain create/verify
1 parent 366147f commit 620b618

File tree

2 files changed

+33
-52
lines changed

2 files changed

+33
-52
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -489,20 +489,6 @@ public static ExecResult cleanup() throws Exception {
489489
return ExecCommand.exec(cmd);
490490
}
491491

492-
public static ExecResult cleanupDomainResources(String domainUid) throws Exception {
493-
String cmd =
494-
"export RESULT_ROOT="
495-
+ getResultRoot()
496-
+ " export PV_ROOT="
497-
+ getPvRoot()
498-
+ " && "
499-
+ getProjectRoot()
500-
+ "/kubernetes/samples/scripts/delete-domain/delete-weblogic-domain-resources.sh -d "
501-
+ domainUid;
502-
logger.info("Command to call cleanup domain resources script " + cmd);
503-
return ExecCommand.exec(cmd);
504-
}
505-
506492
protected void logTestBegin(String testName) throws Exception {
507493
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
508494
logger.info("BEGIN " + testName);

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

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -602,37 +602,26 @@ public void testAddRemoveDomainUpdateOperatorHC() throws Exception {
602602
Domain domain = null;
603603
Domain domainnew = null;
604604
boolean testCompletedSuccessfully = false;
605-
logger.info("kubectl create namespace test" + (number + 1));
606-
ExecCommand.exec("kubectl create namespace test" + (number + 1));
607-
logger.info("create domain with UID : test" + number);
608-
domain = TestUtils.createDomain(TestUtils.createDomainMap(number));
609-
domain.verifyDomainCreated();
610-
testAdminT3Channel(domain);
611-
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
612-
logger.info("verify that domain is managed by operator");
613-
operator.verifyDomainExists(domain.getDomainUid());
614-
logger.info("update operator with new target domain");
615-
operator.callHelmUpgrade("domainNamespaces={test" + number + ",test" + (number + 1) + "}");
616-
617-
ArrayList<String> targetDomainsNS =
618-
(ArrayList<String>) (operator.getOperatorMap().get("domainNamespaces"));
619-
targetDomainsNS.add("test" + (number + 1));
620-
operatorMap.replace("domainNamespaces", targetDomainsNS);
621-
domainnew = TestUtils.createDomain(TestUtils.createDomainMap(number + 1));
622-
domainnew.verifyDomainCreated();
623-
testAdminT3Channel(domainnew);
624-
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
625-
logger.info("verify that new domain is managed by operator after upgrade");
626-
operator.verifyDomainExists(domainnew.getDomainUid());
627-
logger.info("verify that old domain is managed by operator after upgrade");
628-
operator.verifyDomainExists(domain.getDomainUid());
629-
logger.info("Upgrade to remove first domain");
630-
operator.callHelmUpgrade("domainNamespaces={test" + (number + 1) + "}");
631-
targetDomainsNS = (ArrayList<String>) (operator.getOperatorMap().get("domainNamespaces"));
632-
targetDomainsNS.remove("test" + (number));
633-
operatorMap.replace("domainNamespaces", targetDomainsNS);
634-
Thread.sleep(30 * 1000);
635605
try {
606+
logger.info("kubectl create namespace test" + (number + 1));
607+
ExecCommand.exec("kubectl create namespace test" + (number + 1));
608+
domain = createVerifyDomain(number, operator);
609+
logger.info("update operator with new target domain");
610+
operator.callHelmUpgrade("domainNamespaces={test" + number + ",test" + (number + 1) + "}");
611+
612+
ArrayList<String> targetDomainsNS =
613+
(ArrayList<String>) (operator.getOperatorMap().get("domainNamespaces"));
614+
targetDomainsNS.add("test" + (number + 1));
615+
operatorMap.replace("domainNamespaces", targetDomainsNS);
616+
domainnew = createVerifyDomain(number + 1, operator);
617+
logger.info("verify that old domain is managed by operator after upgrade");
618+
operator.verifyDomainExists(domain.getDomainUid());
619+
logger.info("Upgrade to remove first domain");
620+
operator.callHelmUpgrade("domainNamespaces={test" + (number + 1) + "}");
621+
targetDomainsNS = (ArrayList<String>) (operator.getOperatorMap().get("domainNamespaces"));
622+
targetDomainsNS.remove("test" + (number));
623+
operatorMap.replace("domainNamespaces", targetDomainsNS);
624+
Thread.sleep(30 * 1000);
636625
logger.info("verify that old domain is not managed by operator");
637626
operator.verifyDomainExists(domain.getDomainUid());
638627
throw new RuntimeException(
@@ -646,7 +635,7 @@ public void testAddRemoveDomainUpdateOperatorHC() throws Exception {
646635
testCompletedSuccessfully = true;
647636
} finally {
648637
if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully))
649-
cleanupDomainResources(domain.getDomainUid());
638+
TestUtils.deleteWeblogicDomainResources(domain.getDomainUid());
650639
if (domainnew != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully))
651640
domainnew.destroy();
652641

@@ -680,12 +669,7 @@ public void testDeleteOperatorButNotDomain() throws Exception {
680669
Map<String, Object> operatorMap = TestUtils.createOperatorMap(number, true);
681670
operator = new Operator(operatorMap, RESTCertType.SELF_SIGNED);
682671
operator.callHelmInstall();
683-
domain = TestUtils.createDomain(TestUtils.createDomainMap(number));
684-
domain.verifyDomainCreated();
685-
testAdminT3Channel(domain);
686-
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
687-
logger.info("verify that domain is managed by operator");
688-
operator.verifyDomainExists(domain.getDomainUid());
672+
domain = createVerifyDomain(number, operator);
689673
logger.info("Deleting operator to check that domain functionality is not effected");
690674
operator.destroy();
691675
operator = null;
@@ -694,7 +678,7 @@ public void testDeleteOperatorButNotDomain() throws Exception {
694678
testCompletedSuccessfully = true;
695679
} finally {
696680
if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully))
697-
cleanupDomainResources(domain.getDomainUid());
681+
TestUtils.deleteWeblogicDomainResources(domain.getDomainUid());
698682

699683
if (operator != null) {
700684
operator.destroy();
@@ -704,4 +688,15 @@ public void testDeleteOperatorButNotDomain() throws Exception {
704688

705689
logger.info("SUCCESS - " + testMethodName);
706690
}
691+
692+
private Domain createVerifyDomain(int number, Operator operator) throws Exception {
693+
logger.info("create domain with UID : test" + number);
694+
Domain domain = TestUtils.createDomain(TestUtils.createDomainMap(number));
695+
domain.verifyDomainCreated();
696+
testAdminT3Channel(domain);
697+
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
698+
logger.info("verify that domain is managed by operator");
699+
operator.verifyDomainExists(domain.getDomainUid());
700+
return domain;
701+
}
707702
}

0 commit comments

Comments
 (0)