|
70 | 70 | import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify; |
71 | 71 | import static oracle.weblogic.kubernetes.utils.DomainUtils.deleteDomainResource; |
72 | 72 | import static oracle.weblogic.kubernetes.utils.FmwUtils.createDomainResourceSimplifyJrfPv; |
73 | | -import static oracle.weblogic.kubernetes.utils.FmwUtils.createSimplifyJrfPvDomainAndRCU; |
74 | 73 | import static oracle.weblogic.kubernetes.utils.FmwUtils.saveAndRestoreOpssWalletfileSecret; |
75 | 74 | import static oracle.weblogic.kubernetes.utils.FmwUtils.verifyDomainReady; |
76 | 75 | import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret; |
77 | 76 | import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret; |
78 | 77 | import static oracle.weblogic.kubernetes.utils.JobUtils.getIntrospectJobName; |
79 | 78 | import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD; |
80 | 79 | import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator; |
| 80 | +import static oracle.weblogic.kubernetes.utils.PatchDomainUtils.patchDomainResourceServerStartPolicy; |
| 81 | +import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDeleted; |
81 | 82 | import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDoesNotExist; |
82 | 83 | import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodExists; |
83 | 84 | import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodLogContains; |
@@ -588,34 +589,18 @@ void testFmwDomainOnPvUserCreatesRCUMultiImages() { |
588 | 589 | /** |
589 | 590 | * Export the OPSS wallet file secret of Fmw domain from the previous run |
590 | 591 | * CrateIfNotExists set to DomainAndRCU |
591 | | - * Use this OPSS wallet file secret to create Fmw domain on PV to connect to the same database |
| 592 | + * Use this OPSS wallet file secret to restart Fmw domain on PV to connect to the same database |
592 | 593 | * Verify Pod is ready and service exists for both admin server and managed servers. |
593 | 594 | */ |
594 | 595 | @Test |
595 | 596 | @Order(6) |
596 | | - @DisplayName("Create a FMW domain on PV with provided OPSS wallet file secret") |
597 | | - void testFmwDomainOnPVwithProvidedOpss() { |
598 | | - |
599 | | - final String pvName = getUniqueName(domainUid3 + "-pv-"); |
600 | | - final String pvcName = getUniqueName(domainUid3 + "-pvc-"); |
| 597 | + @DisplayName("Restart a FMW domain on PV with provided OPSS wallet file secret") |
| 598 | + void testReuseRCUschemaToRestartFmwDomain() { |
601 | 599 |
|
602 | 600 | saveAndRestoreOpssWalletfileSecret(domainNamespace, domainUid3, opsswalletfileSecretName3); |
603 | | - logger.info("Deleting domain custom resource with namespace: {0}, domainUid {1}", domainNamespace, domainUid3); |
604 | | - deleteDomainResource(domainNamespace, domainUid3); |
605 | | - try { |
606 | | - deleteDirectory(Paths.get("/shared").toFile()); |
607 | | - } catch (IOException ioe) { |
608 | | - logger.severe("Failed to cleanup directory /shared", ioe); |
609 | | - } |
610 | | - logger.info("Creating domain custom resource with pvName: {0}", pvName); |
611 | | - DomainResource domain = createSimplifyJrfPvDomainAndRCU( |
612 | | - domainUid3, domainNamespace, adminSecretName3, |
613 | | - TEST_IMAGES_REPO_SECRET_NAME, |
614 | | - rcuaccessSecretName3, |
615 | | - opsswalletpassSecretName3, opsswalletfileSecretName3, |
616 | | - pvName, pvcName, domainCreationImages3, null); |
617 | | - |
618 | | - createDomainAndVerify(domain, domainNamespace); |
| 601 | + shutdownDomain(domainUid3); |
| 602 | + patchDomainWithWalletFileSecret(opsswalletfileSecretName3, domainUid3); |
| 603 | + startupDomain(domainUid3); |
619 | 604 |
|
620 | 605 | // verify that all servers are ready |
621 | 606 | verifyDomainReady(domainNamespace, domainUid3, replicaCount, "nosuffix"); |
@@ -885,5 +870,55 @@ private static void createModelConfigMap(String domainid, String cfgMapName) { |
885 | 870 | assertTrue(cmCreated, String.format("createConfigMap failed %s", cfgMapName)); |
886 | 871 | } |
887 | 872 |
|
888 | | - |
| 873 | + /** |
| 874 | + * Shutdown the domain by setting serverStartPolicy as "Never". |
| 875 | + */ |
| 876 | + private void shutdownDomain(String domainUid) { |
| 877 | + patchDomainResourceServerStartPolicy("/spec/serverStartPolicy", "Never", domainNamespace, domainUid); |
| 878 | + logger.info("Domain is patched to stop entire WebLogic domain"); |
| 879 | + |
| 880 | + String adminServerPodName = domainUid + "-admin-server"; |
| 881 | + String managedServerPrefix = domainUid + "-managed-server"; |
| 882 | + |
| 883 | + // make sure all the server pods are removed after patch |
| 884 | + checkPodDeleted(adminServerPodName, domainUid, domainNamespace); |
| 885 | + for (int i = 1; i <= replicaCount; i++) { |
| 886 | + checkPodDeleted(managedServerPrefix + i, domainUid, domainNamespace); |
| 887 | + } |
| 888 | + |
| 889 | + logger.info("Domain shutdown success"); |
| 890 | + |
| 891 | + } |
| 892 | + |
| 893 | + /** |
| 894 | + * Startup the domain by setting serverStartPolicy as "IfNeeded". |
| 895 | + */ |
| 896 | + private void startupDomain(String domainUid) { |
| 897 | + patchDomainResourceServerStartPolicy("/spec/serverStartPolicy", "IfNeeded", domainNamespace, |
| 898 | + domainUid); |
| 899 | + logger.info("Domain is patched to start all servers in the domain"); |
| 900 | + } |
| 901 | + |
| 902 | + /** |
| 903 | + * Patch the domain with opss wallet file secret. |
| 904 | + * @param opssWalletFileSecretName the name of opps wallet file secret |
| 905 | + * @return true if patching succeeds, false otherwise |
| 906 | + */ |
| 907 | + private boolean patchDomainWithWalletFileSecret(String opssWalletFileSecretName, String domainUid) { |
| 908 | + // construct the patch string for adding server pod resources |
| 909 | + StringBuffer patchStr = new StringBuffer("[{") |
| 910 | + .append("\"op\": \"add\", ") |
| 911 | + .append("\"path\": \"/spec/configuration/opss/walletFileSecret\", ") |
| 912 | + .append("\"value\": \"") |
| 913 | + .append(opssWalletFileSecretName) |
| 914 | + .append("\"}]"); |
| 915 | + |
| 916 | + logger.info("Adding opssWalletPasswordSecretName for domain {0} in namespace {1} using patch string: {2}", |
| 917 | + domainUid, domainNamespace, patchStr.toString()); |
| 918 | + |
| 919 | + V1Patch patch = new V1Patch(new String(patchStr)); |
| 920 | + |
| 921 | + return patchDomainCustomResource(domainUid, domainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH); |
| 922 | + } |
| 923 | + |
889 | 924 | } |
0 commit comments