Skip to content

Commit 2cd4fd5

Browse files
authored
Merge pull request #212 from oracle/java-home-update-image
Java home update image
2 parents 3c1f2bc + cc41e33 commit 2cd4fd5

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/UpdateImage.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public CommandResponse call() throws Exception {
6262

6363
Properties baseImageProperties = Utils.getBaseImageProperties(fromImage, tmpDir);
6464

65+
dockerfileOptions.setJavaHome(baseImageProperties.getProperty("JAVA_HOME", null));
66+
6567
String oracleHome = baseImageProperties.getProperty("ORACLE_HOME", null);
6668
if (oracleHome == null) {
6769
return new CommandResponse(-1, "IMG-0072", fromImage);

tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ static void staticUnprepare() throws Exception {
243243

244244
/**
245245
* Create the log directory in ./target (build folder), and open a new file using the test method's name.
246+
*
246247
* @param testInfo metadata from the test to be logged
247248
* @return an output file wrapped in a PrintWriter
248249
* @throws IOException if the PrintWriter fails to open the file
@@ -881,4 +882,59 @@ void createWlsImgWithAdditionalBuildCommands(TestInfo testInfo) throws Exception
881882
assertTrue(inspect.stdout().contains("final-build-commands:finalBuildCommands"),
882883
tagName + " does not contain the expected label");
883884
}
885+
886+
/**
887+
* Create a WLS image using Java Server JRE image as a base.
888+
* This tests that the JAVA_HOME is correctly identified and applied in the CREATE.
889+
*
890+
* @throws Exception - if any error occurs
891+
*/
892+
@Test
893+
@Order(26)
894+
@Tag("nightly")
895+
@DisplayName("Create image with WLS using Java ServerJRE")
896+
void createImageWithServerJRE(TestInfo testInfo) throws Exception {
897+
String tagName = build_tag + ":" + getMethodName(testInfo);
898+
String command = new CreateCommand()
899+
.tag(tagName)
900+
.fromImage("container-registry.oracle.com/java/serverjre:8")
901+
.build();
902+
903+
try (PrintWriter out = getTestMethodWriter(testInfo)) {
904+
CommandResult result = Runner.run(command, out, logger);
905+
assertEquals(0, result.exitValue(), "for command: " + command);
906+
907+
// verify the docker image is created
908+
String imageId = Runner.run("docker images -q " + tagName, out, logger).stdout().trim();
909+
assertFalse(imageId.isEmpty(), "Image was not created: " + tagName);
910+
}
911+
}
912+
913+
/**
914+
* Update the WLS image created in the previous test.
915+
* This tests that the JAVA_HOME is correctly identified and applied in the UPDATE.
916+
*
917+
* @throws Exception - if any error occurs
918+
*/
919+
@Test
920+
@Order(27)
921+
@Tag("nightly")
922+
@DisplayName("Update image with WLS using Java ServerJRE")
923+
void updateImageWithServerJRE(TestInfo testInfo) throws Exception {
924+
String tagName = build_tag + ":" + getMethodName(testInfo);
925+
String command = new UpdateCommand()
926+
.fromImage(build_tag + ":createImageWithServerJRE")
927+
.tag(tagName)
928+
.patches(P27342434_ID)
929+
.build();
930+
931+
try (PrintWriter out = getTestMethodWriter(testInfo)) {
932+
CommandResult result = Runner.run(command, out, logger);
933+
assertEquals(0, result.exitValue(), "for command: " + command);
934+
935+
// verify the docker image is created
936+
String imageId = Runner.run("docker images -q " + tagName, out, logger).stdout().trim();
937+
assertFalse(imageId.isEmpty(), "Image was not created: " + tagName);
938+
}
939+
}
884940
}

0 commit comments

Comments
 (0)