Skip to content

Commit 4486c10

Browse files
authored
Merge pull request #917 from oracle/add-newproperty-javatests
READY TO MERGE: Add new property createDomainPyScript to domain inputs in java tests
2 parents dbcfc81 + 2565080 commit 4486c10

File tree

8 files changed

+54
-286
lines changed

8 files changed

+54
-286
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
package oracle.kubernetes.operator;
66

7-
import java.io.File;
8-
import java.nio.file.Files;
9-
import java.nio.file.StandardCopyOption;
107
import java.util.Map;
118
import oracle.kubernetes.operator.utils.Domain;
129
import oracle.kubernetes.operator.utils.ExecCommand;
@@ -411,8 +408,6 @@ public void testAutoAndCustomSitConfigOverrides() throws Exception {
411408
}
412409
Domain domain11 = null;
413410
boolean testCompletedSuccessfully = false;
414-
String createDomainScriptDir =
415-
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv";
416411
try {
417412
// load input yaml to map and add configOverrides
418413
Map<String, Object> domainMap = TestUtils.loadYaml(domainonpvwlstFile);
@@ -423,33 +418,23 @@ public void testAutoAndCustomSitConfigOverrides() throws Exception {
423418
domainMap.put("domainUID", "customsitdomain");
424419
domainMap.put("adminNodePort", new Integer("30704"));
425420
domainMap.put("t3ChannelPort", new Integer("30051"));
421+
domainMap.put(
422+
"createDomainPyScript",
423+
"integration-tests/src/test/resources/domain-home-on-pv/create-domain-auto-custom-sit-config.py");
426424
domainMap.put("voyagerWebPort", new Integer("30312"));
425+
427426
// use NFS for this domain on Jenkins, defaultis HOST_PATH
428427
if (System.getenv("JENKINS") != null && System.getenv("JENKINS").equalsIgnoreCase("true")) {
429428
domainMap.put("weblogicDomainStorageType", "NFS");
430429
}
431430

432-
// cp py
433-
Files.copy(
434-
new File(createDomainScriptDir + "/create-domain.py").toPath(),
435-
new File(createDomainScriptDir + "/create-domain.py.bak").toPath(),
436-
StandardCopyOption.REPLACE_EXISTING);
437-
Files.copy(
438-
new File(createDomainScriptDir + "/create-domain-auto-custom-sit-config.py").toPath(),
439-
new File(createDomainScriptDir + "/create-domain.py").toPath(),
440-
StandardCopyOption.REPLACE_EXISTING);
441-
442431
domain11 = TestUtils.createDomain(domainMap);
443432
domain11.verifyDomainCreated();
444433
testBasicUseCases(domain11);
445434
testAdminT3ChannelWithJMS(domain11);
446435
testCompletedSuccessfully = true;
447436

448437
} finally {
449-
Files.copy(
450-
new File(createDomainScriptDir + "/create-domain.py.bak").toPath(),
451-
new File(createDomainScriptDir + "/create-domain.py").toPath(),
452-
StandardCopyOption.REPLACE_EXISTING);
453438
if (domain11 != null && (JENKINS || testCompletedSuccessfully)) {
454439
domain11.destroy();
455440
}

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,8 @@ private void createPV() throws Exception {
810810
InputStream pv_is =
811811
new FileInputStream(
812812
new File(
813-
BaseTest.getProjectRoot()
814-
+ "/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml"));
813+
BaseTest.getResultDir()
814+
+ "/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml"));
815815
pvMap = yaml.load(pv_is);
816816
pv_is.close();
817817
pvMap.put("domainUID", domainUid);
@@ -882,21 +882,38 @@ private void generateInputYaml() throws Exception {
882882
}
883883

884884
private void callCreateDomainScript(String outputDir) throws Exception {
885-
StringBuffer createDomainScriptCmd = new StringBuffer(BaseTest.getProjectRoot());
886885

886+
// copy create domain py script for domain on pv case
887+
if (domainMap.containsKey("createDomainPyScript")
888+
&& !domainMap.containsKey("domainHomeImageBase")) {
889+
Files.copy(
890+
new File(BaseTest.getProjectRoot() + "/" + domainMap.get("createDomainPyScript"))
891+
.toPath(),
892+
new File(
893+
BaseTest.getResultDir()
894+
+ "/samples/scripts/create-weblogic-domain/domain-home-on-pv/wlst/create-domain.py")
895+
.toPath(),
896+
StandardCopyOption.REPLACE_EXISTING);
897+
}
898+
899+
StringBuffer createDomainScriptCmd = new StringBuffer(BaseTest.getResultDir());
900+
901+
// call different create-domain.sh based on the domain type
887902
if (domainMap.containsKey("domainHomeImageBase")) {
888-
// clone docker sample from github
903+
904+
// clone docker sample from github and copy create domain py script for domain in image case
889905
gitCloneDockerImagesSample(domainMap);
906+
890907
createDomainScriptCmd
891908
.append(
892-
"/kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain.sh -u ")
909+
"/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain.sh -u ")
893910
.append(BaseTest.getUsername())
894911
.append(" -p ")
895912
.append(BaseTest.getPassword())
896913
.append(" -k -i ");
897914
} else {
898915
createDomainScriptCmd.append(
899-
"/kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain.sh -v -i ");
916+
"/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain.sh -v -i ");
900917
}
901918
createDomainScriptCmd.append(generatedInputYamlFile);
902919

