Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ private static Map<String,String> 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");
}
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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 '<max-dynamic-cluster-size>4</max-dynamic-cluster-size>' " + domainParentDir + FS +
String cmd = "grep -q '<max-dynamic-cluster-size>4</max-dynamic-cluster-size>' " + 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");
Expand Down Expand Up @@ -840,19 +846,20 @@ 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
+ " -oracle_home " + mwhome_12213
+ " -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
Expand Down Expand Up @@ -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");
Expand All @@ -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 | "
Expand All @@ -910,7 +917,8 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception {
assertEquals(0, result.exitValue(), "Unexpected return code for untargeting app");
assertTrue(result.stdout().contains("<remove_app_from_deployment> <WLSDPLY-09339>"),
"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");
Expand All @@ -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> <WLSDPLY-09316>"),
"Update does not contains expected message WLSDPLY-09316");
assertTrue(result.stdout().contains("<__start_app> <WLSDPLY-09313>"),
"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);
Expand All @@ -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> <WLSDPLY-09312>"),
Expand Down Expand Up @@ -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");
}
Expand All @@ -989,19 +998,21 @@ 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");

// 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");

Expand All @@ -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
Expand All @@ -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;
Expand Down