Skip to content

Commit 838ed0d

Browse files
committed
push image to ocir for pod restart test
1 parent 250ece7 commit 838ed0d

File tree

4 files changed

+56
-26
lines changed

4 files changed

+56
-26
lines changed

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,38 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
200200
+ domain.getDomainUid()
201201
+ " Image property: store/oracle/weblogic:12.2.1.3 to store/oracle/weblogic:duplicate");
202202

203-
TestUtils.exec("docker tag store/oracle/weblogic:12.2.1.3 store/oracle/weblogic:duplicate");
204-
domain.verifyDomainServerPodRestart(
205-
"\"store/oracle/weblogic:12.2.1.3\"", "\"store/oracle/weblogic:duplicate\"");
203+
if (BaseTest.SHARED_CLUSTER) {
204+
String newImage =
205+
System.getenv("REPO_REGISTRY") + "/weblogick8s/store/oracle/weblogic:duplicate";
206+
207+
// tag image with repo name
208+
TestUtils.exec("docker tag store/oracle/weblogic:12.2.1.3 " + newImage);
209+
210+
// login and push image to ocir
211+
TestUtils.loginAndPushImageToOCIR(newImage);
212+
213+
// create ocir registry secret in the same ns as domain which is used while pulling the
214+
// image
215+
TestUtils.createDockerRegistrySecret(
216+
"docker-store",
217+
System.getenv("REPO_REGISTRY"),
218+
System.getenv("REPO_USERNAME"),
219+
System.getenv("REPO_PASSWORD"),
220+
System.getenv("REPO_EMAIL"),
221+
domain.getDomainNS());
222+
223+
// apply new domain yaml and verify pod restart
224+
domain.verifyDomainServerPodRestart(
225+
"\"store/oracle/weblogic:12.2.1.3\"", "\"" + newImage + "\"");
226+
} else {
227+
TestUtils.exec("docker tag store/oracle/weblogic:12.2.1.3 store/oracle/weblogic:duplicate");
228+
domain.verifyDomainServerPodRestart(
229+
"\"store/oracle/weblogic:12.2.1.3\"", "\"store/oracle/weblogic:duplicate\"");
230+
}
206231
} finally {
207-
TestUtils.exec("docker rmi -f store/oracle/weblogic:duplicate");
232+
if (!BaseTest.SHARED_CLUSTER) {
233+
TestUtils.exec("docker rmi -f store/oracle/weblogic:duplicate");
234+
}
208235
}
209236

210237
logger.info("SUCCESS - " + testMethodName);

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,27 +1095,13 @@ protected void callCreateDomainScript(String outputDir) throws Exception {
10951095
logger.info("Command returned " + outputStr);
10961096

10971097
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")
1098+
String image =
1099+
System.getenv("REPO_REGISTRY")
11071100
+ "/weblogick8s/domain-home-in-image:"
11081101
+ (System.getenv("IMAGE_TAG_WEBLOGIC") != null
11091102
? System.getenv("IMAGE_TAG_WEBLOGIC")
11101103
: "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());
1104+
TestUtils.loginAndPushImageToOCIR(image);
11191105

11201106
// create ocir registry secret in the same ns as domain which is used while pulling the domain
11211107
// image

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,4 +1337,25 @@ public static void buildDeployWebServiceAppInPod(
13371337
domain.callShellScriptToBuildDeployAppInPod(
13381338
appName, scriptName, username, password, clusterURL, wsServiceName);
13391339
}
1340+
1341+
public static ExecResult loginAndPushImageToOCIR(String image) throws Exception {
1342+
String dockerLoginAndPushCmd =
1343+
"docker login "
1344+
+ System.getenv("REPO_REGISTRY")
1345+
+ " -u "
1346+
+ System.getenv("REPO_USERNAME")
1347+
+ " -p \""
1348+
+ System.getenv("REPO_PASSWORD")
1349+
+ "\" && docker push "
1350+
+ image;
1351+
ExecResult result = TestUtils.exec(dockerLoginAndPushCmd);
1352+
logger.info(
1353+
"cmd "
1354+
+ dockerLoginAndPushCmd
1355+
+ "\n result "
1356+
+ result.stdout()
1357+
+ "\n err "
1358+
+ result.stderr());
1359+
return result;
1360+
}
13401361
}

src/integration-tests/bash/cleanup.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,7 @@ if [ "${DELETE_FILES:-true}" = "true" ]; then
351351

352352
echo @@ Launching run to delete all pv contents. This runs in the k8s cluster, /sharedparent mounts PV_ROOT.
353353
# $SCRIPTPATH/job.sh "rm -fr /scratch/acceptance_test_pv"
354-
if [ "$SHARED_CLUSTER" = "true" ]; then
355-
$SCRIPTPATH/job.sh "rm -fr /scratch/acceptance_test_pv"
356-
else
357-
$SCRIPTPATH/krun.sh -i openjdk:11-oracle -m "${PV_ROOT}:/sharedparent" -c 'rm -fr /sharedparent/acceptance_test_pv'
358-
fi
354+
$SCRIPTPATH/krun.sh -i openjdk:11-oracle -m "${PV_ROOT}:/sharedparent" -c 'rm -fr /sharedparent/acceptance_test_pv'
359355
[ "$?" = "0" ] || SUCCESS="1"
360356
echo @@ SUCCESS=$SUCCESS
361357

0 commit comments

Comments
 (0)