|
6 | 6 |
|
7 | 7 | import java.util.ArrayList;
|
8 | 8 | import java.util.Map;
|
9 |
| -import oracle.kubernetes.operator.utils.ExecCommand; |
10 |
| -import oracle.kubernetes.operator.utils.ExecResult; |
11 |
| -import oracle.kubernetes.operator.utils.Operator; |
| 9 | +import oracle.kubernetes.operator.utils.*; |
12 | 10 | import oracle.kubernetes.operator.utils.Operator.RESTCertType;
|
13 |
| -import oracle.kubernetes.operator.utils.TestUtils; |
14 |
| -import org.junit.AfterClass; |
15 |
| -import org.junit.Assume; |
16 |
| -import org.junit.BeforeClass; |
17 |
| -import org.junit.FixMethodOrder; |
18 |
| -import org.junit.Test; |
| 11 | +import org.junit.*; |
19 | 12 | import org.junit.runners.MethodSorters;
|
20 | 13 |
|
21 | 14 | /**
|
@@ -596,4 +589,87 @@ public void testCreateWithDefaultTargetDomainInstall() throws Exception {
|
596 | 589 | }
|
597 | 590 | logger.info("SUCCESS - " + testMethodName);
|
598 | 591 | }
|
| 592 | + /** |
| 593 | + * Create operator and verify its deployed successfully. Create domain1 and verify domain is |
| 594 | + * started. Call helm upgrade to add domainnew to manage, verify both domains are managed by |
| 595 | + * operator Call helm upgrade to remove first domain from operator target domains, verify it can't |
| 596 | + * not be managed by operator anymore Delete operator and make sure domainnew is still functional |
| 597 | + * |
| 598 | + * @throws Exception |
| 599 | + */ |
| 600 | + @Test |
| 601 | + public void testAddRemoveDomainUpdateOperatorHC() throws Exception { |
| 602 | + Assume.assumeFalse(QUICKTEST); |
| 603 | + String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName(); |
| 604 | + logTestBegin(testMethodName); |
| 605 | + logger.info("Creating Operator & waiting for the script to complete execution"); |
| 606 | + // create operator |
| 607 | + Map<String, Object> operatorMap = TestUtils.createOperatorMap(number, true); |
| 608 | + Operator operator = new Operator(operatorMap, RESTCertType.SELF_SIGNED); |
| 609 | + operator.callHelmInstall(); |
| 610 | + Domain domain = null; |
| 611 | + Domain domainnew = null; |
| 612 | + boolean testCompletedSuccessfully = false; |
| 613 | + logger.info("kubectl create namespace test" + (number + 1)); |
| 614 | + ExecCommand.exec("kubectl create namespace test" + (number + 1)); |
| 615 | + logger.info("create domain with UID : test" + number); |
| 616 | + domain = TestUtils.createDomain(TestUtils.createDomainMap(number)); |
| 617 | + domain.verifyDomainCreated(); |
| 618 | + testAdminT3Channel(domain); |
| 619 | + TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId()); |
| 620 | + logger.info("verify that domain is managed by operator"); |
| 621 | + operator.verifyDomainExists(domain.getDomainUid()); |
| 622 | + logger.info("update operator with new target domain"); |
| 623 | + operator.callHelmUpgrade("domainNamespaces={test" + number + ",test" + (number + 1) + "}"); |
| 624 | + |
| 625 | + ArrayList<String> targetDomainsNS = |
| 626 | + (ArrayList<String>) (operator.getOperatorMap().get("domainNamespaces")); |
| 627 | + targetDomainsNS.add("test" + (number + 1)); |
| 628 | + operatorMap.replace("domainNamespaces", targetDomainsNS); |
| 629 | + domainnew = TestUtils.createDomain(TestUtils.createDomainMap(number + 1)); |
| 630 | + domainnew.verifyDomainCreated(); |
| 631 | + testAdminT3Channel(domainnew); |
| 632 | + TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId()); |
| 633 | + logger.info("verify that new domain is managed by operator after upgrade"); |
| 634 | + operator.verifyDomainExists(domainnew.getDomainUid()); |
| 635 | + logger.info("verify that old domain is managed by operator after upgrade"); |
| 636 | + operator.verifyDomainExists(domain.getDomainUid()); |
| 637 | + logger.info("Upgrade to remove first domain"); |
| 638 | + operator.callHelmUpgrade("domainNamespaces={test" + (number + 1) + "}"); |
| 639 | + targetDomainsNS = (ArrayList<String>) (operator.getOperatorMap().get("domainNamespaces")); |
| 640 | + targetDomainsNS.remove("test" + (number)); |
| 641 | + operatorMap.replace("domainNamespaces", targetDomainsNS); |
| 642 | + Thread.sleep(30 * 1000); |
| 643 | + try { |
| 644 | + logger.info("verify that old domain is not managed by operator"); |
| 645 | + operator.verifyDomainExists(domain.getDomainUid()); |
| 646 | + throw new RuntimeException( |
| 647 | + "FAILURE: After Helm Upgrade for the domainNamespaces operator still able to manage old namespace "); |
| 648 | + } catch (Exception ex) { |
| 649 | + if (!ex.getMessage() |
| 650 | + .contains( |
| 651 | + " Response {\"status\":404,\"detail\":\"/operator/latest/domains/test" |
| 652 | + + number |
| 653 | + + "\"")) |
| 654 | + throw new RuntimeException( |
| 655 | + "FAILURE: Exception does not report the expected error message " + ex.getMessage()); |
| 656 | + logger.info("Deleting operator to check that domain functionality is not effected"); |
| 657 | + operator.destroy(); |
| 658 | + operator = null; |
| 659 | + Thread.sleep(20 * 1000); |
| 660 | + domainnew.testWlsLivenessProbe(); |
| 661 | + testCompletedSuccessfully = true; |
| 662 | + } finally { |
| 663 | + if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully)) domain.destroy(); |
| 664 | + if (domainnew != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully)) |
| 665 | + domainnew.destroy(); |
| 666 | + |
| 667 | + if (operator != null) { |
| 668 | + operator.destroy(); |
| 669 | + } |
| 670 | + number++; |
| 671 | + } |
| 672 | + |
| 673 | + logger.info("SUCCESS - " + testMethodName); |
| 674 | + } |
599 | 675 | }
|
0 commit comments