@@ -1122,27 +1139,31 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
11221139
domainMap = inputDomainMap;
11231140
this.userProjectsDir = BaseTest.getUserProjectsDir();
11241141
this.projectRoot = BaseTest.getProjectRoot();
1142+
1143+
// copy samples to RESULT_DIR
1144+
TestUtils.exec(
1145+
"cp -rf " + BaseTest.getProjectRoot() + "/kubernetes/samples " + BaseTest.getResultDir());
1146+
11251147
this.voyager =
11261148
System.getenv("LB_TYPE") != null && System.getenv("LB_TYPE").equalsIgnoreCase("VOYAGER");
11271149
if (System.getenv("INGRESSPERDOMAIN") != null) {
11281150
INGRESSPERDOMAIN = new Boolean(System.getenv("INGRESSPERDOMAIN")).booleanValue();
11291151
}
1152+
11301153
domainMap.put("domainName", domainMap.get("domainUID"));
11311154

11321155
// read sample domain inputs
11331156
String sampleDomainInputsFile =
1134-
"/kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-inputs.yaml";
1157+
"/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-inputs.yaml";
11351158
if (domainMap.containsKey("domainHomeImageBase")) {
11361159
sampleDomainInputsFile =
1137-
"/kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain-inputs.yaml";
1160+
"/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain-inputs.yaml";
11381161
}
11391162
Yaml dyaml = new Yaml();
11401163
InputStream sampleDomainInputStream =
1141-
new FileInputStream(new File(BaseTest.getProjectRoot() + sampleDomainInputsFile));
1164+
new FileInputStream(new File(BaseTest.getResultDir() + sampleDomainInputsFile));
11421165
logger.info(
1143-
"loading domain inputs template file "
1144-
+ BaseTest.getProjectRoot()
1145-
+ sampleDomainInputsFile);
1166+
"loading domain inputs template file " + BaseTest.getResultDir() + sampleDomainInputsFile);
11461167
Map<String, Object> sampleDomainMap = dyaml.load(sampleDomainInputStream);
11471168
sampleDomainInputStream.close();
11481169

@@ -1183,9 +1204,9 @@ private void initialize(Map<String, Object> inputDomainMap) throws Exception {
11831204
domainMap.put("logHome", "/shared/logs/" + domainUid);
11841205
if (!domainMap.containsKey("domainHomeImageBase")) {
11851206
domainMap.put("domainHome", "/shared/domains/" + domainUid);
1186-
domainMap.put(
1187-
"createDomainFilesDir",
1188-
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv");
1207+
/* domainMap.put(
1208+
"createDomainFilesDir",
1209+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/domain-home-on-pv"); */
11891210
domainMap.put("image", imageName + ":" + imageTag);
11901211
}
11911212

@@ -1348,14 +1369,15 @@ private void gitCloneDockerImagesSample(Map domainMap) throws Exception {
13481369
+ " "
13491370
+ result.stdout());
13501371
}
1351-
// copy script to cloned location
1352-
Files.copy(
1353-
new File(
1354-
BaseTest.getProjectRoot()
1355-
+ "/integration-tests/src/test/resources/domain-home-on-image/create-wls-domain.py")
1356-
.toPath(),
1357-
new File(domainHomeImageBuildPath + "/container-scripts/create-wls-domain.py").toPath(),
1358-
StandardCopyOption.REPLACE_EXISTING);
1372+
1373+
// copy create domain py script to cloned location
1374+
if (domainMap.containsKey("createDomainPyScript")) {
1375+
Files.copy(
1376+
new File(BaseTest.getProjectRoot() + "/" + domainMap.get("createDomainPyScript"))
1377+
.toPath(),
1378+
new File(domainHomeImageBuildPath + "/container-scripts/create-wls-domain.py").toPath(),
1379+
StandardCopyOption.REPLACE_EXISTING);
1380+
}
13591381
}
13601382
}
13611383

integration-tests/src/test/java/oracle/kubernetes/operator/utils/PersistentVolume.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public PersistentVolume(String dirPath, Map pvMap) throws Exception {
4949

5050
// create PV/PVC
5151
String cmdPvPvc =
52-
BaseTest.getProjectRoot()
53-
+ "/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc.sh "
52+
BaseTest.getResultDir()
53+
+ "/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc.sh "
5454
+ " -i "
5555
+ parentDir
5656
+ "/"

0 commit comments

Comments
 (0)