From 13c40f821fdd631af2b89405f717b8fd0694a17d Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Wed, 21 Jul 2021 19:28:31 +0000 Subject: [PATCH 1/9] added test for WDT update --- .../kubernetes/ItMiiAuxiliaryImage.java | 162 +++++++++++++++++- .../actions/impl/primitive/Installer.java | 18 +- .../weblogic/kubernetes/utils/FileUtils.java | 13 +- 3 files changed, 187 insertions(+), 6 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java index 938b5ac9fb1..a180230168a 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java @@ -104,11 +104,15 @@ public class ItMiiAuxiliaryImage { private static String opNamespace = null; private static String domainNamespace = null; private static String errorpathDomainNamespace = null; + private static String wdtDomainNamespace = null; private static LoggingFacade logger = null; private String domainUid = "domain1"; private static String miiAuxiliaryImage1 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "1"; private static String miiAuxiliaryImage2 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "2"; private static String miiAuxiliaryImage3 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "3"; + private static String miiAuxiliaryImage4 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "4"; + private static String miiAuxiliaryImage5 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "5"; + private static String miiAuxiliaryImage6 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "6"; private static Map podsWithTimeStamps = null; private final String adminServerPodName = domainUid + "-admin-server"; private final String managedServerPrefix = domainUid + "-managed-server"; @@ -127,7 +131,7 @@ public class ItMiiAuxiliaryImage { * JUnit engine parameter resolution mechanism */ @BeforeAll - public static void initAll(@Namespaces(3) List namespaces) { + public static void initAll(@Namespaces(4) List namespaces) { logger = getLogger(); // get a new unique opNamespace logger.info("Creating unique namespace for Operator"); @@ -142,8 +146,12 @@ public static void initAll(@Namespaces(3) List namespaces) { assertNotNull(namespaces.get(2), "Namespace list is null"); errorpathDomainNamespace = namespaces.get(2); + logger.info("Creating unique namespace for wdtDomainNamespace"); + assertNotNull(namespaces.get(3), "Namespace list is null"); + wdtDomainNamespace = namespaces.get(3); + // install and verify operator - installAndVerifyOperator(opNamespace, domainNamespace, errorpathDomainNamespace); + installAndVerifyOperator(opNamespace, domainNamespace, errorpathDomainNamespace,wdtDomainNamespace); } @@ -838,6 +846,156 @@ public void testErrorPathFilePermission() { deleteDomainResource(errorpathDomainNamespace, domainUid); } + /** + * Create a domain using multiple auxiliary images. + * One auxiliary image (image1) contains the domain configuration and + * another auxiliary image (image2) with WDT only, + * update WDT version by patching with another auxiliary image (image3) + * and verify the domain is running. + */ + @Test + @Order(8) + @DisplayName("Test to update WDT version using auxiliary images") + public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { + + // admin/managed server name here should match with model yaml + final String auxiliaryImageVolumeName = "auxiliaryImageVolume1"; + final String auxiliaryImagePath = "/auxiliary"; + + // Create the repo secret to pull the image + // this secret is used only for non-kind cluster + createOcirRepoSecret(wdtDomainNamespace); + + // create secret for admin credentials + logger.info("Create secret for admin credentials"); + String adminSecretName = "weblogic-credentials"; + createSecretWithUsernamePassword(adminSecretName, wdtDomainNamespace, + ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT); + + // create encryption secret + logger.info("Create encryption secret"); + String encryptionSecretName = "encryptionsecret"; + createSecretWithUsernamePassword(encryptionSecretName, wdtDomainNamespace, + "weblogicenc", "weblogicenc"); + + // create stage dir for first auxiliary image containing domain configuration + Path multipleAIPath1 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage1"); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath1.toFile())); + assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath1)); + + // create models dir and copy model, archive files if any for image1 + Path modelsPath1 = Paths.get(multipleAIPath1.toString(), "models"); + assertDoesNotThrow(() -> Files.createDirectories(modelsPath1)); + assertDoesNotThrow(() -> Files.copy( + Paths.get(MODEL_DIR, MII_BASIC_WDT_MODEL_FILE), + Paths.get(modelsPath1.toString(), MII_BASIC_WDT_MODEL_FILE), + StandardCopyOption.REPLACE_EXISTING)); + assertDoesNotThrow(() -> Files.copy( + Paths.get(MODEL_DIR, "multi-model-one-ds.20.yaml"), + Paths.get(modelsPath1.toString(), "multi-model-one-ds.20.yaml"), + StandardCopyOption.REPLACE_EXISTING)); + + // build app + assertTrue(buildAppArchive(defaultAppParams() + .srcDirList(Collections.singletonList(MII_BASIC_APP_NAME)) + .appName(MII_BASIC_APP_NAME)), + String.format("Failed to create app archive for %s", MII_BASIC_APP_NAME)); + + // copy app archive to models + assertDoesNotThrow(() -> Files.copy( + Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), + Paths.get(modelsPath1.toString(), MII_BASIC_APP_NAME + ".zip"), + StandardCopyOption.REPLACE_EXISTING)); + + // create image1 with domain configuration only + createAuxiliaryImage(multipleAIPath1.toString(), + Paths.get(RESOURCE_DIR, "auxiliaryimage", "Dockerfile").toString(), miiAuxiliaryImage4); + + // push image1 to repo for multi node cluster + if (!DOMAIN_IMAGES_REPO.isEmpty()) { + logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage4, DOMAIN_IMAGES_REPO); + assertTrue(dockerPush(miiAuxiliaryImage4), String.format("docker push failed for image %s", miiAuxiliaryImage4)); + } + + // create stage dir for second auxiliary image + Path multipleAIPath2 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage2"); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath2.toFile())); + assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath2)); + + Path modelsPath2 = Paths.get(multipleAIPath2.toString(), "models"); + assertDoesNotThrow(() -> Files.createDirectories(modelsPath2)); + + // unzip 1.9.15 version WDT installation file into work dir + String wdtURL = "https://github.com/oracle/weblogic-deploy-tooling/releases/release-1.9.15"; + unzipWDTInstallationFile(multipleAIPath2.toString(), wdtURL); + + // create image2 with wdt installation files only + createAuxiliaryImage(multipleAIPath2.toString(), + Paths.get(RESOURCE_DIR, "auxiliaryimage", "Dockerfile").toString(), miiAuxiliaryImage5); + + // push image2 to repo for multi node cluster + if (!DOMAIN_IMAGES_REPO.isEmpty()) { + logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage5, DOMAIN_IMAGES_REPO); + assertTrue(dockerPush(miiAuxiliaryImage5), String.format("docker push failed for image %s", miiAuxiliaryImage5)); + } + + // create stage dir for third auxiliary image with latest wdt installation files only + Path multipleAIPath3 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage3"); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath3.toFile())); + assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath3)); + + Path modelsPath3 = Paths.get(multipleAIPath3.toString(), "models"); + assertDoesNotThrow(() -> Files.createDirectories(modelsPath3)); + + // unzip WDT installation file into work dir + unzipWDTInstallationFile(multipleAIPath3.toString()); + + // create image3 with newest version of wdt installation files + createAuxiliaryImage(multipleAIPath3.toString(), + Paths.get(RESOURCE_DIR, "auxiliaryimage", "Dockerfile").toString(), miiAuxiliaryImage6); + + // push image3 to repo for multi node cluster + if (!DOMAIN_IMAGES_REPO.isEmpty()) { + logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage6, DOMAIN_IMAGES_REPO); + assertTrue(dockerPush(miiAuxiliaryImage6), String.format("docker push failed for image %s", miiAuxiliaryImage6)); + } + + // create domain custom resource using 2 auxiliary images ( image1, image2) + logger.info("Creating domain custom resource with domainUid {0} and auxiliary images {1} {2}", + domainUid, miiAuxiliaryImage4, miiAuxiliaryImage5); + Domain domainCR = createDomainResource(domainUid, wdtDomainNamespace, + WEBLOGIC_IMAGE_NAME + ":" + WEBLOGIC_IMAGE_TAG, adminSecretName, OCIR_SECRET_NAME, + encryptionSecretName, replicaCount, "cluster-1", auxiliaryImagePath, + auxiliaryImageVolumeName, miiAuxiliaryImage4, miiAuxiliaryImage5); + + // create domain and verify its running + logger.info("Creating domain {0} with auxiliary images {1} {2} in namespace {3}", + domainUid, miiAuxiliaryImage4, miiAuxiliaryImage5, wdtDomainNamespace); + createDomainAndVerify(domainUid, domainCR, wdtDomainNamespace, + adminServerPodName, managedServerPrefix, replicaCount); + + // check configuration for DataSource in the running domain + int adminServiceNodePort + = getServiceNodePort(wdtDomainNamespace, getExternalServicePodName(adminServerPodName), "default"); + assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); + assertTrue(checkSystemResourceConfig(adminServiceNodePort, + "JDBCSystemResources/TestDataSource/JDBCResource/JDBCDriverParams", + "jdbc:oracle:thin:@\\/\\/xxx.xxx.x.xxx:1521\\/ORCLCDB"),"Can't find expected URL configuration for DataSource"); + + logger.info("Found the DataResource configuration"); + + //updating wdt to latest version by patching the domain with image3 + patchDomainWithAuxiliaryImageAndVerify(miiAuxiliaryImage5, miiAuxiliaryImage6, domainUid, wdtDomainNamespace); + // check configuration for DataSource in the running domain + adminServiceNodePort + = getServiceNodePort(wdtDomainNamespace, getExternalServicePodName(adminServerPodName), "default"); + assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); + assertTrue(checkSystemResourceConfig(adminServiceNodePort, + "JDBCSystemResources/TestDataSource/JDBCResource/JDBCDriverParams", + "jdbc:oracle:thin:@\\/\\/xxx.xxx.x.xxx:1521\\/ORCLCDB"),"Can't find expected URL configuration for DataSource"); + + } + private static void patchDomainWithAuxiliaryImageAndVerify(String oldImageName, String newImageName, String domainUid, String domainNamespace) { String adminServerPodName = domainUid + "-admin-server"; diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java index 01c55fb6cbd..5c34cc3fbea 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java @@ -56,8 +56,22 @@ public static InstallParams defaultInstallWdtParams() { .location(WDT_DOWNLOAD_URL) .verify(true) .unzip(false); - } - + } + + /** + * Create an InstallParams with the default values for WDT. + * @param locationURL wdt download url + * @return an InstallParams instance + */ + public static InstallParams installWdtParams(String locationURL) { + return new InstallParams() + .defaults() + .type(WDT) + .location(locationURL) + .verify(true) + .unzip(false); + } + /** * Create an InstallParams with the default values for WIT. * @return an InstallParams instance diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java index 2fe334d9b45..04a8ac1156b 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java @@ -31,8 +31,9 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static oracle.weblogic.kubernetes.actions.ActionConstants.DOWNLOAD_DIR; import static oracle.weblogic.kubernetes.actions.ActionConstants.WDT_DOWNLOAD_FILENAME_DEFAULT; +import static oracle.weblogic.kubernetes.actions.ActionConstants.WDT_DOWNLOAD_URL; import static oracle.weblogic.kubernetes.actions.TestActions.execCommand; -import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.defaultInstallWdtParams; +import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.installWdtParams; import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger; import static org.apache.commons.io.FileUtils.cleanDirectory; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -322,10 +323,18 @@ public static boolean doesFileExistInPod(String namespace, String podName, Strin * @param unzipLocation location to unzip the files */ public static void unzipWDTInstallationFile(String unzipLocation) { + unzipWDTInstallationFile(unzipLocation, WDT_DOWNLOAD_URL); + } + + /** + * Download and unzip the WDT installation files. + * @param unzipLocation location to unzip the files + */ + public static void unzipWDTInstallationFile(String unzipLocation, String locationURL) { Path wlDeployZipFile = Paths.get(DOWNLOAD_DIR, WDT_DOWNLOAD_FILENAME_DEFAULT); if (!Files.exists(wlDeployZipFile)) { assertTrue(Installer.withParams( - defaultInstallWdtParams()) + installWdtParams(locationURL)) .download(), "WDT download failed"); } String cmdToExecute = String.format("unzip %s -d %s", wlDeployZipFile, unzipLocation); From 37014891696ec0c4f36fdb67279028f4fad49113 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Wed, 21 Jul 2021 20:28:45 +0000 Subject: [PATCH 2/9] cleanup --- .../kubernetes/ItMiiAuxiliaryImage.java | 183 +++++++++++------- 1 file changed, 111 insertions(+), 72 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java index a180230168a..4487d5a47e7 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java @@ -53,7 +53,6 @@ import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource; import static oracle.weblogic.kubernetes.actions.TestActions.defaultAppParams; import static oracle.weblogic.kubernetes.actions.TestActions.deleteImage; -import static oracle.weblogic.kubernetes.actions.TestActions.dockerPush; import static oracle.weblogic.kubernetes.actions.TestActions.dockerTag; import static oracle.weblogic.kubernetes.actions.TestActions.getDomainCustomResource; import static oracle.weblogic.kubernetes.actions.TestActions.getOperatorPodName; @@ -186,8 +185,10 @@ public void testCreateDomainUsingMultipleAuxiliaryImages() { // create stage dir for first auxiliary image with image1 Path multipleAIPath1 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage1"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath1.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath1)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath1.toFile()), + "Delete directory failed"); + assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath1), + "Create directory failed"); Path multipleAIPathToFile1 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage1/test.txt"); String content = "1"; assertDoesNotThrow(() -> Files.write(multipleAIPathToFile1, content.getBytes()), @@ -227,13 +228,15 @@ public void testCreateDomainUsingMultipleAuxiliaryImages() { // push image1 to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage1, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(miiAuxiliaryImage1), String.format("docker push failed for image %s", miiAuxiliaryImage1)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage1); } // create stage dir for second auxiliary image with image2 Path multipleAIPath2 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage2"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath2.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath2)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath2.toFile()), + "Delete directory failed"); + assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath2), + "Create directory failed"); // create models dir and copy model, archive files if any Path modelsPath2 = Paths.get(multipleAIPath2.toString(), "models"); @@ -254,7 +257,7 @@ public void testCreateDomainUsingMultipleAuxiliaryImages() { // push image2 to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage2, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(miiAuxiliaryImage2), String.format("docker push failed for image %s", miiAuxiliaryImage2)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage2); } // create domain custom resource using 2 auxiliary images @@ -317,7 +320,7 @@ public void testUpdateDataSourceInDomainUsingAuxiliaryImage() { // push image3 to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage3, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(miiAuxiliaryImage3), String.format("docker push failed for image %s", miiAuxiliaryImage3)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage3); } // check configuration for DataSource in the running domain @@ -407,7 +410,7 @@ public void testUpdateBaseImageName() { * Negative Test to create domain with mismatch mount path in auxiliary image and auxiliaryImageVolumes. * in auxiliaryImageVolumes, set mountPath to "/errorpath" * in auxiliary image, set AUXILIARY_IMAGE_PATH to "/auxiliary" - * Check the error msg is in introspector pod log, domain events and operator pod log. + * Check the error message is in introspector pod log, domain events and operator pod log. */ @Test @Order(3) @@ -424,8 +427,10 @@ public void testErrorPathDomainMismatchMountPath() { // create stage dir for auxiliary image Path errorpathAIPath1 = Paths.get(RESULTS_ROOT, "errorpathauxiimage1"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath1.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(errorpathAIPath1)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath1.toFile()), + "Delete directory failed"); + assertDoesNotThrow(() -> Files.createDirectories(errorpathAIPath1), + "Create directory failed"); // create models dir and copy model for image Path modelsPath1 = Paths.get(errorpathAIPath1.toString(), "models"); @@ -445,8 +450,7 @@ public void testErrorPathDomainMismatchMountPath() { // push image to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage1, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(errorPathAuxiliaryImage1), - String.format("docker push failed for image %s", errorPathAuxiliaryImage1)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage1); } // create domain custom resource using auxiliary images @@ -462,16 +466,16 @@ public void testErrorPathDomainMismatchMountPath() { domainUid, errorPathAuxiliaryImage1, errorpathDomainNamespace); assertDoesNotThrow(() -> createDomainCustomResource(domainCR), "createDomainCustomResource throws Exception"); - // check the introspector pod log contains the expected error msg + // check the introspector pod log contains the expected error message String expectedErrorMsg = "Auxiliary Image: Dir '/errorpath' doesn't exist or is empty. Exiting."; String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, errorpathDomainNamespace)); checkPodLogContainsString(errorpathDomainNamespace, introspectorPodName, expectedErrorMsg); - // check the domain event contains the expected error msg + // check the domain event contains the expected error message checkDomainEventContainsExpectedMsg(opNamespace, errorpathDomainNamespace, domainUid, DOMAIN_PROCESSING_FAILED, "Warning", timestamp, expectedErrorMsg); - // check the operator pod log contains the expected error msg + // check the operator pod log contains the expected error message String operatorPodName = assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace)); checkPodLogContainsString(opNamespace, operatorPodName, expectedErrorMsg); @@ -490,7 +494,7 @@ public void testErrorPathDomainMismatchMountPath() { /** * Negative Test to create domain without WDT binary. - * Check the error msg is in introspector pod log, domain events and operator pod log. + * Check the error message is in introspector pod log, domain events and operator pod log. */ @Test @Order(4) @@ -507,16 +511,19 @@ public void testErrorPathDomainMissingWDTBinary() { // create stage dir for common mount image Path errorpathAIPath2 = Paths.get(RESULTS_ROOT, "errorpathauxiimage2"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath2.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(errorpathAIPath2)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath2.toFile()), + "Delete directory failed"); + assertDoesNotThrow(() -> Files.createDirectories(errorpathAIPath2), + "Create directory failed"); // create models dir and copy model for image Path modelsPath2 = Paths.get(errorpathAIPath2.toString(), "models"); - assertDoesNotThrow(() -> Files.createDirectories(modelsPath2)); + assertDoesNotThrow(() -> Files.createDirectories(modelsPath2), + "Create directory failed"); assertDoesNotThrow(() -> Files.copy( Paths.get(MODEL_DIR, MII_BASIC_WDT_MODEL_FILE), Paths.get(modelsPath2.toString(), MII_BASIC_WDT_MODEL_FILE), - StandardCopyOption.REPLACE_EXISTING)); + StandardCopyOption.REPLACE_EXISTING), "Copy files failed"); // create image with model and no wdt installation files createAuxiliaryImage(errorpathAIPath2.toString(), @@ -525,8 +532,7 @@ public void testErrorPathDomainMissingWDTBinary() { // push image to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage2, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(errorPathAuxiliaryImage2), - String.format("docker push failed for image %s", errorPathAuxiliaryImage2)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage2); } // create domain custom resource using auxiliary images @@ -542,20 +548,22 @@ public void testErrorPathDomainMissingWDTBinary() { domainUid, errorPathAuxiliaryImage2, errorpathDomainNamespace); assertDoesNotThrow(() -> createDomainCustomResource(domainCR), "createDomainCustomResource throws Exception"); - // check the introspector pod log contains the expected error msg + // check the introspector pod log contains the expected error message String expectedErrorMsg = "The domain resource 'spec.domainHomeSourceType' is 'FromModel' and " + "a WebLogic Deploy Tool (WDT) install is not located at 'spec.configuration.model.wdtInstallHome' " + "which is currently set to '/auxiliary/weblogic-deploy'"; - String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, errorpathDomainNamespace)); + String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, errorpathDomainNamespace), + "Can't get introspector pod's name"); checkPodLogContainsString(errorpathDomainNamespace, introspectorPodName, expectedErrorMsg); - // check the domain event contains the expected error msg + // check the domain event contains the expected error message checkDomainEventContainsExpectedMsg(opNamespace, errorpathDomainNamespace, domainUid, DOMAIN_PROCESSING_FAILED, "Warning", timestamp, expectedErrorMsg); - // check the operator pod log contains the expected error msg + // check the operator pod log contains the expected error message String operatorPodName = - assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace)); + assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace), + "Can't get operator pod's name"); checkPodLogContainsString(opNamespace, operatorPodName, expectedErrorMsg); // check there are no admin server and managed server pods and services created @@ -589,16 +597,20 @@ public void testErrorPathDomainMissingDomainConfig() { // create stage dir for auxiliary image Path errorpathAIPath3 = Paths.get(RESULTS_ROOT, "errorpathauxiimage3"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath3.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(errorpathAIPath3)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath3.toFile()), + "Delete directory failed"); + assertDoesNotThrow(() -> Files.createDirectories(errorpathAIPath3), + "Create directory failed"); // create models dir and copy model for image Path modelsPath3 = Paths.get(errorpathAIPath3.toString(), "models"); - assertDoesNotThrow(() -> Files.createDirectories(modelsPath3)); + assertDoesNotThrow(() -> Files.createDirectories(modelsPath3), + "Create directory failed"); assertDoesNotThrow(() -> Files.copy( Paths.get(MODEL_DIR, "model.jms2.yaml"), Paths.get(modelsPath3.toString(), "model.jms2.yaml"), - StandardCopyOption.REPLACE_EXISTING)); + StandardCopyOption.REPLACE_EXISTING), + "Copy files failed"); // unzip WDT installation file into work dir unzipWDTInstallationFile(errorpathAIPath3.toString()); @@ -610,8 +622,7 @@ public void testErrorPathDomainMissingDomainConfig() { // push image to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage3, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(errorPathAuxiliaryImage3), - String.format("docker push failed for image %s", errorPathAuxiliaryImage3)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage3); } // create domain custom resource using auxiliary images @@ -627,19 +638,21 @@ public void testErrorPathDomainMissingDomainConfig() { domainUid, errorPathAuxiliaryImage3, errorpathDomainNamespace); assertDoesNotThrow(() -> createDomainCustomResource(domainCR), "createDomainCustomResource throws Exception"); - // check the introspector pod log contains the expected error msg + // check the introspector pod log contains the expected error message String expectedErrorMsg = "createDomain did not find the required domainInfo section in the model file /auxiliary/models/model.jms2.yaml"; - String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, errorpathDomainNamespace)); + String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, errorpathDomainNamespace), + "Get introspector's pod name failed"); checkPodLogContainsString(errorpathDomainNamespace, introspectorPodName, expectedErrorMsg); - // check the domain event contains the expected error msg + // check the domain event contains the expected error message checkDomainEventContainsExpectedMsg(opNamespace, errorpathDomainNamespace, domainUid, DOMAIN_PROCESSING_FAILED, "Warning", timestamp, expectedErrorMsg); - // check the operator pod log contains the expected error msg + // check the operator pod log contains the expected error message String operatorPodName = - assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace)); + assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace), + "Get operator's pod name failed"); checkPodLogContainsString(opNamespace, operatorPodName, expectedErrorMsg); // check there are no admin server and managed server pods and services created @@ -658,7 +671,7 @@ public void testErrorPathDomainMissingDomainConfig() { * Negative Test to patch the existing domain using a custom mount command that's guaranteed to fail. * Specify domain.spec.serverPod.auxiliaryImages.command to a custom mount command instead of the default one, which * defaults to "cp -R $AUXILIARY_IMAGE_PATH/* $TARGET_MOUNT_PATH" - * Check the error msg in introspector pod log, domain events and operator pod log. + * Check the error message in introspector pod log, domain events and operator pod log. * Restore the domain by removing the custom mount command. */ @Test @@ -702,18 +715,20 @@ public void testErrorPathDomainWithFailCustomMountCommand() { "patchDomainCustomResource(Auxiliary Image) failed "); assertTrue(aiPatched, "patchDomainCustomResource(auxiliary image) failed"); - // check the introspector pod log contains the expected error msg + // check the introspector pod log contains the expected error message String expectedErrorMsg = "Auxiliary Image: Command 'exit 1' execution failed in container"; - String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, domainNamespace)); + String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, domainNamespace), + "Get introspector's pod name failed"); checkPodLogContainsString(domainNamespace, introspectorPodName, expectedErrorMsg); - // check the domain event contains the expected error msg + // check the domain event contains the expected error message checkDomainEventContainsExpectedMsg(opNamespace, domainNamespace, domainUid, DOMAIN_PROCESSING_FAILED, "Warning", timestamp, expectedErrorMsg); - // check the operator pod log contains the expected error msg + // check the operator pod log contains the expected error message String operatorPodName = - assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace)); + assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace), + "Get operator's pod name failed"); checkPodLogContainsString(opNamespace, operatorPodName, expectedErrorMsg); // verify the domain is not rolled @@ -748,7 +763,7 @@ public void testErrorPathDomainWithFailCustomMountCommand() { * Negative Test to create domain with file , created by user tester with permission read only * and not accessible by oracle user in auxiliary image * via provided Dockerfile. - * Check the error msg is in introspector pod log, domain events and operator pod log. + * Check the error message is in introspector pod log, domain events and operator pod log. */ @Test @Order(7) @@ -765,8 +780,10 @@ public void testErrorPathFilePermission() { // create stage dir for auxiliary image Path errorpathAIPath1 = Paths.get(RESULTS_ROOT, "errorpathauxiimage4"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath1.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(errorpathAIPath1)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath1.toFile()), + "Can't delete directory"); + assertDoesNotThrow(() -> Files.createDirectories(errorpathAIPath1), + "Can't create directory"); Path errorpathAIPathToFile = Paths.get(RESULTS_ROOT, "errorpathauxiimage4/test1.txt"); String content = "some text "; @@ -775,11 +792,13 @@ public void testErrorPathFilePermission() { // create models dir and copy model for image Path modelsPath1 = Paths.get(errorpathAIPath1.toString(), "models"); - assertDoesNotThrow(() -> Files.createDirectories(modelsPath1)); + assertDoesNotThrow(() -> Files.createDirectories(modelsPath1), + "Can't create directory"); assertDoesNotThrow(() -> Files.copy( Paths.get(MODEL_DIR, MII_BASIC_WDT_MODEL_FILE), Paths.get(modelsPath1.toString(), MII_BASIC_WDT_MODEL_FILE), - StandardCopyOption.REPLACE_EXISTING)); + StandardCopyOption.REPLACE_EXISTING), + "Can't copy files"); // build app assertTrue(buildAppArchive(defaultAppParams() @@ -791,7 +810,7 @@ public void testErrorPathFilePermission() { assertDoesNotThrow(() -> Files.copy( Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), Paths.get(modelsPath1.toString(), MII_BASIC_APP_NAME + ".zip"), - StandardCopyOption.REPLACE_EXISTING)); + StandardCopyOption.REPLACE_EXISTING), "Can't copy files"); // unzip WDT installation file into work dir unzipWDTInstallationFile(errorpathAIPath1.toString()); @@ -803,8 +822,7 @@ public void testErrorPathFilePermission() { // push image to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage1, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(errorPathAuxiliaryImage1), - String.format("docker push failed for image %s", errorPathAuxiliaryImage1)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage1); } // create domain custom resource using auxiliary images @@ -820,18 +838,20 @@ public void testErrorPathFilePermission() { domainUid, errorPathAuxiliaryImage1, errorpathDomainNamespace); assertDoesNotThrow(() -> createDomainCustomResource(domainCR), "createDomainCustomResource throws Exception"); - // check the introspector pod log contains the expected error msg + // check the introspector pod log contains the expected error message String expectedErrorMsg = "cp: can't open '/auxiliary/test1.txt': Permission denied"; - String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, errorpathDomainNamespace)); + String introspectorPodName = assertDoesNotThrow(() -> getIntrospectorPodName(domainUid, errorpathDomainNamespace), + "Can't get introspector's pod name"); checkPodLogContainsString(errorpathDomainNamespace, introspectorPodName, expectedErrorMsg); - // check the domain event contains the expected error msg + // check the domain event contains the expected error message checkDomainEventContainsExpectedMsg(opNamespace, errorpathDomainNamespace, domainUid, DOMAIN_PROCESSING_FAILED, "Warning", timestamp, expectedErrorMsg); - // check the operator pod log contains the expected error msg + // check the operator pod log contains the expected error message String operatorPodName = - assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace)); + assertDoesNotThrow(() -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace), + "Can't get operator's pod name"); checkPodLogContainsString(opNamespace, operatorPodName, expectedErrorMsg); // check there are no admin server and managed server pods and services not created @@ -880,8 +900,10 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { // create stage dir for first auxiliary image containing domain configuration Path multipleAIPath1 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage1"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath1.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath1)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath1.toFile()), + "Delete directory failed"); + assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath1), + "Failed to create directory"); // create models dir and copy model, archive files if any for image1 Path modelsPath1 = Paths.get(multipleAIPath1.toString(), "models"); @@ -889,11 +911,11 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { assertDoesNotThrow(() -> Files.copy( Paths.get(MODEL_DIR, MII_BASIC_WDT_MODEL_FILE), Paths.get(modelsPath1.toString(), MII_BASIC_WDT_MODEL_FILE), - StandardCopyOption.REPLACE_EXISTING)); + StandardCopyOption.REPLACE_EXISTING), "Failed to copy file"); assertDoesNotThrow(() -> Files.copy( Paths.get(MODEL_DIR, "multi-model-one-ds.20.yaml"), Paths.get(modelsPath1.toString(), "multi-model-one-ds.20.yaml"), - StandardCopyOption.REPLACE_EXISTING)); + StandardCopyOption.REPLACE_EXISTING), "Failed to copy file"); // build app assertTrue(buildAppArchive(defaultAppParams() @@ -905,7 +927,7 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { assertDoesNotThrow(() -> Files.copy( Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), Paths.get(modelsPath1.toString(), MII_BASIC_APP_NAME + ".zip"), - StandardCopyOption.REPLACE_EXISTING)); + StandardCopyOption.REPLACE_EXISTING), "Failed to copy file"); // create image1 with domain configuration only createAuxiliaryImage(multipleAIPath1.toString(), @@ -914,16 +936,17 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { // push image1 to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage4, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(miiAuxiliaryImage4), String.format("docker push failed for image %s", miiAuxiliaryImage4)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage4); } // create stage dir for second auxiliary image Path multipleAIPath2 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage2"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath2.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath2)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath2.toFile()), + "Delete directory failed"); + assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath2), "Create directory failed"); Path modelsPath2 = Paths.get(multipleAIPath2.toString(), "models"); - assertDoesNotThrow(() -> Files.createDirectories(modelsPath2)); + assertDoesNotThrow(() -> Files.createDirectories(modelsPath2), "Create directory failed"); // unzip 1.9.15 version WDT installation file into work dir String wdtURL = "https://github.com/oracle/weblogic-deploy-tooling/releases/release-1.9.15"; @@ -936,16 +959,19 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { // push image2 to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage5, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(miiAuxiliaryImage5), String.format("docker push failed for image %s", miiAuxiliaryImage5)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage5); } // create stage dir for third auxiliary image with latest wdt installation files only Path multipleAIPath3 = Paths.get(RESULTS_ROOT, "multipleauxiliaryimage3"); - assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath3.toFile())); - assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath3)); + assertDoesNotThrow(() -> FileUtils.deleteDirectory(multipleAIPath3.toFile()), + "Delete directory failed"); + assertDoesNotThrow(() -> Files.createDirectories(multipleAIPath3), + "Create directory failed"); Path modelsPath3 = Paths.get(multipleAIPath3.toString(), "models"); - assertDoesNotThrow(() -> Files.createDirectories(modelsPath3)); + assertDoesNotThrow(() -> Files.createDirectories(modelsPath3), + "Create directory failed"); // unzip WDT installation file into work dir unzipWDTInstallationFile(multipleAIPath3.toString()); @@ -957,7 +983,8 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { // push image3 to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage6, DOMAIN_IMAGES_REPO); - assertTrue(dockerPush(miiAuxiliaryImage6), String.format("docker push failed for image %s", miiAuxiliaryImage6)); + //assertTrue(dockerLoginAndPushImageToRegistry(miiAuxiliaryImage6), String.format("docker push failed for image %s", miiAuxiliaryImage6)); + dockerLoginAndPushImageToRegistry(miiAuxiliaryImage6); } // create domain custom resource using 2 auxiliary images ( image1, image2) @@ -1078,6 +1105,18 @@ public void tearDownAll() { if (miiAuxiliaryImage3 != null) { deleteImage(miiAuxiliaryImage3); } + + if (miiAuxiliaryImage4 != null) { + deleteImage(miiAuxiliaryImage4); + } + + if (miiAuxiliaryImage5 != null) { + deleteImage(miiAuxiliaryImage5); + } + + if (miiAuxiliaryImage6 != null) { + deleteImage(miiAuxiliaryImage6); + } } private void createAuxiliaryImage(String stageDirPath, String dockerFileLocation, String auxiliaryImage) { From 8ed0b2c906848c73b897ad822633232810695c26 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Wed, 21 Jul 2021 20:29:27 +0000 Subject: [PATCH 3/9] cleanup1 --- .../java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java index 4487d5a47e7..bb9f72ed3d6 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java @@ -983,7 +983,6 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { // push image3 to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", miiAuxiliaryImage6, DOMAIN_IMAGES_REPO); - //assertTrue(dockerLoginAndPushImageToRegistry(miiAuxiliaryImage6), String.format("docker push failed for image %s", miiAuxiliaryImage6)); dockerLoginAndPushImageToRegistry(miiAuxiliaryImage6); } From 72a9ea0aa588af1b388822c2514f075a5a7f5ec0 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Wed, 21 Jul 2021 22:09:04 +0000 Subject: [PATCH 4/9] fixed imagename --- .../kubernetes/ItMiiAuxiliaryImage.java | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java index bb9f72ed3d6..0a15ef7c87f 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java @@ -112,6 +112,10 @@ public class ItMiiAuxiliaryImage { private static String miiAuxiliaryImage4 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "4"; private static String miiAuxiliaryImage5 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "5"; private static String miiAuxiliaryImage6 = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG + "6"; + private static String errorPathAuxiliaryImage1 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage1"; + private static String errorPathAuxiliaryImage2 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage2"; + private static String errorPathAuxiliaryImage3 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage3"; + private static String errorPathAuxiliaryImage4 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage4"; private static Map podsWithTimeStamps = null; private final String adminServerPodName = domainUid + "-admin-server"; private final String managedServerPrefix = domainUid + "-managed-server"; @@ -418,7 +422,6 @@ public void testUpdateBaseImageName() { public void testErrorPathDomainMismatchMountPath() { OffsetDateTime timestamp = now(); - String errorPathAuxiliaryImage1 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage1"; final String auxiliaryImageVolumeName = "auxiliaryImageVolume1"; final String auxiliaryImagePath = "/errorpath"; @@ -450,7 +453,7 @@ public void testErrorPathDomainMismatchMountPath() { // push image to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage1, DOMAIN_IMAGES_REPO); - dockerLoginAndPushImageToRegistry(miiAuxiliaryImage1); + dockerLoginAndPushImageToRegistry(errorPathAuxiliaryImage1); } // create domain custom resource using auxiliary images @@ -502,7 +505,6 @@ public void testErrorPathDomainMismatchMountPath() { public void testErrorPathDomainMissingWDTBinary() { OffsetDateTime timestamp = now(); - String errorPathAuxiliaryImage2 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage2"; final String auxiliaryImageVolumeName = "auxiliaryImageVolume1"; final String auxiliaryImagePath = "/auxiliary"; @@ -532,7 +534,7 @@ public void testErrorPathDomainMissingWDTBinary() { // push image to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage2, DOMAIN_IMAGES_REPO); - dockerLoginAndPushImageToRegistry(miiAuxiliaryImage2); + dockerLoginAndPushImageToRegistry(errorPathAuxiliaryImage2); } // create domain custom resource using auxiliary images @@ -588,7 +590,6 @@ public void testErrorPathDomainMissingWDTBinary() { public void testErrorPathDomainMissingDomainConfig() { OffsetDateTime timestamp = now(); - String errorPathAuxiliaryImage3 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage3"; final String auxiliaryImageVolumeName = "auxiliaryImageVolume1"; final String auxiliaryImagePath = "/auxiliary"; @@ -622,7 +623,7 @@ public void testErrorPathDomainMissingDomainConfig() { // push image to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage3, DOMAIN_IMAGES_REPO); - dockerLoginAndPushImageToRegistry(miiAuxiliaryImage3); + dockerLoginAndPushImageToRegistry(errorPathAuxiliaryImage3); } // create domain custom resource using auxiliary images @@ -771,7 +772,6 @@ public void testErrorPathDomainWithFailCustomMountCommand() { public void testErrorPathFilePermission() { OffsetDateTime timestamp = now(); - String errorPathAuxiliaryImage1 = MII_AUXILIARY_IMAGE_NAME + ":errorpathimage4"; final String auxiliaryImageVolumeName = "auxiliaryImageVolume1"; final String auxiliaryImagePath = "/auxiliary"; @@ -817,25 +817,25 @@ public void testErrorPathFilePermission() { // create image with model and wdt installation files createAuxiliaryImage(errorpathAIPath1.toString(), - Paths.get(RESOURCE_DIR, "auxiliaryimage", "/negative/Dockerfile").toString(), errorPathAuxiliaryImage1); + Paths.get(RESOURCE_DIR, "auxiliaryimage", "/negative/Dockerfile").toString(), errorPathAuxiliaryImage4); // push image to repo for multi node cluster if (!DOMAIN_IMAGES_REPO.isEmpty()) { - logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage1, DOMAIN_IMAGES_REPO); - dockerLoginAndPushImageToRegistry(miiAuxiliaryImage1); + logger.info("docker push image {0} to registry {1}", errorPathAuxiliaryImage4, DOMAIN_IMAGES_REPO); + dockerLoginAndPushImageToRegistry(errorPathAuxiliaryImage4); } // create domain custom resource using auxiliary images logger.info("Creating domain custom resource with domainUid {0} and auxiliary image {1}", - domainUid, errorPathAuxiliaryImage1); + domainUid, errorPathAuxiliaryImage4); Domain domainCR = createDomainResource(domainUid, errorpathDomainNamespace, WEBLOGIC_IMAGE_NAME + ":" + WEBLOGIC_IMAGE_TAG, adminSecretName, OCIR_SECRET_NAME, encryptionSecretName, replicaCount, "cluster-1", auxiliaryImagePath, - auxiliaryImageVolumeName, errorPathAuxiliaryImage1); + auxiliaryImageVolumeName, errorPathAuxiliaryImage4); // create domain and verify it is failed logger.info("Creating domain {0} with auxiliary image {1} in namespace {2}", - domainUid, errorPathAuxiliaryImage1, errorpathDomainNamespace); + domainUid, errorPathAuxiliaryImage4, errorpathDomainNamespace); assertDoesNotThrow(() -> createDomainCustomResource(domainCR), "createDomainCustomResource throws Exception"); // check the introspector pod log contains the expected error message @@ -1116,6 +1116,22 @@ public void tearDownAll() { if (miiAuxiliaryImage6 != null) { deleteImage(miiAuxiliaryImage6); } + + if (errorPathAuxiliaryImage1 != null) { + deleteImage(errorPathAuxiliaryImage1); + } + + if (errorPathAuxiliaryImage2 != null) { + deleteImage(errorPathAuxiliaryImage2); + } + + if (errorPathAuxiliaryImage3 != null) { + deleteImage(errorPathAuxiliaryImage3); + } + + if (errorPathAuxiliaryImage4 != null) { + deleteImage(errorPathAuxiliaryImage4); + } } private void createAuxiliaryImage(String stageDirPath, String dockerFileLocation, String auxiliaryImage) { From 85bd53b2393c6fff47304f80c3a471b219f5d8c2 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Thu, 22 Jul 2021 18:12:20 +0000 Subject: [PATCH 5/9] added test var for specific wdt version --- .../weblogic/kubernetes/ItMiiAuxiliaryImage.java | 13 +++++++------ .../oracle/weblogic/kubernetes/TestConstants.java | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java index 0a15ef7c87f..e092606019e 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java @@ -44,6 +44,7 @@ import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME; import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME; import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT; +import static oracle.weblogic.kubernetes.TestConstants.WDT_TEST_VERSION; import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME; import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG; import static oracle.weblogic.kubernetes.actions.ActionConstants.ARCHIVE_DIR; @@ -281,7 +282,7 @@ public void testCreateDomainUsingMultipleAuxiliaryImages() { // check configuration for JMS checkConfiguredJMSresouce(domainNamespace, adminServerPodName); - //checking the order of loading for the common mount images, expecting file with content =2 + //checking the order of loading for the auxiliary images, expecting file with content =2 assertDoesNotThrow(() -> FileUtils.deleteQuietly(Paths.get(RESULTS_ROOT, "/test.txt").toFile())); assertDoesNotThrow(() -> copyFileFromPod(domainNamespace, adminServerPodName, "weblogic-server", @@ -290,7 +291,7 @@ public void testCreateDomainUsingMultipleAuxiliaryImages() { assertDoesNotThrow(() -> { String fileContent = Files.readAllLines(Paths.get(RESULTS_ROOT, "/test.txt")).get(0); - assertEquals("2", fileContent, "The content of the file from common mount path " + assertEquals("2", fileContent, "The content of the file from auxiliary image path " + fileContent + "does not match the expected 2"); }, "File from image2 was not loaded in the expected order"); } @@ -511,7 +512,7 @@ public void testErrorPathDomainMissingWDTBinary() { createSecretsForDomain(adminSecretName, encryptionSecretName, errorpathDomainNamespace); - // create stage dir for common mount image + // create stage dir for auxiliary image Path errorpathAIPath2 = Paths.get(RESULTS_ROOT, "errorpathauxiimage2"); assertDoesNotThrow(() -> FileUtils.deleteDirectory(errorpathAIPath2.toFile()), "Delete directory failed"); @@ -546,7 +547,7 @@ public void testErrorPathDomainMissingWDTBinary() { auxiliaryImageVolumeName, errorPathAuxiliaryImage2); // create domain and verify it is failed - logger.info("Creating domain {0} with common mount image {1} in namespace {2}", + logger.info("Creating domain {0} with auxiliary image {1} in namespace {2}", domainUid, errorPathAuxiliaryImage2, errorpathDomainNamespace); assertDoesNotThrow(() -> createDomainCustomResource(domainCR), "createDomainCustomResource throws Exception"); @@ -948,8 +949,8 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { Path modelsPath2 = Paths.get(multipleAIPath2.toString(), "models"); assertDoesNotThrow(() -> Files.createDirectories(modelsPath2), "Create directory failed"); - // unzip 1.9.15 version WDT installation file into work dir - String wdtURL = "https://github.com/oracle/weblogic-deploy-tooling/releases/release-1.9.15"; + // unzip older version WDT installation file into work dir + String wdtURL = "https://github.com/oracle/weblogic-deploy-tooling/releases/release-" + WDT_TEST_VERSION; unzipWDTInstallationFile(multipleAIPath2.toString(), wdtURL); // create image2 with wdt installation files only diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java index 0bfbba08603..d506017bee8 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java @@ -240,6 +240,9 @@ public interface TestConstants { public static final String WDT_IMAGE_DOMAINHOME_BASE_DIR = "/u01/oracle/user_projects/domains"; public static final String WDT_BASIC_IMAGE_DOMAINTYPE = "wdt"; public static final String WDT_BASIC_APP_NAME = "sample-app"; + public static final String WDT_TEST_VERSION = Optional.ofNullable(System.getenv( + "WDT_VERSION")) + .orElse("1.9.15"); //monitoring constants public static final String MONITORING_EXPORTER_WEBAPP_VERSION = Optional.ofNullable(System.getenv( From 255b9e1e877df50ac15ba130b1880d56d3c6ee56 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Thu, 22 Jul 2021 21:39:59 +0000 Subject: [PATCH 6/9] addresed review comments --- .../kubernetes/ItMiiAuxiliaryImage.java | 66 ++++++++++++++----- .../weblogic/kubernetes/utils/FileUtils.java | 7 +- 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java index e092606019e..89efc3ccad4 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java @@ -50,6 +50,7 @@ import static oracle.weblogic.kubernetes.actions.ActionConstants.ARCHIVE_DIR; import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR; import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR; +import static oracle.weblogic.kubernetes.actions.ActionConstants.WDT_DOWNLOAD_FILENAME_DEFAULT; import static oracle.weblogic.kubernetes.actions.TestActions.buildAppArchive; import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource; import static oracle.weblogic.kubernetes.actions.TestActions.defaultAppParams; @@ -131,8 +132,9 @@ public class ItMiiAuxiliaryImage { /** * Install Operator. + * * @param namespaces list of namespaces created by the IntegrationTestWatcher by the - * JUnit engine parameter resolution mechanism + * JUnit engine parameter resolution mechanism */ @BeforeAll public static void initAll(@Namespaces(4) List namespaces) { @@ -155,7 +157,7 @@ public static void initAll(@Namespaces(4) List namespaces) { wdtDomainNamespace = namespaces.get(3); // install and verify operator - installAndVerifyOperator(opNamespace, domainNamespace, errorpathDomainNamespace,wdtDomainNamespace); + installAndVerifyOperator(opNamespace, domainNamespace, errorpathDomainNamespace, wdtDomainNamespace); } @@ -219,7 +221,7 @@ public void testCreateDomainUsingMultipleAuxiliaryImages() { // copy app archive to models assertDoesNotThrow(() -> Files.copy( - Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), + Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), Paths.get(modelsPath1.toString(), MII_BASIC_APP_NAME + ".zip"), StandardCopyOption.REPLACE_EXISTING)); @@ -289,7 +291,7 @@ public void testCreateDomainUsingMultipleAuxiliaryImages() { auxiliaryImagePath + "/test.txt", Paths.get(RESULTS_ROOT, "/test.txt")), " Can't find file in the pod, or failed to copy"); - assertDoesNotThrow(() -> { + assertDoesNotThrow(() -> { String fileContent = Files.readAllLines(Paths.get(RESULTS_ROOT, "/test.txt")).get(0); assertEquals("2", fileContent, "The content of the file from auxiliary image path " + fileContent + "does not match the expected 2"); @@ -313,10 +315,10 @@ public void testUpdateDataSourceInDomainUsingAuxiliaryImage() { // replace DataSource URL info in the model file assertDoesNotThrow(() -> replaceStringInFile(Paths.get(modelsPath1.toString(), "/multi-model-one-ds.20.yaml").toString(), "xxx.xxx.x.xxx:1521", - "localhost:7001"),"Can't replace datasource url in the model file"); + "localhost:7001"), "Can't replace datasource url in the model file"); assertDoesNotThrow(() -> replaceStringInFile(Paths.get(modelsPath1.toString(), "/multi-model-one-ds.20.yaml").toString(), "ORCLCDB", - "dbsvc"),"Can't replace datasource url in the model file"); + "dbsvc"), "Can't replace datasource url in the model file"); // create image3 with model and wdt installation files createAuxiliaryImage(multipleAIPath1.toString(), @@ -334,7 +336,8 @@ public void testUpdateDataSourceInDomainUsingAuxiliaryImage() { assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); assertTrue(checkSystemResourceConfig(adminServiceNodePort, "JDBCSystemResources/TestDataSource/JDBCResource/JDBCDriverParams", - "jdbc:oracle:thin:@\\/\\/xxx.xxx.x.xxx:1521\\/ORCLCDB"),"Can't find expected URL configuration for DataSource"); + "jdbc:oracle:thin:@\\/\\/xxx.xxx.x.xxx:1521\\/ORCLCDB"), + "Can't find expected URL configuration for DataSource"); logger.info("Found the DataResource configuration"); @@ -708,7 +711,7 @@ public void testErrorPathDomainWithFailCustomMountCommand() { .append(" \"path\": " + searchString + ",") .append(" \"value\": \"exit 1\"") .append(" }]"); - logger.info("Auxiliary Image patch string: " + patchStr); + logger.info("Auxiliary Image patch string: " + patchStr); V1Patch patch = new V1Patch((patchStr).toString()); @@ -748,7 +751,7 @@ public void testErrorPathDomainWithFailCustomMountCommand() { patchStr.append("\"op\": \"remove\",") .append(" \"path\": " + searchString) .append(" }]"); - logger.info("Auxiliary Image patch string: " + patchStr); + logger.info("Auxiliary Image patch string: " + patchStr); V1Patch patch1 = new V1Patch((patchStr).toString()); @@ -809,7 +812,7 @@ public void testErrorPathFilePermission() { // copy app archive to models assertDoesNotThrow(() -> Files.copy( - Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), + Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), Paths.get(modelsPath1.toString(), MII_BASIC_APP_NAME + ".zip"), StandardCopyOption.REPLACE_EXISTING), "Can't copy files"); @@ -926,7 +929,7 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { // copy app archive to models assertDoesNotThrow(() -> Files.copy( - Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), + Paths.get(ARCHIVE_DIR, MII_BASIC_APP_NAME + ".zip"), Paths.get(modelsPath1.toString(), MII_BASIC_APP_NAME + ".zip"), StandardCopyOption.REPLACE_EXISTING), "Failed to copy file"); @@ -950,8 +953,11 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { assertDoesNotThrow(() -> Files.createDirectories(modelsPath2), "Create directory failed"); // unzip older version WDT installation file into work dir - String wdtURL = "https://github.com/oracle/weblogic-deploy-tooling/releases/release-" + WDT_TEST_VERSION; - unzipWDTInstallationFile(multipleAIPath2.toString(), wdtURL); + String wdtURL = "https://github.com/oracle/weblogic-deploy-tooling/releases/download/release-" + + WDT_TEST_VERSION + "/" + + WDT_DOWNLOAD_FILENAME_DEFAULT; + unzipWDTInstallationFile(multipleAIPath2.toString(), wdtURL, + "weblogic-deploy" + WDT_TEST_VERSION + ".zip"); // create image2 with wdt installation files only createAuxiliaryImage(multipleAIPath2.toString(), @@ -1007,19 +1013,37 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); assertTrue(checkSystemResourceConfig(adminServiceNodePort, "JDBCSystemResources/TestDataSource/JDBCResource/JDBCDriverParams", - "jdbc:oracle:thin:@\\/\\/xxx.xxx.x.xxx:1521\\/ORCLCDB"),"Can't find expected URL configuration for DataSource"); + "jdbc:oracle:thin:@\\/\\/xxx.xxx.x.xxx:1521\\/ORCLCDB"), + "Can't find expected URL configuration for DataSource"); logger.info("Found the DataResource configuration"); + //check WDT version in the image equals the provided WDT_TEST_VERSION + + assertDoesNotThrow(() -> { + String wdtVersion = checkWDTVersion(wdtDomainNamespace, auxiliaryImagePath); + assertEquals("WebLogic Deploy Tooling " + WDT_TEST_VERSION, wdtVersion, + " Used WDT in the auxiliary image does not match the expected"); + }, "Can't retrieve wdt version file or version does match the expected"); //updating wdt to latest version by patching the domain with image3 patchDomainWithAuxiliaryImageAndVerify(miiAuxiliaryImage5, miiAuxiliaryImage6, domainUid, wdtDomainNamespace); + + //check that WDT version is changed + assertDoesNotThrow(() -> { + String wdtVersion = checkWDTVersion(wdtDomainNamespace, auxiliaryImagePath); + assertNotEquals("WebLogic Deploy Tooling " + WDT_TEST_VERSION,wdtVersion, + " Used WDT in the auxiliary image was not updated"); + }, "Can't retrieve wdt version file " + + "or wdt was not updated after patching with auxiliary image"); + // check configuration for DataSource in the running domain adminServiceNodePort = getServiceNodePort(wdtDomainNamespace, getExternalServicePodName(adminServerPodName), "default"); assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); assertTrue(checkSystemResourceConfig(adminServiceNodePort, "JDBCSystemResources/TestDataSource/JDBCResource/JDBCDriverParams", - "jdbc:oracle:thin:@\\/\\/xxx.xxx.x.xxx:1521\\/ORCLCDB"),"Can't find expected URL configuration for DataSource"); + "jdbc:oracle:thin:@\\/\\/xxx.xxx.x.xxx:1521\\/ORCLCDB"), + "Can't find expected URL configuration for DataSource"); } @@ -1052,7 +1076,7 @@ private static void patchDomainWithAuxiliaryImageAndVerify(String oldImageName, .append(" \"path\": " + searchString + ",") .append(" \"value\": \"" + newImageName + "\"") .append(" }]"); - logger.info("Auxiliary Image patch string: " + patchStr); + logger.info("Auxiliary Image patch string: " + patchStr); //get current timestamp before domain rolling restart to verify domain roll events podsWithTimeStamps = getPodsWithTimeStamps(domainNamespace, adminServerPodName, @@ -1183,4 +1207,14 @@ private void checkConfiguredJDBCresouce(String domainNamespace, String adminServ logger.info("Found the DataResource configuration"); } + private String checkWDTVersion(String domainNamespace, String auxiliaryImagePath) throws Exception { + assertDoesNotThrow(() -> FileUtils.deleteQuietly(Paths.get(RESULTS_ROOT, "/WDTversion.txt").toFile())); + assertDoesNotThrow(() -> copyFileFromPod(domainNamespace, + adminServerPodName, "weblogic-server", + auxiliaryImagePath + "/weblogic-deploy/VERSION.txt", + Paths.get(RESULTS_ROOT, "/WDTversion.txt")), " Can't find file in the pod, or failed to copy"); + + + return Files.readAllLines(Paths.get(RESULTS_ROOT, "/WDTversion.txt")).get(0); + } } diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java index 04a8ac1156b..6910d77166b 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java @@ -323,15 +323,16 @@ public static boolean doesFileExistInPod(String namespace, String podName, Strin * @param unzipLocation location to unzip the files */ public static void unzipWDTInstallationFile(String unzipLocation) { - unzipWDTInstallationFile(unzipLocation, WDT_DOWNLOAD_URL); + unzipWDTInstallationFile(unzipLocation, WDT_DOWNLOAD_URL, WDT_DOWNLOAD_FILENAME_DEFAULT); } /** * Download and unzip the WDT installation files. * @param unzipLocation location to unzip the files + * @param wdtFileName zip archive file name */ - public static void unzipWDTInstallationFile(String unzipLocation, String locationURL) { - Path wlDeployZipFile = Paths.get(DOWNLOAD_DIR, WDT_DOWNLOAD_FILENAME_DEFAULT); + public static void unzipWDTInstallationFile(String unzipLocation, String locationURL, String wdtFileName) { + Path wlDeployZipFile = Paths.get(DOWNLOAD_DIR, wdtFileName); if (!Files.exists(wlDeployZipFile)) { assertTrue(Installer.withParams( installWdtParams(locationURL)) From e7e67ae1c0d0c5803b0ea6355f5bbe75cc676d9d Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Fri, 23 Jul 2021 02:38:19 +0000 Subject: [PATCH 7/9] added check for wdt ver --- .../kubernetes/ItMiiAuxiliaryImage.java | 3 +- .../actions/impl/primitive/Installer.java | 39 +++++++++++-------- .../weblogic/kubernetes/utils/FileUtils.java | 12 +++--- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java index 89efc3ccad4..2339ee9c7db 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java @@ -48,6 +48,7 @@ import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_NAME; import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TAG; import static oracle.weblogic.kubernetes.actions.ActionConstants.ARCHIVE_DIR; +import static oracle.weblogic.kubernetes.actions.ActionConstants.DOWNLOAD_DIR; import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR; import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR; import static oracle.weblogic.kubernetes.actions.ActionConstants.WDT_DOWNLOAD_FILENAME_DEFAULT; @@ -957,7 +958,7 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { + WDT_TEST_VERSION + "/" + WDT_DOWNLOAD_FILENAME_DEFAULT; unzipWDTInstallationFile(multipleAIPath2.toString(), wdtURL, - "weblogic-deploy" + WDT_TEST_VERSION + ".zip"); + DOWNLOAD_DIR + "/ver" +WDT_TEST_VERSION ); // create image2 with wdt installation files only createAuxiliaryImage(multipleAIPath2.toString(), diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java index 5c34cc3fbea..494f0d1cb85 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java @@ -145,44 +145,48 @@ private Installer params(InstallParams params) { * @return true if the command succeeds */ public boolean download() { - + return download(DOWNLOAD_DIR); + } + + public boolean download(String downloadDir) { + boolean downloadSucceeded = true; boolean unzipSucceeded = true; if (params.verify() - && new File(DOWNLOAD_DIR, getInstallerFileName(params.type())).exists()) { + && new File(downloadDir, getInstallerFileName(params.type())).exists()) { getLogger().fine("File {0} already exists.", getInstallerFileName(params.type())); } else { - // check and make sure DOWNLOAD_DIR exists; will create it if it is missing - checkDirectory(DOWNLOAD_DIR); - + // check and make sure downloadDir exists; will create it if it is missing + checkDirectory(downloadDir); + // we are about to download the installer. We need to get the real version that is requested try { - params.location(getActualLocationIfNeeded(params.location(), params.type())); + params.location(getActualLocationIfNeeded(params.location(), params.type(), downloadDir)); } catch (RuntimeException re) { // already logged return false; } - + downloadSucceeded = Command.withParams( - defaultCommandParams() - .command(buildDownloadCommand()) + defaultCommandParams() + .command(buildDownloadCommand(downloadDir)) .redirect(params.redirect())) .execute(); } if (params.unzip()) { // only unzip WIT once if (!(doesFileExist(IMAGE_TOOL)) || !(doesFileExist(REMOTECONSOLE_FILE))) { - unzipSucceeded = unzip(); + unzipSucceeded = unzip(downloadDir); } } return downloadSucceeded && unzipSucceeded; } - private boolean unzip() { + private boolean unzip(String downloadDir) { String command = String.format( "unzip -o -d %s %s/%s", WORK_DIR, - DOWNLOAD_DIR, + downloadDir, getInstallerFileName(params.type())); return Command.withParams( @@ -192,11 +196,11 @@ private boolean unzip() { .execute(); } - private String buildDownloadCommand() { + private String buildDownloadCommand(String downloadDir) { String command = String.format( "curl -fL %s -o %s/%s", params.location(), - DOWNLOAD_DIR, + downloadDir, getInstallerFileName(params.type())); return command; } @@ -211,7 +215,8 @@ private String buildDownloadCommand() { */ private String getActualLocationIfNeeded( String location, - String type + String type, + String downloadDir ) throws RuntimeException { String actualLocation = location; if (needToGetActualLocation(location, type)) { @@ -219,7 +224,7 @@ private String getActualLocationIfNeeded( String command = String.format( "curl -fL %s -o %s/%s-%s", location, - DOWNLOAD_DIR, + downloadDir, type, TMP_FILE_NAME); @@ -241,7 +246,7 @@ private String getActualLocationIfNeeded( command = String.format( "cat %s/%s-%s | grep 'releases/download' | awk '{ split($0,a,/href=\"/);%s | %s", - DOWNLOAD_DIR, + downloadDir, type, TMP_FILE_NAME, " print a[2] }'", diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java index 6910d77166b..c0e0ad350fd 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java @@ -36,6 +36,7 @@ import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.installWdtParams; import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger; import static org.apache.commons.io.FileUtils.cleanDirectory; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -323,20 +324,21 @@ public static boolean doesFileExistInPod(String namespace, String podName, Strin * @param unzipLocation location to unzip the files */ public static void unzipWDTInstallationFile(String unzipLocation) { - unzipWDTInstallationFile(unzipLocation, WDT_DOWNLOAD_URL, WDT_DOWNLOAD_FILENAME_DEFAULT); + unzipWDTInstallationFile(unzipLocation, WDT_DOWNLOAD_URL, DOWNLOAD_DIR); } /** * Download and unzip the WDT installation files. * @param unzipLocation location to unzip the files - * @param wdtFileName zip archive file name + * @param downloadDir location to download wdt zip file */ - public static void unzipWDTInstallationFile(String unzipLocation, String locationURL, String wdtFileName) { - Path wlDeployZipFile = Paths.get(DOWNLOAD_DIR, wdtFileName); + public static void unzipWDTInstallationFile(String unzipLocation, String locationURL, String downloadDir) { + Path wlDeployZipFile = Paths.get(downloadDir, WDT_DOWNLOAD_FILENAME_DEFAULT); + if (!Files.exists(wlDeployZipFile)) { assertTrue(Installer.withParams( installWdtParams(locationURL)) - .download(), "WDT download failed"); + .download(downloadDir), "WDT download failed"); } String cmdToExecute = String.format("unzip %s -d %s", wlDeployZipFile, unzipLocation); assertTrue(new Command() From 1c5d2104257a4bbfb0f5f200e0d3f551ac019a94 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Fri, 23 Jul 2021 02:40:54 +0000 Subject: [PATCH 8/9] style --- .../java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java | 2 +- .../kubernetes/actions/impl/primitive/Installer.java | 5 +++++ .../java/oracle/weblogic/kubernetes/utils/FileUtils.java | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java index 2339ee9c7db..1fdd06fcf25 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java @@ -958,7 +958,7 @@ public void testUpdateWDTVersionUsingMultipleAuxiliaryImages() { + WDT_TEST_VERSION + "/" + WDT_DOWNLOAD_FILENAME_DEFAULT; unzipWDTInstallationFile(multipleAIPath2.toString(), wdtURL, - DOWNLOAD_DIR + "/ver" +WDT_TEST_VERSION ); + DOWNLOAD_DIR + "/ver" + WDT_TEST_VERSION); // create image2 with wdt installation files only createAuxiliaryImage(multipleAIPath2.toString(), diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java index 494f0d1cb85..398daea7f35 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/Installer.java @@ -148,6 +148,11 @@ public boolean download() { return download(DOWNLOAD_DIR); } + /** + * Download and install the tool using the params. + * @param downloadDir download directory + * @return true if the command succeeds + */ public boolean download(String downloadDir) { boolean downloadSucceeded = true; diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java index c0e0ad350fd..40516e48e54 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/FileUtils.java @@ -36,7 +36,6 @@ import static oracle.weblogic.kubernetes.actions.impl.primitive.Installer.installWdtParams; import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger; import static org.apache.commons.io.FileUtils.cleanDirectory; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertTrue; /** From 6eb7431b64a806d9a5cdad3fa930d50d8ee5f251 Mon Sep 17 00:00:00 2001 From: Marina Kogan Date: Fri, 23 Jul 2021 20:52:56 +0000 Subject: [PATCH 9/9] corrected var name --- .../src/test/java/oracle/weblogic/kubernetes/TestConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java index d506017bee8..0b95074f1c1 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java @@ -241,7 +241,7 @@ public interface TestConstants { public static final String WDT_BASIC_IMAGE_DOMAINTYPE = "wdt"; public static final String WDT_BASIC_APP_NAME = "sample-app"; public static final String WDT_TEST_VERSION = Optional.ofNullable(System.getenv( - "WDT_VERSION")) + "WDT_TEST_VERSION")) .orElse("1.9.15"); //monitoring constants