Skip to content

Commit

Permalink
Merge branch 'fix-jar-installer' into 'main'
Browse files Browse the repository at this point in the history
Fix jar installer

See merge request weblogic-cloud/weblogic-image-tool!472
  • Loading branch information
ddsharpe committed Apr 14, 2024
2 parents 937febf + b4b2f5f commit 3dd568f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir -p {{{oracle_home}}} \
{{#installJava}}COPY --from=jdk_build --chown={{userid}}:{{groupid}} {{{java_home}}} {{{java_home}}}/
{{/installJava}}

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

Expand All @@ -38,19 +38,19 @@ RUN echo "INSTALLING MIDDLEWARE" \
{{#installPackages}}
&& echo "INSTALLING {{type}}" \
# If installer is packaged in a ZIP, extract it before running it
{{#isZip}}&& unzip -q {{{tempDir}}}/{{installerFilename}} -d {{{tempDir}}}/{{{type}}} {{/isZip}} \
{{#isZip}}&& unzip -q {{{tempDir}}}/{{{type}}}/{{installerFilename}} -d {{{tempDir}}}/{{{type}}} {{/isZip}} \
{{#preinstallCommands}}&& {{{tempDir}}}/{{{type}}}/{{{.}}} {{/preinstallCommands}} \
# IF the installer is a JAR file (not a .bin), run the silent install using Java
{{^isBin}} && {{{java_home}}}/bin/java -Xmx1024m -jar {{{tempDir}}}/{{{type}}}/{{jarName}} \
-silent ORACLE_HOME={{{oracle_home}}} \
-responseFile {{{tempDir}}}/{{responseFile.name}} \
-responseFile {{{tempDir}}}/{{{type}}}/{{responseFile.name}} \
-invPtrLoc {{inv_loc}}/oraInst.loc \
-ignoreSysPrereqs -force -novalidation {{/isBin}} \
# If the installer is a BIN, make sure it is executable and run the installer
{{#isBin}} && chmod +x {{{tempDir}}}/{{{type}}}/{{jarName}} \
&& {{{tempDir}}}/{{{type}}}/{{jarName}} \
-force -ignoreSysPrereqs -silent \
-responseFile {{{tempDir}}}/{{responseFile.name}} \
-responseFile {{{tempDir}}}/{{{type}}}/{{responseFile.name}} \
-invPtrLoc {{inv_loc}}/oraInst.loc ORACLE_HOME={{{oracle_home}}} -jreLoc {{{java_home}}} {{/isBin}} \
{{/installPackages}}
&& test $? -eq 0 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static void validateEnvironmentSettings() {
missingSettings.add("STAGING_DIR");
}

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

}

/**
* create a WLS image using a JAR installer not in a zip.
*
* @throws Exception - if any error occurs
*/
@Test
@Order(31)
@Tag("nightly")
@DisplayName("Create WebLogic Server image from a JAR")
void createWlsImgFromJar(TestInfo testInfo) throws Exception {
// Create an imagetool command to cache the JAR installer for 12.2.1.4.0
String cacheCommand = new CacheCommand()
.addInstaller(true)
.type("wls")
.version("12.2.1.4.0")
.path(Paths.get(STAGING_DIR, "fmw_12.2.1.4.0_wls_lite_generic.jar"))
.build();

// Create an imagetool command to build the image for 12.2.1.4.0
String tagName = build_tag + ":" + getMethodName(testInfo);
String buildCommand = new CreateCommand()
.tag(tagName)
.version("12.2.1.4.0")
.build();

try (PrintWriter out = getTestMethodWriter(testInfo)) {
// run imagetool cache command
CommandResult cacheResult = Runner.run(cacheCommand, out, logger);
assertEquals(0, cacheResult.exitValue(), "for command: " + cacheCommand);
// run imagetool build command
CommandResult buildResult = Runner.run(buildCommand, out, logger);
assertEquals(0, buildResult.exitValue(), "for command: " + buildCommand);

// verify that the container image was created
assertTrue(imageExists(tagName), "Image was not created: " + tagName);
}
}
}

0 comments on commit 3dd568f

Please sign in to comment.