Skip to content

Commit 3dd568f

Browse files
committedApr 14, 2024
Merge branch 'fix-jar-installer' into 'main'
Fix jar installer See merge request weblogic-cloud/weblogic-image-tool!472
2 parents 937febf + b4b2f5f commit 3dd568f

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed
 

‎imagetool/src/main/resources/docker-files/install-middleware.mustache

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN mkdir -p {{{oracle_home}}} \
2424
{{#installJava}}COPY --from=jdk_build --chown={{userid}}:{{groupid}} {{{java_home}}} {{{java_home}}}/
2525
{{/installJava}}
2626

27-
{{#installPackages}}COPY --chown={{userid}}:{{groupid}} {{installerFilename}} {{responseFile.name}} {{{tempDir}}}/
27+
{{#installPackages}}COPY --chown={{userid}}:{{groupid}} {{installerFilename}} {{responseFile.name}} {{{tempDir}}}/{{{type}}}/
2828
{{/installPackages}}
2929
COPY --chown={{userid}}:{{groupid}} oraInst.loc {{inv_loc}}/
3030

@@ -38,19 +38,19 @@ RUN echo "INSTALLING MIDDLEWARE" \
3838
{{#installPackages}}
3939
&& echo "INSTALLING {{type}}" \
4040
# If installer is packaged in a ZIP, extract it before running it
41-
{{#isZip}}&& unzip -q {{{tempDir}}}/{{installerFilename}} -d {{{tempDir}}}/{{{type}}} {{/isZip}} \
41+
{{#isZip}}&& unzip -q {{{tempDir}}}/{{{type}}}/{{installerFilename}} -d {{{tempDir}}}/{{{type}}} {{/isZip}} \
4242
{{#preinstallCommands}}&& {{{tempDir}}}/{{{type}}}/{{{.}}} {{/preinstallCommands}} \
4343
# IF the installer is a JAR file (not a .bin), run the silent install using Java
4444
{{^isBin}} && {{{java_home}}}/bin/java -Xmx1024m -jar {{{tempDir}}}/{{{type}}}/{{jarName}} \
4545
-silent ORACLE_HOME={{{oracle_home}}} \
46-
-responseFile {{{tempDir}}}/{{responseFile.name}} \
46+
-responseFile {{{tempDir}}}/{{{type}}}/{{responseFile.name}} \
4747
-invPtrLoc {{inv_loc}}/oraInst.loc \
4848
-ignoreSysPrereqs -force -novalidation {{/isBin}} \
4949
# If the installer is a BIN, make sure it is executable and run the installer
5050
{{#isBin}} && chmod +x {{{tempDir}}}/{{{type}}}/{{jarName}} \
5151
&& {{{tempDir}}}/{{{type}}}/{{jarName}} \
5252
-force -ignoreSysPrereqs -silent \
53-
-responseFile {{{tempDir}}}/{{responseFile.name}} \
53+
-responseFile {{{tempDir}}}/{{{type}}}/{{responseFile.name}} \
5454
-invPtrLoc {{inv_loc}}/oraInst.loc ORACLE_HOME={{{oracle_home}}} -jreLoc {{{java_home}}} {{/isBin}} \
5555
{{/installPackages}}
5656
&& test $? -eq 0 \

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

+40-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static void validateEnvironmentSettings() {
104104
missingSettings.add("STAGING_DIR");
105105
}
106106

107-
if (missingSettings.size() > 0) {
107+
if (!missingSettings.isEmpty()) {
108108
String error = String.join(", ", missingSettings)
109109
+ " must be set as a system property in the pom.xml";
110110
throw new IllegalArgumentException(error);
@@ -145,7 +145,7 @@ private static void verifyStagedFiles(String... installers) {
145145
missingInstallers.add(installer);
146146
}
147147
}
148-
if (missingInstallers.size() > 0) {
148+
if (!missingInstallers.isEmpty()) {
149149
String error = "Could not find these installers in the staging directory: " + STAGING_DIR + "\n ";
150150
error += String.join("\n ", missingInstallers);
151151
throw new IllegalStateException(error);
@@ -1162,4 +1162,42 @@ void createWlsImgWithOpenShiftSettings(TestInfo testInfo) throws Exception {
11621162
}
11631163

11641164
}
1165+
1166+
/**
1167+
* create a WLS image using a JAR installer not in a zip.
1168+
*
1169+
* @throws Exception - if any error occurs
1170+
*/
1171+
@Test
1172+
@Order(31)
1173+
@Tag("nightly")
1174+
@DisplayName("Create WebLogic Server image from a JAR")
1175+
void createWlsImgFromJar(TestInfo testInfo) throws Exception {
1176+
// Create an imagetool command to cache the JAR installer for 12.2.1.4.0
1177+
String cacheCommand = new CacheCommand()
1178+
.addInstaller(true)
1179+
.type("wls")
1180+
.version("12.2.1.4.0")
1181+
.path(Paths.get(STAGING_DIR, "fmw_12.2.1.4.0_wls_lite_generic.jar"))
1182+
.build();
1183+
1184+
// Create an imagetool command to build the image for 12.2.1.4.0
1185+
String tagName = build_tag + ":" + getMethodName(testInfo);
1186+
String buildCommand = new CreateCommand()
1187+
.tag(tagName)
1188+
.version("12.2.1.4.0")
1189+
.build();
1190+
1191+
try (PrintWriter out = getTestMethodWriter(testInfo)) {
1192+
// run imagetool cache command
1193+
CommandResult cacheResult = Runner.run(cacheCommand, out, logger);
1194+
assertEquals(0, cacheResult.exitValue(), "for command: " + cacheCommand);
1195+
// run imagetool build command
1196+
CommandResult buildResult = Runner.run(buildCommand, out, logger);
1197+
assertEquals(0, buildResult.exitValue(), "for command: " + buildCommand);
1198+
1199+
// verify that the container image was created
1200+
assertTrue(imageExists(tagName), "Image was not created: " + tagName);
1201+
}
1202+
}
11651203
}

0 commit comments

Comments
 (0)
Please sign in to comment.