|
54 | 54 | import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_STATUS_CONDITION_COMPLETED_TYPE;
|
55 | 55 | import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_STATUS_CONDITION_FAILED_TYPE;
|
56 | 56 | import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
|
| 57 | +import static oracle.weblogic.kubernetes.TestConstants.ENCRYPION_PASSWORD_DEFAULT; |
| 58 | +import static oracle.weblogic.kubernetes.TestConstants.ENCRYPION_USERNAME_DEFAULT; |
57 | 59 | import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_NAME;
|
58 | 60 | import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TAG;
|
59 | 61 | import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TO_USE_IN_SPEC;
|
60 | 62 | import static oracle.weblogic.kubernetes.TestConstants.IMAGE_PULL_POLICY;
|
61 | 63 | import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
|
62 | 64 | import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
|
63 | 65 | import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
|
| 66 | +import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME; |
64 | 67 | import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
|
65 | 68 | import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
|
66 | 69 | import static oracle.weblogic.kubernetes.actions.TestActions.deleteClusterCustomResource;
|
|
78 | 81 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
|
79 | 82 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
|
80 | 83 | import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.configMapExist;
|
| 84 | +import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapAndVerify; |
81 | 85 | import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapFromFiles;
|
82 | 86 | import static oracle.weblogic.kubernetes.utils.DbUtils.createRcuAccessSecret;
|
83 | 87 | import static oracle.weblogic.kubernetes.utils.DbUtils.setupDBandRCUschema;
|
|
89 | 93 | import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
|
90 | 94 | import static oracle.weblogic.kubernetes.utils.ImageUtils.createImageRegistrySecret;
|
91 | 95 | import static oracle.weblogic.kubernetes.utils.ImageUtils.createMiiImageAndVerify;
|
| 96 | +import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret; |
92 | 97 | import static oracle.weblogic.kubernetes.utils.ImageUtils.imageRepoLoginAndPushImageToRegistry;
|
93 | 98 | import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
|
| 99 | +import static oracle.weblogic.kubernetes.utils.PatchDomainUtils.patchDomainResource; |
94 | 100 | import static oracle.weblogic.kubernetes.utils.PodUtils.setPodAntiAffinity;
|
95 | 101 | import static oracle.weblogic.kubernetes.utils.SecretUtils.createOpsswalletpasswordSecret;
|
96 | 102 | import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
|
@@ -853,6 +859,111 @@ rcuSchemaPrefix, domainNamespace, getNextFreePort(), dbUrl, dbListenerPort),
|
853 | 859 | }
|
854 | 860 | }
|
855 | 861 |
|
| 862 | + /** |
| 863 | + * Test domain status condition with a bad model file. |
| 864 | + * Verify the following conditions are generated in an order after an introspector failure. |
| 865 | + * type: Failed, status: true |
| 866 | + * type: Available, status: false |
| 867 | + * type: Completed, status: false |
| 868 | + * Verify the introspector reruns to make it right when model file is fixed. |
| 869 | + */ |
| 870 | + @Test |
| 871 | + @DisplayName("Test domain status condition with bad model file") |
| 872 | + void testIntrospectorMakerightAvailableFromFailure() { |
| 873 | + // Create the repo secret to pull the image |
| 874 | + // this secret is used only for non-kind cluster |
| 875 | + createTestRepoSecret(domainNamespace); |
| 876 | + |
| 877 | + // create secret for admin credentials |
| 878 | + logger.info("Create secret for admin credentials"); |
| 879 | + assertDoesNotThrow(() -> createSecretWithUsernamePassword( |
| 880 | + adminSecretName, |
| 881 | + domainNamespace, |
| 882 | + ADMIN_USERNAME_DEFAULT, |
| 883 | + ADMIN_PASSWORD_DEFAULT), |
| 884 | + String.format("createSecret failed for %s", adminSecretName)); |
| 885 | + |
| 886 | + // create encryption secret |
| 887 | + logger.info("Create encryption secret"); |
| 888 | + assertDoesNotThrow(() -> createSecretWithUsernamePassword( |
| 889 | + encryptionSecretName, |
| 890 | + domainNamespace, |
| 891 | + ENCRYPION_USERNAME_DEFAULT, |
| 892 | + ENCRYPION_PASSWORD_DEFAULT), |
| 893 | + String.format("createSecret failed for %s", encryptionSecretName)); |
| 894 | + |
| 895 | + // create WDT config map without any files |
| 896 | + createConfigMapAndVerify("empty-cm", domainUid, domainNamespace, Collections.emptyList()); |
| 897 | + String image = MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG; |
| 898 | + |
| 899 | + // create the domain object |
| 900 | + DomainResource domain = createDomainResourceWithConfigMap(domainUid, |
| 901 | + domainNamespace, |
| 902 | + adminSecretName, |
| 903 | + TEST_IMAGES_REPO_SECRET_NAME, |
| 904 | + encryptionSecretName, |
| 905 | + 2, |
| 906 | + image, |
| 907 | + "empty-cm", |
| 908 | + 180L, |
| 909 | + "mymii-cluster-resource"); |
| 910 | + |
| 911 | + logger.info("Creating a domain resource with model file image"); |
| 912 | + createDomainAndVerify(domain, domainNamespace); |
| 913 | + checkDomainStatusConditionTypeHasExpectedStatus(domainUid, domainNamespace, |
| 914 | + DOMAIN_STATUS_CONDITION_COMPLETED_TYPE, "True"); |
| 915 | + |
| 916 | + //patch the domain with bad image |
| 917 | + //check the desired completed, available and failed status |
| 918 | + //verify the condition type Failed exists |
| 919 | + StringBuffer patchStr = new StringBuffer("[{"); |
| 920 | + patchStr.append("\"op\": \"replace\",") |
| 921 | + .append(" \"path\": \"/spec/image\",") |
| 922 | + .append("\"value\": \"") |
| 923 | + .append("bad-mii-image:doesntexist") |
| 924 | + .append("\"}]"); |
| 925 | + logger.info("PatchStr for imageUpdate: {0}", patchStr.toString()); |
| 926 | + |
| 927 | + assertTrue(patchDomainResource(domainUid, domainNamespace, patchStr), |
| 928 | + "patchDomainCustomResource(imageUpdate) failed"); |
| 929 | + checkDomainStatusConditionTypeHasExpectedStatus(domainUid, domainNamespace, |
| 930 | + DOMAIN_STATUS_CONDITION_FAILED_TYPE, "True"); |
| 931 | + |
| 932 | + //fix the domain failure by patching the domain resource with good image |
| 933 | + patchStr = new StringBuffer("[" |
| 934 | + + "{"); |
| 935 | + patchStr.append("\"op\": \"replace\",") |
| 936 | + .append(" \"path\": \"/spec/image\",") |
| 937 | + .append("\"value\": \"") |
| 938 | + .append(MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG) |
| 939 | + .append("\"},") |
| 940 | + .append("{\"op\": \"add\",") |
| 941 | + .append(" \"path\": \"/spec/restartVersion\",").append("\"value\": ").append("\"1\"") |
| 942 | + .append("}" |
| 943 | + + "]"); |
| 944 | + logger.info("PatchStr for imageUpdate: {0}", patchStr.toString()); |
| 945 | + |
| 946 | + assertTrue(patchDomainResource(domainUid, domainNamespace, patchStr), |
| 947 | + "patchDomainCustomResource(imageUpdate) failed"); |
| 948 | + |
| 949 | + final String adminServerPodName = domainUid + "-admin-server"; |
| 950 | + final String managedServerPrefix = domainUid + "-managed-server"; |
| 951 | + |
| 952 | + // check admin server pod is ready |
| 953 | + logger.info("Wait for admin server pod {0} to be ready in namespace {1}", |
| 954 | + adminServerPodName, domainNamespace); |
| 955 | + checkPodReadyAndServiceExists(adminServerPodName, domainUid, domainNamespace); |
| 956 | + // check managed server pods are ready |
| 957 | + for (int i = 1; i <= 2; i++) { |
| 958 | + logger.info("Wait for managed server pod {0} to be ready in namespace {1}", |
| 959 | + managedServerPrefix + i, domainNamespace); |
| 960 | + checkPodReadyAndServiceExists(managedServerPrefix + i, domainUid, domainNamespace); |
| 961 | + } |
| 962 | + checkDomainStatusConditionTypeHasExpectedStatus(domainUid, domainNamespace, |
| 963 | + DOMAIN_STATUS_CONDITION_COMPLETED_TYPE, "True"); |
| 964 | + checkDomainStatusConditionTypeExists(domainUid, domainNamespace, DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE); |
| 965 | + } |
| 966 | + |
856 | 967 | // Create a domain resource with a custom ConfigMap
|
857 | 968 | private DomainResource createDomainResourceWithConfigMap(String domainUid,
|
858 | 969 | String domNamespace, String adminSecretName,
|
|
0 commit comments