diff --git a/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/AruUtil.java b/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/AruUtil.java index 519aac9e..73224318 100644 --- a/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/AruUtil.java +++ b/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/AruUtil.java @@ -137,6 +137,11 @@ List getLatestPsu(AruProduct product, String version, String userId, S try { logger.info("IMG-0019", product.description()); String releaseNumber = getReleaseNumber(product, version, userId, password); + if (Utils.isEmptyString(releaseNumber)) { + // ARU does not have a release number for the given product and version, return empty patch list + logger.info(Utils.getMessage("IMG-0082", version, product.description())); + return Collections.emptyList(); + } Document aruRecommendations = retry( () -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password)); logger.exiting(); @@ -144,7 +149,7 @@ List getLatestPsu(AruProduct product, String version, String userId, S .filter(AruPatch::isPsu) .filter(not(AruPatch::isStackPatchBundle)) .collect(Collectors.toList()); - } catch (NoPatchesFoundException | ReleaseNotFoundException ex) { + } catch (NoPatchesFoundException ex) { logger.exiting(); return Collections.emptyList(); } catch (RetryFailedException | XPathExpressionException e) { @@ -154,7 +159,7 @@ List getLatestPsu(AruProduct product, String version, String userId, S } /** - * Get list of recommended patches available for a given product and version. + * Get list of recommended patches available for all the products that are part of the FMW installer type. * * @param type FMW installer type * @param version version number like 12.2.1.3.0 @@ -203,44 +208,43 @@ public List getRecommendedPatches(FmwInstallerType type, String versio List getRecommendedPatches(AruProduct product, String version, String userId, String password) throws AruException { logger.entering(product, version); + List patches = Collections.emptyList(); try { logger.info("IMG-0067", product.description()); String releaseNumber = getReleaseNumber(product, version, userId, password); - Document aruRecommendations = retry( - () -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password)); - // TODO: Need an option for the user to request the Coherence additional feature pack. - List patches = AruPatch.getPatches(aruRecommendations) - .filter(not(AruPatch::isStackPatchBundle)) //remove Stack Patch Bundle - .filter(not(AruPatch::isCoherenceFeaturePack)) //remove COH feature pack - .collect(Collectors.toList()); - String psuVersion = getPsuVersion(product.description(), patches); - if (psuVersion != null) { - //repeat the same process to get recommended patches, but use the PSU release instead of the GA release - // All the same patches are in the PSU release, but also the overlay patches (if any) - patches.forEach(p -> logger.fine("Discarding recommended patch {0} {1}", p.patchId(), p.description())); - logger.fine("Recommended patch list contains a PSU, getting recommendations for PSU version {0}", - psuVersion); - // get release number for PSU - String psuReleaseNumber = getReleaseNumber(product, psuVersion, userId, password); - // get recommended patches for PSU release (Overlay patches are only recommended on the PSU release) - Document psuOverrides = retry( - () -> getRecommendedPatchesMetadata(product, psuReleaseNumber, userId, password)); - - patches = AruPatch.getPatches(psuOverrides) - .filter(not(AruPatch::isStackPatchBundle)) // remove the Stack Patch Bundle patch, if returned - .filter(not(AruPatch::isCoherenceFeaturePack)) // remove the Coherence feature pack, if returned - .collect(Collectors.toList()); + if (Utils.isEmptyString(releaseNumber)) { + // ARU does not have a release number for the given product and version, return an empty patch list + logger.info(Utils.getMessage("IMG-0082", version, product.description())); + } else { + // Get a list of patches applicable to the given product and release number + patches = getReleaseRecommendations(product, releaseNumber, userId, password); + String psuVersion = getPsuVersion(product.description(), patches); + if (psuVersion != null) { + // Check to see if there is a release with the PSU version that contains overlay patches. + logger.fine("Recommended patch list contains a PSU, getting recommendations for PSU version {0}", + psuVersion); + // Get the release number for the PSU version number + String psuReleaseNumber = getReleaseNumber(product, psuVersion, userId, password); + // If there is a release for the specific PSU, check it for overlay patches + if (!Utils.isEmptyString(psuReleaseNumber)) { + // Debug log - useful to know what was thrown away when "patches" is replaced by the new array + patches.forEach(p -> logger.fine("Discarding recommended patch {0} {1}", + p.patchId(), p.description())); + // Get recommended patches for PSU release (includes PSU overlay patches) + patches = getReleaseRecommendations(product, psuReleaseNumber, userId, password); + } else { + // ARU does not have a release number for the PSU version found (no overlays needed) + logger.fine("PSU release was not found for {0} : {1}", product, psuVersion); + } + } } - logger.exiting(patches); - return patches; - } catch (ReleaseNotFoundException nf) { - return Collections.emptyList(); } catch (NoPatchesFoundException npf) { logger.info("IMG-0069", product.description(), version); - return Collections.emptyList(); } catch (RetryFailedException | XPathExpressionException e) { throw new AruException(Utils.getMessage("IMG-0070", product.description(), version), e); } + logger.exiting(patches); + return patches; } private String getPsuVersion(String productName, Collection patches) { @@ -256,6 +260,19 @@ private String getPsuVersion(String productName, Collection patches) { return null; } + List getReleaseRecommendations(AruProduct product, String releaseNumber, String userId, String password) + throws AruException, XPathExpressionException, RetryFailedException { + + Document patchesDocument = retry( + () -> getRecommendedPatchesMetadata(product, releaseNumber, userId, password)); + + return AruPatch.getPatches(patchesDocument) + .filter(not(AruPatch::isStackPatchBundle)) // remove the Stack Patch Bundle patch, if returned + // TODO: Need an option for the user to request the Coherence additional feature pack. + .filter(not(AruPatch::isCoherenceFeaturePack)) // remove the Coherence feature pack, if returned + .collect(Collectors.toList()); + } + static class PatchLists { List installedPatches; List candidatePatches; @@ -358,7 +375,6 @@ Document getRecommendedPatchesMetadata(AruProduct product, String releaseNumber, * @param password OTN credential password * @return release number for the product and version provided * @throws AruException if the call to ARU fails, or the response from ARU had an error - * @throws ReleaseNotFoundException if the specified version for the requested product was not found */ private String getReleaseNumber(AruProduct product, String version, String userId, String password) throws AruException { @@ -375,11 +391,6 @@ private String getReleaseNumber(AruProduct product, String version, String userI } catch (XPathExpressionException xpe) { throw new AruException("Could not extract release number with XPath", xpe); } - if (Utils.isEmptyString(result)) { - String msg = Utils.getMessage("IMG-0082", version, product.description()); - logger.info(msg); - throw new ReleaseNotFoundException(msg); - } logger.exiting(result); return result; } diff --git a/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/ReleaseNotFoundException.java b/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/ReleaseNotFoundException.java deleted file mode 100644 index 724abeb8..00000000 --- a/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/ReleaseNotFoundException.java +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2021, Oracle and/or its affiliates. -// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - -package com.oracle.weblogic.imagetool.aru; - -/** - * For a given list of patches returned from ARU, the version requested was not found. - */ -public class ReleaseNotFoundException extends AruException { - /** - * The product/version combination was not found in the release table on ARU. - */ - public ReleaseNotFoundException(String message) { - super(message); - } -} diff --git a/tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java b/tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java index 3c15641e..a3d82bea 100644 --- a/tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java +++ b/tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java @@ -783,7 +783,6 @@ void createAuxImage(TestInfo testInfo) throws Exception { @Test @Order(20) @Tag("nightly") - @Tag("failing") @DisplayName("Create FMW 12.2.1.3 image with latest PSU") void createFmwImgFullInternetAccess(TestInfo testInfo) throws Exception { // add jdk 8u212 installer to the cache @@ -879,7 +878,6 @@ void createJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception { @Test @Order(23) @Tag("nightly") - @Tag("failing") @DisplayName("Create FMW image with WDT domain and latestPSU with new base img") void createRestrictedJrfDomainImgUsingWdt(TestInfo testInfo) throws Exception { // test assumes that the FMW 12.2.1.3 installer is already in the cache @@ -955,7 +953,6 @@ void createWlsImgUsingMultiModels(TestInfo testInfo) throws Exception { @Test @Order(25) @Tag("nightly") - @Tag("failing") @DisplayName("Create image with additionalBuildCommands and recommendedPatches") void createWlsImgWithAdditionalBuildCommands(TestInfo testInfo) throws Exception { String tagName = build_tag + ":" + getMethodName(testInfo);