From d2716d46f9cc04cf1e6b5d9da71b18e75a0a1067 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Tue, 5 Sep 2023 14:21:02 -0400 Subject: [PATCH 1/6] Improve usability by printing helpful info before running long test cycle. Signed-off-by: Paul Gooderham --- .../src/it/binary-scanner-it/run-binary-scanner-it | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it b/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it index 7496004a7..5c54b7d0b 100755 --- a/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it +++ b/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it @@ -10,14 +10,18 @@ # five minutes for each test. cd liberty-maven-plugin/ cp src/it/binary-scanner-it/pom.xml /tmp -for i in 3.7 3.7.1 +for i in 3.8 3.8.1 3.8.2 do -sed "s/@pom.version@/$i/g" src/it/binary-scanner-it/pom.xml -mvn install verify -Ponline-its -Dinvoker.streamLogs=true -Druntime=ol -DruntimeVersion=23.0.0.1 -Dinvoker.test=binary-scanner-it echo !! +echo !! About to test using Liberty Maven Plugin version $i. +echo !! Each test runs for 5-10 minutes and then pauses here +echo !! so you can check the results. +echo !! You should already have followed the instructions in +echo !! the comments at the top of this script. echo !! PRESS ENTER TO CONTINUE echo !! -# Allow time to inspect the pass/fail status before continuing. read j +sed "s/@pom.version@/$i/g" src/it/binary-scanner-it/pom.xml +mvn install verify -Ponline-its -Dinvoker.streamLogs=true -Druntime=ol -DruntimeVersion=23.0.0.1 -Dinvoker.test=binary-scanner-it done cp /tmp/pom.xml src/it/binary-scanner-it/pom.xml From 5af08d23a743c347a6259eaa68390b3c33e645a3 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Tue, 5 Sep 2023 14:22:22 -0400 Subject: [PATCH 2/6] Remove parent tag because this causes an error running on a new machine and this test is not run as part of the IT bucket. Signed-off-by: Paul Gooderham --- liberty-maven-plugin/src/it/binary-scanner-it/pom.xml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/pom.xml b/liberty-maven-plugin/src/it/binary-scanner-it/pom.xml index a9c5c160c..ebe44005a 100755 --- a/liberty-maven-plugin/src/it/binary-scanner-it/pom.xml +++ b/liberty-maven-plugin/src/it/binary-scanner-it/pom.xml @@ -3,13 +3,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - io.openliberty.tools.it - tests - 1.0-SNAPSHOT - - binary-scanner-it + io.openliberty.tools.it + 1.0 jar @@ -67,7 +63,7 @@ @pom.version@ ${runtimeVersion} - 23.0.0.1-SNAPSHOT + 23.0.0.3-SNAPSHOT false From e53bd475a4dbfc497940dd7fc44538e739271128 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Wed, 6 Sep 2023 10:09:57 -0400 Subject: [PATCH 3/6] Add test project. Signed-off-by: Paul Gooderham --- .../resources/basic-dev-project10/pom.xml | 220 ++++++++++++++++++ .../src/main/java/com/demo/HelloLogger.java | 37 +++ .../src/main/java/com/demo/HelloServlet.java | 39 ++++ .../src/main/java/com/demo/HelloWorld.java | 34 +++ .../src/main/liberty/config/server.xml | 5 + 5 files changed, 335 insertions(+) create mode 100755 liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/pom.xml create mode 100755 liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloLogger.java create mode 100644 liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloServlet.java create mode 100755 liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloWorld.java create mode 100755 liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/liberty/config/server.xml diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/pom.xml b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/pom.xml new file mode 100755 index 000000000..fc755016e --- /dev/null +++ b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/pom.xml @@ -0,0 +1,220 @@ + + + + 4.0.0 + + binary-scanner-it-tests + dev-sample-proj + 1.0-SNAPSHOT + war + + + UTF-8 + UTF-8 + 1.7 + 1.7 + LibertyProject + + 9080 + 9443 + + usr + + + + + oss-sonatype + oss-sonatype + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + + + + + + io.openliberty.features + features-bom + RUNTIME_VERSION + pom + import + + + + + + + + jakarta.platform + jakarta.jakartaee-api + 10.0.0 + provided + + + org.eclipse.microprofile + microprofile + 6.0 + pom + provided + + + + junit + junit + 4.13.1 + test + + + org.apache.cxf + cxf-rt-rs-client + 3.2.6 + test + + + org.apache.cxf + cxf-rt-rs-extension-providers + 3.2.6 + test + + + org.glassfish + javax.json + 1.0.4 + test + + + + org.apache.commons + commons-lang3 + 3.0 + + + + javax.xml.bind + jaxb-api + 2.3.1 + provided + + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + provided + + + javax.activation + activation + 1.1.1 + provided + + + javax.batch + javax.batch-api + 1.0.1 + provided + + + + org.slf4j + slf4j-api + 1.7.25 + + + ch.qos.logback + logback-classic + 1.2.3 + runtime + + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + false + pom.xml + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M1 + + + test + default-test + + + **/it/** + + ${project.build.directory}/test-reports/unit + + + + + + + io.openliberty.tools + liberty-maven-plugin + SUB_VERSION + + + io.openliberty + openliberty-kernel + RUNTIME_VERSION + zip + + ${app.name} + ${packaging.type} + + ${testServerHttpPort} + ${testServerHttpsPort} + json + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M1 + + + integration-test + integration-test + + integration-test + + + + **/it/**/*.java + + + + ${testServerHttpPort} + + + + + + verify-results + + verify + + + + + ${project.build.directory}/test-reports/it/failsafe-summary.xml + ${project.build.directory}/test-reports/it + + + + + diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloLogger.java b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloLogger.java new file mode 100755 index 000000000..caea6b44b --- /dev/null +++ b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloLogger.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +package com.demo; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; + +import static jakarta.ws.rs.core.MediaType.TEXT_PLAIN; + +@Path("/show-log") +public class HelloLogger { + private static final Logger log = LoggerFactory.getLogger(HelloLogger.class); + + @GET + @Produces(TEXT_PLAIN) + public String showLog() { + log.info("Here is the Log"); + return "Log has been shown"; + } +} diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloServlet.java b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloServlet.java new file mode 100644 index 000000000..a5811dedc --- /dev/null +++ b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloServlet.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2019. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +package com.demo; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +@WebServlet(urlPatterns="/servlet") +public class HelloServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + private static final Logger log = LoggerFactory.getLogger(HelloLogger.class); + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + log.info("SLF4J Logger is ready for messages."); + response.getWriter().append("hello world"); + } +} \ No newline at end of file diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloWorld.java b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloWorld.java new file mode 100755 index 000000000..ec88aeba2 --- /dev/null +++ b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/java/com/demo/HelloWorld.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * (c) Copyright IBM Corporation 2022. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +package com.demo; + +import org.eclipse.microprofile.health.Liveness; +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; + +@Liveness +public class HelloWorld implements HealthCheck { + @Override + public HealthCheckResponse call() { + return HealthCheckResponse + .named("liveness check") + .build(); + } + + public String helloWorld() { + return "helloWorld"; + } +} diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/liberty/config/server.xml b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/liberty/config/server.xml new file mode 100755 index 000000000..7256d051f --- /dev/null +++ b/liberty-maven-plugin/src/it/binary-scanner-it/resources/basic-dev-project10/src/main/liberty/config/server.xml @@ -0,0 +1,5 @@ + + + + From 20f83bab23d728144eb71555bfab79baf0be585e Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Tue, 28 Nov 2023 18:42:35 -0500 Subject: [PATCH 4/6] Remove parent from pom and improve invocation script. Signed-off-by: Paul Gooderham --- liberty-maven-plugin/src/it/binary-scanner-it/pom.xml | 5 +++-- .../src/it/binary-scanner-it/run-binary-scanner-it | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/pom.xml b/liberty-maven-plugin/src/it/binary-scanner-it/pom.xml index ebe44005a..ebfe54b41 100755 --- a/liberty-maven-plugin/src/it/binary-scanner-it/pom.xml +++ b/liberty-maven-plugin/src/it/binary-scanner-it/pom.xml @@ -13,6 +13,8 @@ UTF-8 1.8 1.8 + + 23.0.0.5-SNAPSHOT @@ -62,8 +64,7 @@ @pom.version@ ${runtimeVersion} - - 23.0.0.3-SNAPSHOT + ${scanner.version} false diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it b/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it index 5c54b7d0b..b1c2d9268 100755 --- a/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it +++ b/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it @@ -1,7 +1,8 @@ # Manually cd to ci.maven to begin. # Run mvn clean install to build the current plugin. +# Ensure you are running a version of Maven supported by liberty-maven-plugin (e.g. Maven 3.8.6 for plugin 3.9) # Edit liberty-maven-plugin/src/it/binary-scanner-it/pom.xml and add the version of -# binary scanner you expect in . +# binary scanner you expect in . # Edit the loop below to specify the versions of the plugin you want to test: # for i in 3.7 3.7.1 <--change 3.7 to the current version # Execute the following command in the current directory ci.maven: @@ -10,7 +11,11 @@ # five minutes for each test. cd liberty-maven-plugin/ cp src/it/binary-scanner-it/pom.xml /tmp -for i in 3.8 3.8.1 3.8.2 +restorePOM () { + cp /tmp/pom.xml src/it/binary-scanner-it/pom.xml +} +trap restorePOM SIGINT +for i in 3.9 do echo !! echo !! About to test using Liberty Maven Plugin version $i. @@ -24,4 +29,4 @@ read j sed "s/@pom.version@/$i/g" src/it/binary-scanner-it/pom.xml mvn install verify -Ponline-its -Dinvoker.streamLogs=true -Druntime=ol -DruntimeVersion=23.0.0.1 -Dinvoker.test=binary-scanner-it done -cp /tmp/pom.xml src/it/binary-scanner-it/pom.xml +restorePOM From c4a3b93d4e7f5d8e5e0b989c601cf7f7717071d6 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Tue, 28 Nov 2023 19:15:47 -0500 Subject: [PATCH 5/6] Make compile timeout 30s instead of 20s. Signed-off-by: Paul Gooderham --- .../java/net/wasdev/wlp/test/dev/it/BaseScannerTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/src/test/java/net/wasdev/wlp/test/dev/it/BaseScannerTest.java b/liberty-maven-plugin/src/it/binary-scanner-it/src/test/java/net/wasdev/wlp/test/dev/it/BaseScannerTest.java index ba6c20ec3..e805a1b70 100644 --- a/liberty-maven-plugin/src/it/binary-scanner-it/src/test/java/net/wasdev/wlp/test/dev/it/BaseScannerTest.java +++ b/liberty-maven-plugin/src/it/binary-scanner-it/src/test/java/net/wasdev/wlp/test/dev/it/BaseScannerTest.java @@ -180,7 +180,7 @@ protected static void cleanUpAfterTest() throws Exception { /** * Runs process and waits for it to finish - * Times out after 20 seconds + * Times out after 30 seconds * * @param command - command to run */ @@ -194,8 +194,8 @@ protected static void runProcess(String processCommand) throws IOException, Inte OutputStream stdin = process.getOutputStream(); writer = new BufferedWriter(new OutputStreamWriter(stdin)); - // wait for process to finish max 20 seconds - process.waitFor(20, TimeUnit.SECONDS); + // wait for process to finish max 30 seconds + process.waitFor(30, TimeUnit.SECONDS); assertFalse(process.isAlive()); // save and print process output From fcbfabe8b43ce4d985bc2aad13aa77c665ded9cd Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Wed, 29 Nov 2023 11:55:43 -0500 Subject: [PATCH 6/6] Store Liberty Runtime Version as a variable for convenience. Clarify the instructions. Signed-off-by: Paul Gooderham --- .../src/it/binary-scanner-it/run-binary-scanner-it | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it b/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it index b1c2d9268..2a83b799d 100755 --- a/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it +++ b/liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it @@ -1,19 +1,21 @@ # Manually cd to ci.maven to begin. -# Run mvn clean install to build the current plugin. # Ensure you are running a version of Maven supported by liberty-maven-plugin (e.g. Maven 3.8.6 for plugin 3.9) +# Run mvn clean install to build the current plugin. # Edit liberty-maven-plugin/src/it/binary-scanner-it/pom.xml and add the version of # binary scanner you expect in . # Edit the loop below to specify the versions of the plugin you want to test: # for i in 3.7 3.7.1 <--change 3.7 to the current version # Execute the following command in the current directory ci.maven: # liberty-maven-plugin/src/it/binary-scanner-it/run-binary-scanner-it -# After each version is tested you must press Enter to continue. It takes about +# Before each version is tested you must press Enter to continue. It takes about # five minutes for each test. +RuntimeVer=23.0.0.1 cd liberty-maven-plugin/ cp src/it/binary-scanner-it/pom.xml /tmp restorePOM () { cp /tmp/pom.xml src/it/binary-scanner-it/pom.xml } +# In case someone types Ctrl-C restore the pom. trap restorePOM SIGINT for i in 3.9 do @@ -27,6 +29,6 @@ echo !! PRESS ENTER TO CONTINUE echo !! read j sed "s/@pom.version@/$i/g" src/it/binary-scanner-it/pom.xml -mvn install verify -Ponline-its -Dinvoker.streamLogs=true -Druntime=ol -DruntimeVersion=23.0.0.1 -Dinvoker.test=binary-scanner-it +mvn install verify -Ponline-its -Dinvoker.streamLogs=true -Druntime=ol -DruntimeVersion=$RuntimeVer -Dinvoker.test=binary-scanner-it done restorePOM