diff --git a/dev/com.ibm.ws.install.featureUtility_fat/build.gradle b/dev/com.ibm.ws.install.featureUtility_fat/build.gradle index 50960b680f1..ab9fafd2b72 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/build.gradle +++ b/dev/com.ibm.ws.install.featureUtility_fat/build.gradle @@ -1,4 +1,4 @@ -/* Copyright (c) 2021, 2023 IBM Corporation and others. +/* Copyright (c) 2021, 2024 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -13,12 +13,14 @@ addRequiredLibraries { configurations { usrFeatures - features + features1 + features2 } dependencies { usrFeatures 'test.featureUtility_fat:userFeature:1.0@zip' - features 'test.featureUtility_fat:Archive:1.0@zip' + features1 'test.featureUtility_fat:Archive:1.0@zip' + features2 'test.featureUtility_fat:Archive:2.0@zip' requiredLibs project(':com.ibm.ws.org.slf4j.api'), project(':com.ibm.ws.org.slf4j.simple') } @@ -29,8 +31,13 @@ addRequiredLibraries { } copy { - from configurations.features - into "publish/repo/archive" + from configurations.features1 + into "publish/repo/archive1" + } + + copy { + from configurations.features2 + into "publish/repo/archive2" } dependsOn copyTestContainers diff --git a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FATSuite.java b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FATSuite.java index 2756dc173d2..8513117b1a2 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FATSuite.java +++ b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FATSuite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2021 IBM Corporation and others. + * Copyright (c) 2019, 2024 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -25,7 +25,7 @@ @RunWith(Suite.class) @SuiteClasses({ - InstallFeatureTest.class, InstallServerTest.class, HelpActionTest.class + InstallFeatureTest.class, InstallServerTest.class, HelpActionTest.class, InstallVersionlessServerTest.class }) public class FATSuite extends TestContainerSuite { @@ -38,8 +38,9 @@ public class FATSuite extends TestContainerSuite { @BeforeClass public static void beforeSuite() throws Exception { FeatureUtilityToolTest.setupEnv(); - FeatureUtilityToolTest.constructLocalMavenRepo(Paths.get("publish/repo/userFeature/userFeature-1.0.zip")); - FeatureUtilityToolTest.constructLocalMavenRepo(Paths.get("publish/repo/archive/Archive-1.0.zip")); + FeatureUtilityToolTest.constructLocalMavenRepo(Paths.get("publish/repo/").toAbsolutePath().toString(),Paths.get("publish/repo/userFeature/userFeature-1.0.zip")); + FeatureUtilityToolTest.constructLocalMavenRepo(Paths.get("publish/repo/").toAbsolutePath().toString(),Paths.get("publish/repo/archive1/Archive-1.0.zip")); + FeatureUtilityToolTest.constructLocalMavenRepo(Paths.get("publish/repo2/").toAbsolutePath().toString(),Paths.get("publish/repo/archive2/Archive-2.0.zip")); //New repo has versionless features } @AfterClass diff --git a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FeatureUtilityToolTest.java b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FeatureUtilityToolTest.java index 16abbcfdefa..e977cbdcc83 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FeatureUtilityToolTest.java +++ b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/FeatureUtilityToolTest.java @@ -50,7 +50,8 @@ public abstract class FeatureUtilityToolTest { protected static String libertyVersion = "23.0.0.2"; // ${buildDir}/publish/repo - protected static String mavenLocalRepo = Paths.get("publish/repo/").toAbsolutePath().toString(); + protected static String mavenLocalRepo1 = Paths.get("publish/repo/").toAbsolutePath().toString(); + protected static String mavenLocalRepo2 = Paths.get("publish/repo2/").toAbsolutePath().toString(); public static LibertyServer server; private static String installRoot; static String minifiedRoot; @@ -94,7 +95,8 @@ protected static void setupEnv() throws Exception { minifiedRoot = exportWlp(installRoot, installRoot + "/../temp/wlp.zip", installRoot + relativeMinifiedRoot); Log.info(c, methodName, "minified root: " + minifiedRoot); - Log.info(c, methodName, "mavenLocalRepo : " + mavenLocalRepo.toString()); + Log.info(c, methodName, "mavenLocalRepo1 : " + mavenLocalRepo1.toString()); + Log.info(c, methodName, "mavenLocalRepo2 : " + mavenLocalRepo2.toString()); if(!new File(minifiedRoot).exists()){ throw new Exception("The minified root does not exist!"); @@ -372,8 +374,8 @@ protected ProgramOutput runFeatureUtility(String testcase, String[] params) thro protected ProgramOutput runFeatureUtility(String testcase, String[] params, boolean debug) throws Exception { Properties envProps = new Properties(); - // add beta property here - // envProps.put("JVM_ARGS", "-Dbeta.property=true"); + //add beta property here + envProps.put("JVM_ARGS", "-Dbeta.property=true"); return runFeatureUtility(testcase, params, envProps); } @@ -418,8 +420,10 @@ protected static boolean deleteProps(String methodName) throws IOException { } protected static boolean deleteRepo(String methodName) throws IOException { - boolean repo = TestUtils.deleteFolder(new File(mavenLocalRepo)); - Log.info(c, methodName, "DELETED REPO : " + mavenLocalRepo + "?" + repo); + boolean repo = TestUtils.deleteFolder(new File(mavenLocalRepo1)); + Log.info(c, methodName, "DELETED REPO : " + mavenLocalRepo1 + "?" + repo); + repo = TestUtils.deleteFolder(new File(mavenLocalRepo2)); + Log.info(c, methodName, "DELETED REPO : " + mavenLocalRepo2 + "?" + repo); return repo; } @@ -507,18 +511,6 @@ protected static void checkCommandOutput(ProgramOutput po, int exitCode, String } - /* - * / Copy Maven central features and signatures to local repository - */ - protected static void constructLocalMavenRepo(Path artifactPath) throws Exception { - Log.info(c, "constructLocalMavenRepo", - "Creating local repository using " + artifactPath.toAbsolutePath().toString()); - - ZipFile zipFile = new ZipFile(artifactPath.toFile()); - TestUtils.unzipFileIntoDirectory(zipFile, Paths.get(mavenLocalRepo).toFile()); - Log.info(c, "constructLocalMavenRepo", "Unzipped to " + Paths.get(mavenLocalRepo).toAbsolutePath().toString()); - - } /** * @param METHOD_NAME @@ -542,5 +534,18 @@ protected void retryFeatureUtility(String METHOD_NAME) throws Exception { runFeatureUtility(METHOD_NAME, param1s); } + /* + * / Copy Maven central features and signatures to local repository + */ + protected static void constructLocalMavenRepo(String repoPath,Path artifactPath) throws Exception { + Log.info(c, "constructLocalMavenRepo", + "Creating local repository using " + artifactPath.toAbsolutePath().toString()); + + ZipFile zipFile = new ZipFile(artifactPath.toFile()); + TestUtils.unzipFileIntoDirectory(zipFile, Paths.get(repoPath).toFile()); + Log.info(c, "constructLocalMavenRepo", "Unzipped to " + Paths.get(repoPath).toAbsolutePath().toString()); + + } + } diff --git a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallFeatureTest.java b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallFeatureTest.java index 83736eb5c3d..33d7345b78e 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallFeatureTest.java +++ b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallFeatureTest.java @@ -84,7 +84,7 @@ public static void beforeClassSetup() throws Exception { public void beforeSetUp() throws Exception { copyFileToMinifiedRoot("etc", "publish/propertyFiles/publishRepoOverrideProps/featureUtility.properties"); - writeToProps(minifiedRoot + "/etc/featureUtility.properties", "featureLocalRepo", mavenLocalRepo); + writeToProps(minifiedRoot + "/etc/featureUtility.properties", "featureLocalRepo", mavenLocalRepo1); } @After @@ -162,7 +162,7 @@ public void testInstallFeatureESA() throws Exception { String esaFile = String.format("/io/openliberty/features/json-1.0/%s/json-1.0-%s.esa", libertyVersion, libertyVersion); //copy json esa file from local Maven repo to a temporary location (wlp/tmp) - copyFileToMinifiedRoot("tmp", mavenLocalRepo + esaFile); + copyFileToMinifiedRoot("tmp", mavenLocalRepo1 + esaFile); // Begin Test String[] param1s = { "installFeature", minifiedRoot + "/tmp/" + String.format("json-1.0-%s.esa", libertyVersion), "--verbose" }; String[] filesList = { "lib/features/com.ibm.websphere.appserver.json-1.0.mf" }; @@ -589,7 +589,7 @@ public void testFeatureVerifyENFORCEnoSig() throws Exception { String[] filesList = { "usr/extension/lib/features/testesa1.mf", "usr/extension/bin/testesa1.bat" }; //copy testesa1 esa file from local Maven repo to a temporary location (wlp/tmp) - copyFileToMinifiedRoot("tmp", mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/19.0.0.8/testesa1-19.0.0.8.esa"); + copyFileToMinifiedRoot("tmp", mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/19.0.0.8/testesa1-19.0.0.8.esa"); // Begin Test String[] param1s = { "installFeature", minifiedRoot + "/tmp/testesa1-19.0.0.8.esa", "json-1.0", @@ -610,7 +610,7 @@ public void testFeatureVerifyALL() throws Exception { Log.entering(c, METHOD_NAME); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyid", "71f8e6239b6834aa"); String[] filesList = { "usr/extension/lib/features/testesa1.mf", "usr/extension/bin/testesa1.bat" }; @@ -632,7 +632,7 @@ public void testFeatureVerifySKIP() throws Exception { final String METHOD_NAME = "testFeatureVerifySKIP"; Log.entering(c, METHOD_NAME); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyid", "71f8e6239b6834aa"); String[] filesList = { "usr/extension/lib/features/testesa1.mf", "usr/extension/bin/testesa1.bat" }; @@ -709,7 +709,7 @@ public void testFeatureVerifyALLProps() throws Exception { Log.entering(c, METHOD_NAME); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "feature.verify", "all"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyid", "71f8e6239b6834aa"); String[] filesList = { "usr/extension/lib/features/testesa1.mf", "usr/extension/bin/testesa1.bat" }; @@ -732,7 +732,7 @@ public void testFeatureVerifyALLEnv() throws Exception { envProps.put("FEATURE_VERIFY", "all"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyid", "71f8e6239b6834aa"); String[] filesList = { "usr/extension/lib/features/testesa1.mf", "usr/extension/bin/testesa1.bat" }; @@ -784,15 +784,15 @@ public void testVerifyRevokedKey() throws Exception { envProps.put("FEATURE_VERIFY", "all"); // backup the valid user feature signature - Files.move(Paths.get(mavenLocalRepo + userFeatureSigPath), - Paths.get(mavenLocalRepo + userFeatureSigPath + ".bck")); + Files.move(Paths.get(mavenLocalRepo1 + userFeatureSigPath), + Paths.get(mavenLocalRepo1 + userFeatureSigPath + ".bck")); // overwrite with signature signed by revoked key - Files.copy(Paths.get(mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/revoked/testesa1-19.0.0.8.esa.asc"), - Paths.get(mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/19.0.0.8/testesa1-19.0.0.8.esa.asc")); + Files.copy(Paths.get(mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/revoked/testesa1-19.0.0.8.esa.asc"), + Paths.get(mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/19.0.0.8/testesa1-19.0.0.8.esa.asc")); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "feature.verify", "all"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/revoked/revokedKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/revoked/revokedKey.asc"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyid", "2CB7FEADC826EA27"); String[] param1s = { "installFeature", "testesa1", @@ -800,8 +800,8 @@ public void testVerifyRevokedKey() throws Exception { ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); // Change back to valid signature - Files.move(Paths.get(mavenLocalRepo + userFeatureSigPath + ".bck"), - Paths.get(mavenLocalRepo + userFeatureSigPath), + Files.move(Paths.get(mavenLocalRepo1 + userFeatureSigPath + ".bck"), + Paths.get(mavenLocalRepo1 + userFeatureSigPath), StandardCopyOption.REPLACE_EXISTING); checkCommandOutput(po, InstallException.SIGNATURE_VERIFICATION_FAILED, "CWWKF1510E", null); @@ -821,15 +821,15 @@ public void testVerifyExpiredKey() throws Exception { envProps.put("FEATURE_VERIFY", "all"); // backup the valid user feature signature - Files.move(Paths.get(mavenLocalRepo + userFeatureSigPath), - Paths.get(mavenLocalRepo + userFeatureSigPath + ".bck")); + Files.move(Paths.get(mavenLocalRepo1 + userFeatureSigPath), + Paths.get(mavenLocalRepo1 + userFeatureSigPath + ".bck")); // overwrite with signature signed by expired key - Files.copy(Paths.get(mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/expired/testesa1-19.0.0.8.esa.asc"), - Paths.get(mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/19.0.0.8/testesa1-19.0.0.8.esa.asc")); + Files.copy(Paths.get(mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/expired/testesa1-19.0.0.8.esa.asc"), + Paths.get(mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/19.0.0.8/testesa1-19.0.0.8.esa.asc")); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "feature.verify", "all"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/expired/expiredKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/expired/expiredKey.asc"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyid", "61B792CE2DAA8C02"); String[] param1s = { "installFeature", "testesa1", @@ -837,8 +837,8 @@ public void testVerifyExpiredKey() throws Exception { ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); // Change back to valid signature - Files.move(Paths.get(mavenLocalRepo + userFeatureSigPath + ".bck"), - Paths.get(mavenLocalRepo + userFeatureSigPath), StandardCopyOption.REPLACE_EXISTING); + Files.move(Paths.get(mavenLocalRepo1 + userFeatureSigPath + ".bck"), + Paths.get(mavenLocalRepo1 + userFeatureSigPath), StandardCopyOption.REPLACE_EXISTING); checkCommandOutput(po, InstallException.SIGNATURE_VERIFICATION_FAILED, "CWWKF1511E", null); Log.exiting(c, METHOD_NAME); @@ -857,7 +857,7 @@ public void testVerifyNoKeyId() throws Exception { writeToProps(minifiedRoot + "/etc/featureUtility.properties", "feature.verify", "all"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); String[] param1s = { "installFeature", "testesa1", "--featuresBOM=com.ibm.ws.userFeature:features-bom:19.0.0.8", "--verbose" }; @@ -930,25 +930,25 @@ public void testVerifyBadSignature() throws Exception { envProps.put("FEATURE_VERIFY", "all"); // backup the valid user feature signature - Files.move(Paths.get(mavenLocalRepo + userFeatureSigPath), - Paths.get(mavenLocalRepo + userFeatureSigPath + ".bck")); + Files.move(Paths.get(mavenLocalRepo1 + userFeatureSigPath), + Paths.get(mavenLocalRepo1 + userFeatureSigPath + ".bck")); // overwrtie valid signature to invalid signature Files.copy( - Paths.get(mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/invalidSig/testesa1-19.0.0.8.esa.asc"), - Paths.get(mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/19.0.0.8/testesa1-19.0.0.8.esa.asc")); + Paths.get(mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/invalidSig/testesa1-19.0.0.8.esa.asc"), + Paths.get(mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/19.0.0.8/testesa1-19.0.0.8.esa.asc")); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "feature.verify", "all"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyid", "71f8e6239b6834aa"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); String[] param1s = { "installFeature", "testesa1", "--featuresBOM=com.ibm.ws.userFeature:features-bom:19.0.0.8", "--verbose" }; ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); // Change back to valid signature - Files.move(Paths.get(mavenLocalRepo + userFeatureSigPath + ".bck"), - Paths.get(mavenLocalRepo + userFeatureSigPath), StandardCopyOption.REPLACE_EXISTING); + Files.move(Paths.get(mavenLocalRepo1 + userFeatureSigPath + ".bck"), + Paths.get(mavenLocalRepo1 + userFeatureSigPath), StandardCopyOption.REPLACE_EXISTING); checkCommandOutput(po, InstallException.SIGNATURE_VERIFICATION_FAILED, "CWWKF1512E", null); diff --git a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallServerTest.java b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallServerTest.java index 0d8f73f7996..bcf38d7ca98 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallServerTest.java +++ b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallServerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2023 IBM Corporation and others. + * Copyright (c) 2019, 2024 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -44,7 +44,7 @@ public static void beforeClassSetup() throws Exception { @Before public void beforeSetUp() throws Exception { copyFileToMinifiedRoot("etc", "publish/propertyFiles/publishRepoOverrideProps/featureUtility.properties"); - writeToProps(minifiedRoot + "/etc/featureUtility.properties", "featureLocalRepo", mavenLocalRepo); + writeToProps(minifiedRoot + "/etc/featureUtility.properties", "featureLocalRepo", mavenLocalRepo1); } @After @@ -157,28 +157,7 @@ public void testInvalidMultiVersionFeatures() throws Exception { Log.exiting(c, METHOD_NAME); } - /** - * Test the install of versionless servlet from maven central. Multi-version is not - * supported with installServerFeature as it cannot be installed to same - * resource. - * - * @throws Exception - */ - @Ignore - @Test - public void testVersionlessWithPlatformFeatures() throws Exception { - final String METHOD_NAME = "testInvalidMultiVersionFeatures"; - Log.entering(c, METHOD_NAME); - - copyFileToMinifiedRoot("usr/servers/serverX", "publish/tmp/versionlessWPlatform/server.xml"); - - String[] param1s = { "installServerFeatures", "serverX", "--verbose" }; - ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); - - checkCommandOutput(po, 21, "CWWKF1405E", null); - Log.exiting(c, METHOD_NAME); - } - + /** * Install an user feature with the "--featuresBom" parameters */ @@ -293,7 +272,7 @@ public void testInstallServerFeaturesUsrVerifyAll() throws Exception { copyFileToMinifiedRoot("usr/servers/serverX", "publish/tmp/usrFeaturesServerXml/server.xml"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyurl", - mavenLocalRepo + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); + mavenLocalRepo1 + "/com/ibm/ws/userFeature/testesa1/valid/validKey.asc"); writeToProps(minifiedRoot + "/etc/featureUtility.properties", "myKey.keyid", "71f8e6239b6834aa"); String[] filesList = { "usr/extension/lib/features/testesa1.mf", "usr/extension/bin/testesa1.bat" }; diff --git a/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallVersionlessServerTest.java b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallVersionlessServerTest.java new file mode 100644 index 00000000000..e6f3505f80e --- /dev/null +++ b/dev/com.ibm.ws.install.featureUtility_fat/fat/src/com/ibm/ws/install/featureUtility/fat/InstallVersionlessServerTest.java @@ -0,0 +1,130 @@ +/******************************************************************************* + * Copyright (c) 2024 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.ws.install.featureUtility.fat; + +import static org.junit.Assert.assertTrue; + +import java.util.Properties; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import com.ibm.websphere.simplicity.ProgramOutput; +import com.ibm.websphere.simplicity.log.Log; + +public class InstallVersionlessServerTest extends FeatureUtilityToolTest { + private static final Class c = InstallVersionlessServerTest.class; + + @BeforeClass + public static void beforeClassSetup() throws Exception { + final String methodName = "beforeClassSetup"; + Log.entering(c, methodName); + /* Enable tests only if running on a zOS machine, otherwise skip class */ + Assume.assumeTrue(!isZos); + deleteFeaturesAndLafilesFolders("beforeClassSetup"); + replaceWlpProperties("24.0.0.8"); + Log.exiting(c, methodName); + } + + @Before + public void beforeSetUp() throws Exception { + copyFileToMinifiedRoot("etc", "publish/propertyFiles/publishRepoOverrideProps/featureUtility.properties"); + writeToProps(minifiedRoot + "/etc/featureUtility.properties", "featureLocalRepo", mavenLocalRepo2); + } + + @After + public void afterCleanUp() throws Exception { + deleteFeaturesAndLafilesFolders("afterCleanUp"); + deleteUsrExtFolder("afterCleanUp"); + deleteEtcFolder("afterCleanUp"); + } + + @AfterClass + public static void cleanUp() throws Exception { + if (!isZos) { + resetOriginalWlpProps(); + } + } + + + /** + * Test the install of versionless with bogus platform name xxx from maven central. Should throw expected platform name not found + * + * @throws Exception + */ + @Ignore + @Test + public void testVersionlessWithBadPlatformFeatures() throws Exception { + final String METHOD_NAME = "testVersionlessWithBadPlatformFeatures"; + Log.entering(c, METHOD_NAME); + + copyFileToMinifiedRoot("usr/servers/serverX", "publish/tmp/versionlessBadPlatform/server.xml"); + + String[] param1s = { "installServerFeatures", "serverX", "--verify=skip", "--verbose" }; + + ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); + + checkCommandOutput(po, 21, "CWWKF1515E", null); //UnKnown platform error + Log.exiting(c, METHOD_NAME); + } + + /** + * Test the install of versionless with no platform defined. Should throw expected platform can't be determined error + * + * @throws Exception + */ + @Ignore + @Test + public void testVersionlessWithNoPlatformFeatures() throws Exception { + final String METHOD_NAME = "testVersionlessWithNoPlatformFeatures"; + Log.entering(c, METHOD_NAME); + + copyFileToMinifiedRoot("usr/servers/serverX", "publish/tmp/versionlessNoPlatform/server.xml"); + + String[] param1s = { "installServerFeatures", "serverX", "--verify=skip", "--verbose" }; + ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); + + checkCommandOutput(po, 21, "CWWKF1516E", null); //Platform not determined + Log.exiting(c, METHOD_NAME); + } + + /** + * Test the install of versionless with platform name. install servlet-6.0 feature + * + * @throws Exception + */ + @Ignore + @Test + public void testVersionlessWithPlatformFeatures() throws Exception { + final String METHOD_NAME = "testVersionlessWithPlatformFeatures"; + Log.entering(c, METHOD_NAME); + + copyFileToMinifiedRoot("usr/servers/serverX", "publish/tmp/versionlessWithPlatform/server.xml"); + + String[] param1s = { "installServerFeatures", "serverX", "--verify=skip", "--verbose" }; + String[] filesList = { "/lib/features/com.ibm.websphere.appserver.servlet-6.0.mf" }; + + ProgramOutput po = runFeatureUtility(METHOD_NAME, param1s); + + checkCommandOutput(po, 0, null, filesList); //Should have servlet-6.0 + Log.exiting(c, METHOD_NAME); + } + + + +} diff --git a/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessBadPlatform/server.xml b/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessBadPlatform/server.xml new file mode 100644 index 00000000000..5998ea5b079 --- /dev/null +++ b/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessBadPlatform/server.xml @@ -0,0 +1,10 @@ + + + + + + xxx + jsp + + + diff --git a/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessWPlatform/server.xml b/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessNoPlatform/server.xml similarity index 82% rename from dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessWPlatform/server.xml rename to dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessNoPlatform/server.xml index c3076b4451e..315aa08e45a 100644 --- a/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessWPlatform/server.xml +++ b/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessNoPlatform/server.xml @@ -3,7 +3,6 @@ - jakartaee-10.0 servlet diff --git a/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessWithPlatform/server.xml b/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessWithPlatform/server.xml new file mode 100644 index 00000000000..68068cdc782 --- /dev/null +++ b/dev/com.ibm.ws.install.featureUtility_fat/publish/tmp/versionlessWithPlatform/server.xml @@ -0,0 +1,10 @@ + + + + + + javaee-6.0 + servlet + + + diff --git a/dev/com.ibm.ws.install/resources/com/ibm/ws/install/internal/resources/InstallKernel.nlsprops b/dev/com.ibm.ws.install/resources/com/ibm/ws/install/internal/resources/InstallKernel.nlsprops index 7f8fccecdad..a855c9fb76a 100755 --- a/dev/com.ibm.ws.install/resources/com/ibm/ws/install/internal/resources/InstallKernel.nlsprops +++ b/dev/com.ibm.ws.install/resources/com/ibm/ws/install/internal/resources/InstallKernel.nlsprops @@ -949,3 +949,15 @@ ERROR_INAUTHENTIC_PUBLIC_KEY=CWWKF1514E: The {0} public key ID does not match th ERROR_INAUTHENTIC_PUBLIC_KEY.explanation=The public key might have changed. ERROR_INAUTHENTIC_PUBLIC_KEY.useraction=If the public key is a local file, make sure to provide the correct file. +ERROR_MISSING_PLATFORM_NAME=CWWKF1515E: The {0} platform couldn't be found. +ERROR_MISSING_PLATFORM_NAME.explanation=The platform name that is specified by the configuration or environment variable wasn't found. +ERROR_MISSING_PLATFORM_NAME.useraction=Check the spelling of the platform name and version, for example, microProfile-6.1. + +ERROR_NO_DERIVED_PLATFORM=CWWKF1516E: The platform couldn't be determined. The following versionless features can't be installed: {0}. +ERROR_NO_DERIVED_PLATFORM.explanation= The platform was not set or couldn't be derived from existing versioned features. +ERROR_NO_DERIVED_PLATFORM.useraction=Add a platform for versionless features. + +LOG_INSTALL_WITH_PLATFORM=CWWKF1314I: Installing using the following platforms: {0}. +LOG_INSTALL_WITH_PLATFORM.explanation=The specified platform versions was used to resolve versionless features. +LOG_INSTALL_WITH_PLATFORM.useraction=No action is required. + diff --git a/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/ExceptionUtils.java b/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/ExceptionUtils.java index d80535c13b4..015a5f6c544 100755 --- a/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/ExceptionUtils.java +++ b/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/ExceptionUtils.java @@ -553,13 +553,22 @@ static InstallException create(RepositoryResolutionException e, Collection allRequirementsNotFound = e.getAllRequirementsResourcesNotFound(); + + String msg = createVersionlessIssues(e); + if (!msg.isEmpty()) { + InstallException ie = create(msg, e); + ie.setData(assetNames); + return ie; + } + if (allRequirementsNotFound.isEmpty()) { - String msg = checkForSingletonException(e.getFeatureConflicts()); + msg = checkForSingletonException(e.getFeatureConflicts()); if (!msg.isEmpty()) { InstallException ie = create(msg, e); ie.setData(assetNames); return ie; } + return null; } Collection dependants = new ArrayList(allRequirementsNotFound.size()); for (MissingRequirement f : allRequirementsNotFound) { @@ -695,6 +704,27 @@ static InstallException create(RepositoryResolutionException e, Collection> noPlatformVersionless : e.getMissingBasePlatforms().entrySet()) { + sb.append(Messages.INSTALL_KERNEL_MESSAGES.getMessage("ERROR_NO_DERIVED_PLATFORM", noPlatformVersionless.getValue())).append("\n"); + } + } + + String msg = sb.toString(); + return msg; + } + /** * Checks if the inputed version is newer than the newest version * diff --git a/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java b/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java index 6d28caa2fc9..4a6849dba5e 100755 --- a/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java +++ b/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java @@ -1052,8 +1052,10 @@ public Collection singleFileResolve() { data.put(InstallConstants.ACTION_RESULT, ERROR); InstallException ie = ExceptionUtils.create(e, e.getTopLevelFeaturesNotResolved(), (File) data.get(InstallConstants.RUNTIME_INSTALL_DIR), false, isOpenLiberty, isFeatureUtility); - data.put(InstallConstants.ACTION_ERROR_MESSAGE, ie.getMessage()); - data.put(InstallConstants.ACTION_EXCEPTION_STACKTRACE, ExceptionUtils.stacktraceToString(ie)); + if (ie != null) { + data.put(InstallConstants.ACTION_ERROR_MESSAGE, ie.getMessage()); + data.put(InstallConstants.ACTION_EXCEPTION_STACKTRACE, ExceptionUtils.stacktraceToString(ie)); + } } catch (InstallException e) { data.put(InstallConstants.ACTION_RESULT, ERROR); data.put(InstallConstants.ACTION_ERROR_MESSAGE, e.getMessage()); diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java index a1d37a2b289..72e6ad5cc3e 100755 --- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java +++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolutionException.java @@ -15,7 +15,6 @@ import java.util.Collection; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -44,7 +43,7 @@ public class RepositoryResolutionException extends RepositoryException { private final Map> featureConflicts; private Set resolvedPlatforms; private Set missingPlatforms; - private List missingBasePlatforms; + private Map> missingBasePlatforms; /** * @param cause @@ -79,7 +78,7 @@ public RepositoryResolutionException(ResolutionException cause, Collection topLevelFeaturesNotResolved, Collection allRequirementsNotFound, Collection missingProductInformation, Collection allRequirementsResourcesNotFound, Map> featureConflicts, Set resolvedPlatforms, Set missingPlatforms, - List missingBasePlatforms) { + Map> missingBasePlatforms) { super(cause); this.topLevelFeaturesNotResolved = topLevelFeaturesNotResolved; this.allRequirementsNotFound = allRequirementsNotFound; @@ -284,15 +283,6 @@ public Map> getFeatureConflicts() { public String getMessage() { StringBuilder sb = new StringBuilder(); - if (!getMissingPlatforms().isEmpty()) { - for (String missing : getMissingPlatforms()) { - sb.append("Platform: ").append(missing).append(" couldn't be found, no versionless features will be resolved").append("\n"); - } - } - if (getResolvedPlatforms().isEmpty() && getMissingPlatforms().isEmpty()) { - sb.append("Platform couldn't be determined, no versionless features will be resolved").append("\n"); - } - for (String missing : getTopLevelFeaturesNotResolved()) { sb.append("Top level feature not resolved: resource=").append(missing).append("\n"); } @@ -373,6 +363,7 @@ private String getResourceName(RepositoryResource resource) { /** * This states the target platforms that were used during the resolution + * * @return the resolvedPlatforms */ public Set getResolvedPlatforms() { @@ -381,6 +372,7 @@ public Set getResolvedPlatforms() { /** * This describes missspelled or unknown platform names, official names are collected by the feature metadata + * * @return the missingPlatforms */ public Set getMissingPlatforms() { @@ -388,10 +380,12 @@ public Set getMissingPlatforms() { } /** - * This describes base platforms like "jakartaee" that are not derived, either by passed platform values, or by other included versioned features + * This describes a Map of base platforms like "jakartaee" (associated with versionless features) that are not derived, either by passed platform values, or by other included + * versioned features + * * @return the missingBasePlatforms */ - public List getMissingBasePlatforms() { + public Map> getMissingBasePlatforms() { return missingBasePlatforms; } diff --git a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java index 8d823ad7b5a..ae766e4bce8 100755 --- a/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java +++ b/dev/com.ibm.ws.repository.resolver/src/com/ibm/ws/repository/resolver/RepositoryResolver.java @@ -149,6 +149,10 @@ public class RepositoryResolver { * returns if versionless features are part of the resolution - used to skip extra processing */ boolean includesVersionless; + /** + * Map of unresolved base platforms, and the associated passed versionless features + */ + Map> missingBasePlatforms; /** *

@@ -501,6 +505,7 @@ void initResolve() { missingRequirements = new ArrayList<>(); resolverRepository = null; featureConflicts = new HashMap<>(); + missingBasePlatforms = new HashMap<>(); resolvedPlatforms = new HashSet<>(); missingPlatforms = new HashSet<>(); includesVersionless = false; @@ -572,6 +577,7 @@ void resolveFeaturesAsSet() { includesVersionless = true; resolvedPlatforms = result.getResolvedPlatforms(); missingPlatforms = result.getMissingPlatforms(); + missingBasePlatforms = result.getNoPlatformVersionless(); } for (String name : result.getResolvedFeatures()) { @@ -999,25 +1005,6 @@ private void reportErrors() throws RepositoryResolutionException { return; } - List missingBasePlatforms = new ArrayList(); - - // Versionless features can't be resolved if a corresponding platform is not derived, making the choice ambiguous, and the feature won't be included in the resolved list. - will gather the associated platform unable to target. - if (includesVersionless) { - for (String name : missingTopLevelRequirements) { - ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name); - if (feature != null && feature.isVersionless()) { - List featureChildren = resolverRepository.findAllPossibleVersions(feature); - if (!featureChildren.isEmpty()) { - ProvisioningFeatureDefinition firstChild = featureChildren.get(0); - String plat = firstChild.getPlatformName(); - if (plat != null) {//This will add just the platform name without version - missingBasePlatforms.add(resolverRepository.getFeatureBaseName(plat)); - } - } - } - } - } - Set missingProductInformation = new HashSet<>(); for (ApplicableToProduct esa : resourcesWrongProduct) {