Skip to content

Commit 3684926

Browse files
committed
fix testCreateDomainWithStartPolicyAdminOnly and push domain image to ocir
1 parent 59ee05a commit 3684926

File tree

3 files changed

+77
-27
lines changed

3 files changed

+77
-27
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ public static void initialize(String appPropsFile) throws Exception {
220220
"Env var IMAGE_PULL_SECRET_OPERATOR " + System.getenv("IMAGE_PULL_SECRET_OPERATOR"));
221221
logger.info(
222222
"Env var IMAGE_PULL_SECRET_WEBLOGIC " + System.getenv("IMAGE_PULL_SECRET_WEBLOGIC"));
223+
logger.info("Env var IMAGE_NAME_WEBLOGIC " + System.getenv("IMAGE_NAME_WEBLOGIC"));
224+
logger.info("Env var IMAGE_TAG_WEBLOGIC " + System.getenv("IMAGE_TAG_WEBLOGIC"));
225+
223226
logger.info("Env var BRANCH_NAME " + System.getenv("BRANCH_NAME"));
224227
}
225228

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,14 @@ public void testDomainInImageUsingWLST() throws Exception {
451451
Domain domain = null;
452452
boolean testCompletedSuccessfully = false;
453453
try {
454-
domain = TestUtils.createDomain(DOMAININIMAGE_WLST_YAML);
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+
}
461+
domain = TestUtils.createDomain(domainMap);
455462
domain.verifyDomainCreated();
456463

457464
testBasicUseCases(domain);
@@ -483,7 +490,13 @@ public void testDomainInImageUsingWDT() throws Exception {
483490
Domain domain = null;
484491
boolean testCompletedSuccessfully = false;
485492
try {
486-
domain = TestUtils.createDomain(DOMAININIMAGE_WDT_YAML);
493+
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAININIMAGE_WDT_YAML);
494+
if (SHARED_CLUSTER) {
495+
domainMap.put(
496+
"image", System.getenv("REPO_REGISTRY") + "/weblogick8s/domain-home-in-image:12.2.1.3");
497+
domainMap.put("imagePullSecretName", "ocir-domain");
498+
}
499+
domain = TestUtils.createDomain(domainMap);
487500
domain.verifyDomainCreated();
488501

489502
testBasicUseCases(domain);

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

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,6 @@ public void deletePVCAndCheckPVReleased() throws Exception {
636636
* @throws Exception
637637
*/
638638
public void createDomainOnExistingDirectory() throws Exception {
639-
String domainStoragePath = domainMap.get("weblogicDomainStoragePath").toString();
640-
String domainDir = domainStoragePath + "/domains/" + domainMap.get("domainUID").toString();
641639
String cmd =
642640
BaseTest.getProjectRoot()
643641
+ "/src/integration-tests/bash/krun.sh -m "
@@ -651,11 +649,7 @@ public void createDomainOnExistingDirectory() throws Exception {
651649
+ "\"";
652650
logger.info("making sure the domain directory exists by running " + cmd);
653651
ExecResult result = TestUtils.exec(cmd);
654-
logger.info("Command result " + result.stdout() + " err =" + result.stderr());
655-
/* if (domainDir != null && !(new File(domainDir).exists())) {
656-
throw new RuntimeException(
657-
"FAIL: the domain directory " + domainDir + " does not exist, exiting!");
658-
} */
652+
// logger.info("Command result " + result.stdout() + " err =" + result.stderr());
659653
logger.info("Run the script to create domain");
660654

661655
// create domain using different output dir but pv is same, it fails as the domain was already
@@ -1100,8 +1094,42 @@ protected void callCreateDomainScript(String outputDir) throws Exception {
11001094
String outputStr = result.stdout().trim();
11011095
logger.info("Command returned " + outputStr);
11021096

1097+
if (domainMap.containsKey("domainHomeImageBase") && BaseTest.SHARED_CLUSTER) {
1098+
String dockerLoginAndPushCmd =
1099+
"docker login "
1100+
+ System.getenv("REPO_REGISTRY")
1101+
+ " -u "
1102+
+ System.getenv("REPO_USERNAME")
1103+
+ " -p \""
1104+
+ System.getenv("REPO_PASSWORD")
1105+
+ "\" && docker push "
1106+
+ System.getenv("REPO_REGISTRY")
1107+
+ "/weblogick8s/domain-home-in-image:"
1108+
+ (System.getenv("IMAGE_TAG_WEBLOGIC") != null
1109+
? System.getenv("IMAGE_TAG_WEBLOGIC")
1110+
: "12.2.1.3");
1111+
result = TestUtils.exec(dockerLoginAndPushCmd);
1112+
logger.info(
1113+
"cmd "
1114+
+ dockerLoginAndPushCmd
1115+
+ "\n result "
1116+
+ result.stdout()
1117+
+ "\n err "
1118+
+ result.stderr());
1119+
1120+
// create ocir registry secret in the same ns as domain which is used while pulling the domain
1121+
// image
1122+
TestUtils.createDockerRegistrySecret(
1123+
"ocir-domain",
1124+
System.getenv("REPO_REGISTRY"),
1125+
System.getenv("REPO_USERNAME"),
1126+
System.getenv("REPO_PASSWORD"),
1127+
System.getenv("REPO_EMAIL"),
1128+
domainNS);
1129+
}
1130+
11031131
// write configOverride and configOverrideSecrets to domain.yaml
1104-
if (domainMap.containsKey("configOverrides")) {
1132+
if (domainMap.containsKey("configOverrides") || domainMap.containsKey("domainHomeImageBase")) {
11051133
appendToDomainYamlAndCreate();
11061134
}
11071135
}
@@ -1368,6 +1396,11 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
13681396
if (!domainMap.containsKey("domainHomeImageBase")) {
13691397
domainMap.put("domainHome", "/shared/domains/" + domainUid);
13701398
domainMap.put("image", imageName + ":" + imageTag);
1399+
if (System.getenv("IMAGE_PULL_SECRET_WEBLOGIC") != null) {
1400+
domainMap.put("imagePullSecretName", System.getenv("IMAGE_PULL_SECRET_WEBLOGIC"));
1401+
} else {
1402+
domainMap.put("imagePullSecretName", "docker-store");
1403+
}
13711404
}
13721405

13731406
if (domainMap.containsKey("domainHomeImageBuildPath")) {
@@ -1381,11 +1414,7 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
13811414
+ "/"
13821415
+ ((String) domainMap.get("domainHomeImageBuildPath")).trim());
13831416
}
1384-
if (System.getenv("IMAGE_PULL_SECRET_WEBLOGIC") != null) {
1385-
domainMap.put("imagePullSecretName", System.getenv("IMAGE_PULL_SECRET_WEBLOGIC"));
1386-
} else {
1387-
domainMap.put("imagePullSecretName", "docker-store");
1388-
}
1417+
13891418
// remove null values if any attributes
13901419
domainMap.values().removeIf(Objects::isNull);
13911420

@@ -1474,20 +1503,24 @@ private void gitCloneDockerImagesSample() throws Exception {
14741503
* command
14751504
*/
14761505
private void appendToDomainYamlAndCreate() throws Exception {
1477-
String contentToAppend =
1478-
" configOverrides: "
1479-
+ domainUid
1480-
+ "-"
1481-
+ domainMap.get("configOverrides")
1482-
+ "\n"
1483-
+ " configOverrideSecrets: [ \""
1484-
+ domainUid
1485-
+ "-test-secrets\" ]"
1486-
+ "\n";
14871506

14881507
String domainYaml =
14891508
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + domainUid + "/domain.yaml";
1490-
Files.write(Paths.get(domainYaml), contentToAppend.getBytes(), StandardOpenOption.APPEND);
1509+
1510+
if (domainMap.containsKey("configOverrides")) {
1511+
String contentToAppend =
1512+
" configOverrides: "
1513+
+ domainUid
1514+
+ "-"
1515+
+ domainMap.get("configOverrides")
1516+
+ "\n"
1517+
+ " configOverrideSecrets: [ \""
1518+
+ domainUid
1519+
+ "-test-secrets\" ]"
1520+
+ "\n";
1521+
1522+
Files.write(Paths.get(domainYaml), contentToAppend.getBytes(), StandardOpenOption.APPEND);
1523+
}
14911524

14921525
String command = "kubectl create -f " + domainYaml;
14931526
ExecResult result = TestUtils.exec(command);
@@ -1578,7 +1611,8 @@ private String prepareCmdToCallCreateDomainScript(String outputDir) {
15781611
createDomainScriptCmd.append(generatedInputYamlFile);
15791612

15801613
// skip executing yaml if configOverrides
1581-
if (!domainMap.containsKey("configOverrides")) {
1614+
if (!domainMap.containsKey("configOverrides")
1615+
&& !domainMap.containsKey("domainHomeImageBase")) {
15821616
createDomainScriptCmd.append(" -e ");
15831617
}
15841618

0 commit comments

Comments
 (0)