diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java index 60a2bb8e8f..fd321081fb 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java @@ -93,6 +93,10 @@ private static Map getTestMethodEnvironment(TestInfo testInfo) th } private static PrintWriter getTestMethodWriter(TestInfo testInfo) throws IOException { + return getTestMethodWriter(testInfo, ""); + } + + private static PrintWriter getTestMethodWriter(TestInfo testInfo, String suffixName) throws IOException { if (!testInfo.getTestMethod().isPresent()) { throw new IllegalArgumentException("Method is not present in this context, and this method cannot be used"); } @@ -103,7 +107,8 @@ private static PrintWriter getTestMethodWriter(TestInfo testInfo) throws IOExcep logger.info("Test log: " + outputPath); return new PrintWriter( new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(outputPath.resolve(Paths.get(methodName + ".out")).toString()))), true); + new FileOutputStream(outputPath.resolve(Paths.get(methodName + + suffixName + ".out")).toString()))), true); } /** @@ -504,13 +509,13 @@ void test17DiscoverDomainWithRequiredArgument(TestInfo testInfo) throws Exceptio domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -model_file " + getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + " -domain_type RestrictedJRF"; - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code"); discover17DomainCreated = true; } - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); cmd = discoverDomainScript @@ -618,7 +623,7 @@ private void verifyGDiscoverDomainWithVariableFile(String expectedModelFile) thr void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); waitForDatabase(); - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { Path source = Paths.get(getSampleModelFile("2")); Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); // create wdt model file to use in create, after substitution of DB host/ip @@ -631,7 +636,7 @@ void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code"); } - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredJRFD1.yaml"); String cmd = discoverDomainScript @@ -672,7 +677,7 @@ private void verifyHDiscoverDomainJRFDomainType(String expectedModelFile) { @Test void test21UpdateDomain(TestInfo testInfo) throws Exception { assumeTrue(test11DomainCreated, "Skipping test 21 because dependent domain was not created"); - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain")) { Path source = Paths.get(getSampleVariableFile()); Path variableFile = getTestOutputPath(testInfo).resolve(SAMPLE_VARIABLE_FILE); @@ -689,9 +694,10 @@ void test21UpdateDomain(TestInfo testInfo) throws Exception { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); verifyResult(result, "updateDomain.sh completed successfully"); - + } + try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { // Expecting grep return code of 0. Grep will return 0 if found, and 1 if the requested text is not found. - cmd = "grep -q '4' " + domainParentDir + FS + + String cmd = "grep -q '4' " + domainParentDir + FS + "domain2" + FS + "config" + FS + "config.xml"; CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result2.exitValue(), "config.xml does not appear to reflect the update"); @@ -840,9 +846,9 @@ void test28ValidateModelWithInvalidModelfile(TestInfo testInfo) throws Exception @Tag("gate") @Test void test29EncryptModel(TestInfo testInfo) throws Exception { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - Path source = Paths.get(getSampleModelFile("-constant")); - Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-constant.yaml"); + Path source = Paths.get(getSampleModelFile("-constant")); + Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-constant.yaml"); + try (PrintWriter out = getTestMethodWriter(testInfo, "EncryptModel")) { Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); String cmd = encryptModelScript @@ -850,9 +856,10 @@ void test29EncryptModel(TestInfo testInfo) throws Exception { + " -model_file " + model + " < " + getResourcePath().resolve("passphrase.txt"); CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); verifyResult(result, "encryptModel.sh completed successfully"); - + } + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { // create the domain using -use_encryption - cmd = createDomainScript + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + domainParentDir + FS + "domain10" + " -model_file " + model @@ -880,7 +887,7 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { + " -model_file " + getSampleModelFile("-onlinebase") + " -archive_file " + getSampleArchiveFile(); - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code"); assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); @@ -891,11 +898,11 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); boolean isServerUp = startAdminServer(domainHome, adminServerOut); + Path source = Paths.get(getSampleModelFile("-untargetapp")); + Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); if (isServerUp) { - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-1")) { // update wdt model file - Path source = Paths.get(getSampleModelFile("-untargetapp")); - Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); cmd = "echo welcome1 | " @@ -910,7 +917,8 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { assertEquals(0, result.exitValue(), "Unexpected return code for untargeting app"); assertTrue(result.stdout().contains(" "), "Update does not contains expected message WLSDPLY-09339"); - + } + try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-2")) { // Check result source = Paths.get(getSampleModelFile("-targetapp")); model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); @@ -923,14 +931,15 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { + " -model_file " + model + " -archive_file " + getSampleArchiveFile() + " -admin_url t3://localhost:7001 -admin_user weblogic"; - result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code for targeting app"); assertTrue(result.stdout().contains("<__deploy_app_online> "), "Update does not contains expected message WLSDPLY-09316"); assertTrue(result.stdout().contains("<__start_app> "), "Update does not contains expected message WLSDPLY-09313"); - + } + try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-online")) { source = Paths.get(getSampleModelFile("-targetapp")); model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); @@ -942,7 +951,7 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { + " -model_file " + model + " -archive_file " + getUpdatedSampleArchiveFile() + " -admin_url t3://localhost:7001 -admin_user weblogic"; - result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code for updating domain with new archive"); assertTrue(result.stdout().contains("<__stop_app> "), @@ -979,7 +988,7 @@ void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { + " -model_file " + getSampleModelFile("-onlinebase") + " -archive_file " + getSampleArchiveFile(); - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code"); } @@ -989,7 +998,7 @@ void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + domainParentDir + FS + "domain2-discover31 -archive_file " + discoveredArchive + " -model_file " + discoveredModelFile + " -variable_file " + discoveredVariableFile; - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); verifyResult(result, "discoverDomain.sh completed successfully"); @@ -997,11 +1006,13 @@ void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { // verify model file verifyModelFile(discoveredModelFile.toString()); + } + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomainFromDiscover")) { String domainHome = domainParentDir + FS + "createDomainFromDiscover"; cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + domainHome + " -archive_file " + discoveredArchive + " -model_file " + discoveredModelFile + " -variable_file " + getSampleVariableFile(); - result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); verifyResult(result, "createDomain.sh completed successfully"); @@ -1025,9 +1036,9 @@ void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { @Test void test32PrepareModel(TestInfo testInfo) throws Exception { - try (PrintWriter out = getTestMethodWriter(testInfo)) { + Path outputFiles = getTestOutputPath(testInfo); + try (PrintWriter out = getTestMethodWriter(testInfo, "PrepareModel")) { String wkoModelFile = getSampleModelFile("-targetwko"); - Path outputFiles = getTestOutputPath(testInfo); String cmd = prepareModelScript + " -oracle_home " + mwhome_12213 + " -output_dir " + outputFiles @@ -1037,10 +1048,11 @@ void test32PrepareModel(TestInfo testInfo) throws Exception { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); // ListenPort differences warning assertEquals(1, result.exitValue(), "Unexpected return code"); - + } + try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { // verify model file String tempWkoModel = outputFiles + FS + "simple-topology-targetwko.yaml"; - cmd = "grep \"PasswordEncrypted: '@@SECRET\" " + tempWkoModel; + String cmd = "grep \"PasswordEncrypted: '@@SECRET\" " + tempWkoModel; CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result2.exitValue(), "Missing JDBC Secret"); cmd = "grep -c 'Machine' " + tempWkoModel;