Skip to content

Commit

Permalink
Merge branch 'debt-cleanup' into 'main'
Browse files Browse the repository at this point in the history
DB19 installer is not required for OHS 14.1.2 installs

See merge request weblogic-cloud/weblogic-image-tool!493
  • Loading branch information
ddsharpe committed Dec 3, 2024
2 parents 12524d3 + 70d57c7 commit 3bdee7d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ public class InstalledPatch {
private String uniquePatchNumber;
private String patchDescription;

// Patterns for matching PSU versions in patch descriptions
private static final Pattern PSU_VERSION_PATTERN = Pattern.compile(
"WLS PATCH SET UPDATE (?:"
+ "(\\d+\\.\\d+\\.\\d+\\.\\d+\\.)\\d+\\(ID:(\\d+)\\.\\d+\\)|" // Pattern for format: x.x.x.x.0(ID:123456.0)
+ "(\\d+\\.\\d+\\.\\d+\\.\\d+\\.[1-9]\\d+)" // Pattern for format: x.x.x.x.nn
+ ")");

/**
* Parse the output from the image probe list of Oracle patches.
*
Expand Down Expand Up @@ -54,28 +61,28 @@ public static List<InstalledPatch> getPatchList(String oraclePatches) {
* @return the version of the PSU, or null if no PSU is found.
*/
public static String getPsuVersion(List<InstalledPatch> installedPatches) {
String result = null;
// search inventory for PSU and extract PSU version, if available
Pattern patternOne = Pattern.compile(
"WLS PATCH SET UPDATE (\\d+\\.\\d+\\.\\d+\\.\\d+\\.)\\d+\\(ID:(\\d+)\\.\\d+\\)");
Pattern patternTwo = Pattern.compile(
"WLS PATCH SET UPDATE (\\d+\\.\\d+\\.\\d+\\.\\d+\\.[1-9]\\d+)");
if (installedPatches == null || installedPatches.isEmpty()) {
return null;
}

for (InstalledPatch patch : installedPatches) {
String description = patch.patchDescription();
Matcher matchPatternOne = patternOne.matcher(description);
Matcher matchPatternTwo = patternTwo.matcher(description);
if (matchPatternOne.find()) {
result = matchPatternOne.group(1) + matchPatternOne.group(2);
logger.fine("Found PSU in inventory {0}, in {1}", result, description);
break;
} else if (matchPatternTwo.find()) {
result = matchPatternTwo.group(1);
logger.fine("Found PSU in inventory {0}, in {1}", result, description);
break;
Matcher matcher = PSU_VERSION_PATTERN.matcher(description);

if (matcher.find()) {
String psuVersion;
if (matcher.group(1) != null) {
// Handle format: x.x.x.x.0(ID:123456.0)
psuVersion = matcher.group(1) + matcher.group(2);
} else {
// Handle format: x.x.x.x.nn
psuVersion = matcher.group(3);
}
logger.fine("Found PSU in inventory {0}, in {1}", psuVersion, description);
return psuVersion;
}
}
return result;
return null;
}

public String bugNumber() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.oracle.weblogic.imagetool.installer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -82,7 +83,16 @@ public enum FmwInstallerType {
InstallerType.FMW, InstallerType.WCS),
OHS(Utils.toSet(AruProduct.OHS, AruProduct.OAM_WG, AruProduct.WLS, AruProduct.JDBC, AruProduct.FMWPLAT,
AruProduct.OSS, AruProduct.FIT, AruProduct.JRF, AruProduct.FMW_GLCM),
InstallerType.OHS, InstallerType.DB19),
InstallerType.OHS) {
@Override
public List<InstallerType> installerList(String version) {
List<InstallerType> ohsInstallers = new ArrayList<>(Arrays.asList(OHS.installers));
if (version.equals("12.2.1.4.0")) {
ohsInstallers.add(InstallerType.DB19);
}
return ohsInstallers;
}
},
ODI(Collections.singleton(AruProduct.ODI),
InstallerType.ODI)
;
Expand All @@ -95,12 +105,13 @@ public enum FmwInstallerType {
this.products = products;
}

public List<InstallerType> installerList() {
@SuppressWarnings("unused") // version parameter is needed in the OHS override function
public List<InstallerType> installerList(String version) {
return Arrays.asList(installers);
}

public String installerListString() {
return Arrays.stream(installers).map(Object::toString).collect(Collectors.joining(", "));
public String installerListString(String version) {
return installerList(version).stream().map(Object::toString).collect(Collectors.joining(", "));
}

public Set<AruProduct> products() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class MiddlewareInstall {
*/
public MiddlewareInstall(FmwInstallerType type, String version, List<Path> responseFiles,
Architecture target) throws FileNotFoundException {
logger.info("IMG-0039", type.installerListString(), version);
logger.info("IMG-0039", type.installerListString(version), version);
fmwInstallerType = type;

for (InstallerType installer : type.installerList()) {
for (InstallerType installer : type.installerList(version)) {
MiddlewareInstallPackage pkg = new MiddlewareInstallPackage();
pkg.type = installer;
pkg.installer = new CachedFile(installer, version, target);
Expand All @@ -47,7 +47,7 @@ public MiddlewareInstall(FmwInstallerType type, String version, List<Path> respo
}
addInstaller(pkg);
}
setResponseFiles(responseFiles);
setResponseFiles(responseFiles, version);
}

private static String getJarNameFromInstaller(Path installerFile) throws IOException {
Expand Down Expand Up @@ -96,11 +96,11 @@ public List<MiddlewareInstallPackage> getInstallers() {
return installerFiles;
}

private boolean addInstaller(MiddlewareInstallPackage installPackage) {
return installerFiles.add(installPackage);
private void addInstaller(MiddlewareInstallPackage installPackage) {
installerFiles.add(installPackage);
}

private void setResponseFiles(List<Path> responseFiles) throws FileNotFoundException {
private void setResponseFiles(List<Path> responseFiles, String version) throws FileNotFoundException {
if (responseFiles == null || responseFiles.isEmpty()) {
return;
}
Expand All @@ -110,7 +110,7 @@ private void setResponseFiles(List<Path> responseFiles) throws FileNotFoundExcep
if (responseFiles.size() != installerFiles.size()) {
throw new IllegalArgumentException(
Utils.getMessage("IMG-0040",
fmwInstallerType.installerListString(),
fmwInstallerType.installerListString(version),
responseFiles.size(),
installerFiles.size()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,29 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Tag("unit")
class InstallerTest {
@Test
void fmwInstallerTypeStringTest() {
assertEquals("fmw, soa, osb", FmwInstallerType.SOA_OSB.installerListString(),
assertEquals("fmw, soa, osb", FmwInstallerType.SOA_OSB.installerListString("12.2.1.4.0"),
"string list of installer types for SOA_OSB is wrong");
}

@Test
void fmwInstallerTypeListTest() {
assertEquals(Arrays.asList(InstallerType.FMW, InstallerType.OSB),
FmwInstallerType.OSB.installerList(), "installer list for OSB is wrong");
FmwInstallerType.OSB.installerList("12.2.1.4.0"), "installer list for OSB is wrong");

assertEquals(Arrays.asList(InstallerType.FMW, InstallerType.SOA, InstallerType.OSB),
FmwInstallerType.SOA_OSB.installerList(), "installer list for OSB is wrong");
FmwInstallerType.SOA_OSB.installerList("12.2.1.4.0"), "installer list for OSB is wrong");

assertTrue(FmwInstallerType.OHS.installerList("12.2.1.4.0").contains(InstallerType.DB19));
assertFalse(FmwInstallerType.OHS.installerList("14.1.2.0.0").contains(InstallerType.DB19),
"Only OHS 12.2.1.4 requires the DB19 installer (patch)");
}

@Test
Expand Down

0 comments on commit 3bdee7d

Please sign in to comment.