Skip to content

Commit 4bf5bce

Browse files
committed
some refactoring
1 parent 9aaf7da commit 4bf5bce

File tree

4 files changed

+27
-33
lines changed

4 files changed

+27
-33
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static void initialize(String appPropsFile) throws Exception {
146146
+ clnResult.stderr());
147147
}
148148

149-
if (System.getenv("JENKINS") != null) {
149+
if (JENKINS) {
150150
logger.info("Deleting and creating " + resultRoot + "/acceptance_test_tmp");
151151
TestUtils.exec(
152152
"/usr/local/packages/aime/ias/run_as_root \"rm -rf "
@@ -186,7 +186,7 @@ public static void initialize(String appPropsFile) throws Exception {
186186
logger.info("Adding file handler, logging to file at " + resultDir + "/java_test_suite.out");
187187

188188
// for manual/local run, create file handler, create PVROOT
189-
if (System.getenv("JENKINS") == null) {
189+
if (!JENKINS) {
190190
logger.info("Creating PVROOT " + pvRoot);
191191
Files.createDirectories(Paths.get(pvRoot));
192192
ExecResult result = ExecCommand.exec("chmod -R 777 " + pvRoot);
@@ -704,9 +704,9 @@ public static void tearDown(String iTClassName) throws Exception {
704704

705705
if (JENKINS || SHARED_CLUSTER) {
706706
result = cleanup();
707-
// if (result.exitValue() != 0) {
708-
logger.info("cleanup result =" + result.stdout() + "\n " + result.stderr());
709-
// }
707+
if (result.exitValue() != 0) {
708+
logger.info("cleanup result =" + result.stdout() + "\n " + result.stderr());
709+
}
710710
}
711711

712712
if (getLeaseId() != "") {

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -451,15 +451,7 @@ public void testDomainInImageUsingWLST() throws Exception {
451451
Domain domain = null;
452452
boolean testCompletedSuccessfully = false;
453453
try {
454-
455-
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAININIMAGE_WLST_YAML);
456-
if (SHARED_CLUSTER) {
457-
domainMap.put(
458-
"image", System.getenv("REPO_REGISTRY") + "/weblogick8s/domain-home-in-image:12.2.1.3");
459-
domainMap.put("imagePullSecretName", "ocir-domain");
460-
domainMap.put("imagePullPolicy", "Always");
461-
}
462-
domain = TestUtils.createDomain(domainMap);
454+
domain = TestUtils.createDomain(DOMAININIMAGE_WLST_YAML);
463455
domain.verifyDomainCreated();
464456

465457
testBasicUseCases(domain);
@@ -491,14 +483,7 @@ public void testDomainInImageUsingWDT() throws Exception {
491483
Domain domain = null;
492484
boolean testCompletedSuccessfully = false;
493485
try {
494-
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAININIMAGE_WDT_YAML);
495-
if (SHARED_CLUSTER) {
496-
domainMap.put(
497-
"image", System.getenv("REPO_REGISTRY") + "/weblogick8s/domain-home-in-image:12.2.1.3");
498-
domainMap.put("imagePullSecretName", "ocir-domain");
499-
domainMap.put("imagePullPolicy", "Always");
500-
}
501-
domain = TestUtils.createDomain(domainMap);
486+
domain = TestUtils.createDomain(DOMAININIMAGE_WDT_YAML);
502487
domain.verifyDomainCreated();
503488

504489
testBasicUseCases(domain);

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public class Domain {
6161
protected String userProjectsDir = "";
6262
private String projectRoot = "";
6363
private boolean ingressPerDomain = true;
64+
private String imageTag = "12.2.1.3";
65+
private String imageName = "store/oracle/weblogic";
6466

6567
protected String generatedInputYamlFile;
6668

@@ -671,6 +673,8 @@ public void deletePVCAndCheckPVReleased(String jobName) throws Exception {
671673
* @throws Exception
672674
*/
673675
public void createDomainOnExistingDirectory() throws Exception {
676+
677+
// use krun.sh so that the dir check can work on shared cluster/remote k8s cluster env as well
674678
String cmd =
675679
BaseTest.getProjectRoot()
676680
+ "/src/integration-tests/bash/krun.sh -m "
@@ -1129,13 +1133,10 @@ protected void callCreateDomainScript(String outputDir) throws Exception {
11291133
String outputStr = result.stdout().trim();
11301134
logger.info("Command returned " + outputStr);
11311135

1136+
// for remote k8s cluster and domain in image case, push the domain image to OCIR
11321137
if (domainMap.containsKey("domainHomeImageBase") && BaseTest.SHARED_CLUSTER) {
11331138
String image =
1134-
System.getenv("REPO_REGISTRY")
1135-
+ "/weblogick8s/domain-home-in-image:"
1136-
+ (System.getenv("IMAGE_TAG_WEBLOGIC") != null
1137-
? System.getenv("IMAGE_TAG_WEBLOGIC")
1138-
: "12.2.1.3");
1139+
System.getenv("REPO_REGISTRY") + "/weblogick8s/domain-home-in-image:" + imageTag;
11391140
TestUtils.loginAndPushImageToOCIR(image);
11401141

11411142
// create ocir registry secret in the same ns as domain which is used while pulling the domain
@@ -1149,7 +1150,7 @@ protected void callCreateDomainScript(String outputDir) throws Exception {
11491150
domainNS);
11501151
}
11511152

1152-
// write configOverride and configOverrideSecrets to domain.yaml
1153+
// write configOverride and configOverrideSecrets to domain.yaml and/or create domain
11531154
if (domainMap.containsKey("configOverrides") || domainMap.containsKey("domainHomeImageBase")) {
11541155
appendToDomainYamlAndCreate();
11551156
}
@@ -1423,13 +1424,11 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
14231424
domainMap.put("t3PublicAddress", TestUtils.getHostName());
14241425
}
14251426

1426-
String imageName = "store/oracle/weblogic";
14271427
if (System.getenv("IMAGE_NAME_WEBLOGIC") != null) {
14281428
imageName = System.getenv("IMAGE_NAME_WEBLOGIC");
14291429
logger.info("IMAGE_NAME_WEBLOGIC " + imageName);
14301430
}
14311431

1432-
String imageTag = "12.2.1.3";
14331432
if (System.getenv("IMAGE_TAG_WEBLOGIC") != null) {
14341433
imageTag = System.getenv("IMAGE_TAG_WEBLOGIC");
14351434
logger.info("IMAGE_TAG_WEBLOGIC " + imageTag);
@@ -1443,6 +1442,16 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
14431442
} else {
14441443
domainMap.put("imagePullSecretName", "docker-store");
14451444
}
1445+
} else {
1446+
// use default image attibute value for JENKINS and standalone runs and for SHARED_CLUSTER use
1447+
// below
1448+
if (BaseTest.SHARED_CLUSTER) {
1449+
domainMap.put(
1450+
"image",
1451+
System.getenv("REPO_REGISTRY") + "/weblogick8s/domain-home-in-image:" + imageTag);
1452+
domainMap.put("imagePullSecretName", "ocir-domain");
1453+
domainMap.put("imagePullPolicy", "Always");
1454+
}
14461455
}
14471456

14481457
if (domainMap.containsKey("domainHomeImageBuildPath")) {
@@ -1661,7 +1670,7 @@ private String prepareCmdToCallCreateDomainScript(String outputDir) {
16611670
}
16621671
createDomainScriptCmd.append(generatedInputYamlFile);
16631672

1664-
// skip executing yaml if configOverrides
1673+
// skip executing yaml if configOverrides or domain in image
16651674
if (!domainMap.containsKey("configOverrides")
16661675
&& !domainMap.containsKey("domainHomeImageBase")) {
16671676
createDomainScriptCmd.append(" -e ");

integration-tests/src/test/resources/statedump.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ function state_dump {
9999
echo "Running $SCRIPTPATH/krun.sh -i openjdk:11-oracle -t 300 -d ${RESULT_DIR} -m ${PV_ROOT}:/sharedparent -c 'jar cf /sharedparent/pvarchive.jar /sharedparent/acceptance_test_pv' 2>&1 | tee ${outfile}"
100100
$SCRIPTPATH/krun.sh -i openjdk:11-oracle -t 300 -d ${RESULT_DIR} -m "${PV_ROOT}:/sharedparent" -c 'jar cf /sharedparent/pvarchive.jar /sharedparent/acceptance_test_pv' 2>&1 | tee ${outfile}
101101
if [ "$?" = "0" ]; then
102-
echo "Running $SCRIPTPATH/krun.sh -i openjdk:11-oracle -t 300 -d ${RESULT_DIR} -m ${PV_ROOT}:/sharedparent -c 'base64 /sharedparent/pvarchive.jar' > $RESULT_DIR/pvarchive.b64 2>&1"
102+
#echo "Running $SCRIPTPATH/krun.sh -i openjdk:11-oracle -t 300 -d ${RESULT_DIR} -m ${PV_ROOT}:/sharedparent -c 'base64 /sharedparent/pvarchive.jar' > $RESULT_DIR/pvarchive.b64 2>&1"
103103
$SCRIPTPATH/krun.sh -i openjdk:11-oracle -t 300 -d ${RESULT_DIR} -m "${PV_ROOT}:/sharedparent" -c 'base64 /sharedparent/pvarchive.jar' > $RESULT_DIR/pvarchive.b64 2>&1
104104
if [ "$?" = "0" ]; then
105-
echo "Running base64 -di $RESULT_DIR/pvarchive.b64 > $ARCHIVE"
105+
#echo "Running base64 -di $RESULT_DIR/pvarchive.b64 > $ARCHIVE"
106106
base64 -di $RESULT_DIR/pvarchive.b64 > $ARCHIVE
107107
if [ "$?" = "0" ]; then
108108
echo Run complete. Archived to $ARCHIVE

0 commit comments

Comments
 (0)