From 1493b26a04201a412c347911b5cf4aa8dab5234c Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 5 May 2021 08:08:27 +0200 Subject: [PATCH] Adapt Start Stop TS to Windows Backport of https://github.com/quarkus-qe/quarkus-startstop/pull/75. Won't run Native as it's not working on 1.11 due to https://github.com/quarkusio/quarkus/issues/14904 --- .github/workflows/ci.yaml | 50 ++++++++++++++++--- app-full-microprofile/threshold.properties | 6 ++- app-jax-rs-minimal/threshold.properties | 6 ++- .../ts/startstop/SpecialCharsTest.java | 33 +++++++----- .../ts/startstop/utils/LogBuilder.java | 7 +++ .../io/quarkus/ts/startstop/utils/Logs.java | 13 +++++ .../ts/startstop/utils/WhitelistLogLines.java | 44 +++++++++++++++- 7 files changed, 133 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e7df8433..c893468e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,8 +4,8 @@ on: schedule: - cron: '0 23 * * *' jobs: - build-released-jvm: - name: JVM build - released Quarkus + linux-build-released-jvm: + name: Linux - JVM build - released Quarkus runs-on: ubuntu-latest strategy: matrix: @@ -28,15 +28,15 @@ jobs: - name: Zip Artifacts if: failure() run: | - zip -r artifacts-jvm${{ matrix.java }}.zip . -i '*-reports/*' '*/archived-logs/*' + zip -r artifacts-linux-jvm${{ matrix.java }}.zip . -i '*-reports/*' '*/archived-logs/*' - name: Archive artifacts uses: actions/upload-artifact@v1 if: failure() with: name: ci-artifacts - path: artifacts-jvm${{ matrix.java }}.zip - build-released-native: - name: Native build - released Quarkus + path: artifacts-linux-jvm${{ matrix.java }}.zip + linux-build-released-native: + name: Linux - Native build - released Quarkus runs-on: ubuntu-latest strategy: matrix: @@ -59,10 +59,44 @@ jobs: - name: Zip Artifacts if: failure() run: | - zip -r artifacts-native${{ matrix.java }}.zip . -i '*-reports/*' '*/archived-logs/*' + zip -r artifacts-linux-native${{ matrix.java }}.zip . -i '*-reports/*' '*/archived-logs/*' - name: Archive artifacts uses: actions/upload-artifact@v1 if: failure() with: name: ci-artifacts - path: artifacts-native${{ matrix.java }}.zip + path: artifacts-linux-native${{ matrix.java }}.zip + windows-build-released-jvm: + name: Windows - JVM build - released Quarkus + runs-on: windows-latest + strategy: + matrix: + java: [ 11 ] + steps: + - uses: actions/checkout@v1 + - uses: actions/cache@v1 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Install JDK {{ matrix.java }} + uses: joschi/setup-jdk@e87a7cec853d2dd7066adf837fe12bf0f3d45e52 + with: + java-version: ${{ matrix.java }} + - name: Build with Maven + shell: bash + run: | + mvn -V -B -s .github/mvn-settings.xml clean verify -DexcludeTags='product,native,codequarkus' + - name: Zip Artifacts + if: failure() + shell: bash + run: | + # Disambiguate windows find from cygwin find + /usr/bin/find . -name '*-reports' -o -name 'archived-logs' -type d | tar -czf artifacts-windows-jvm${{ matrix.java }}.tar -T - + - name: Archive artifacts + uses: actions/upload-artifact@v1 + if: failure() + with: + name: ci-artifacts + path: artifacts-windows-jvm${{ matrix.java }}.tar \ No newline at end of file diff --git a/app-full-microprofile/threshold.properties b/app-full-microprofile/threshold.properties index 4a9f967f..366e0ae2 100644 --- a/app-full-microprofile/threshold.properties +++ b/app-full-microprofile/threshold.properties @@ -2,5 +2,7 @@ linux.jvm.time.to.first.ok.request.threshold.ms=2600 linux.jvm.RSS.threshold.kB=550000 linux.native.time.to.first.ok.request.threshold.ms=50 linux.native.RSS.threshold.kB=120000 -windows.jvm.time.to.first.ok.request.threshold.ms=2500 -windows.jvm.RSS.threshold.kB=4000 +windows.jvm.time.to.first.ok.request.threshold.ms=4500 +windows.jvm.RSS.threshold.kB=4600 +windows.native.time.to.first.ok.request.threshold.ms=1600 +windows.native.RSS.threshold.kB=120000 diff --git a/app-jax-rs-minimal/threshold.properties b/app-jax-rs-minimal/threshold.properties index 39433037..976f20b8 100644 --- a/app-jax-rs-minimal/threshold.properties +++ b/app-jax-rs-minimal/threshold.properties @@ -2,5 +2,7 @@ linux.jvm.time.to.first.ok.request.threshold.ms=2000 linux.jvm.RSS.threshold.kB=380000 linux.native.time.to.first.ok.request.threshold.ms=35 linux.native.RSS.threshold.kB=90000 -windows.jvm.time.to.first.ok.request.threshold.ms=2000 -windows.jvm.RSS.threshold.kB=4000 +windows.jvm.time.to.first.ok.request.threshold.ms=4500 +windows.jvm.RSS.threshold.kB=4500 +windows.native.time.to.first.ok.request.threshold.ms=800 +windows.native.RSS.threshold.kB=90000 diff --git a/testsuite/src/it/java/io/quarkus/ts/startstop/SpecialCharsTest.java b/testsuite/src/it/java/io/quarkus/ts/startstop/SpecialCharsTest.java index 958762d3..4367cfe1 100644 --- a/testsuite/src/it/java/io/quarkus/ts/startstop/SpecialCharsTest.java +++ b/testsuite/src/it/java/io/quarkus/ts/startstop/SpecialCharsTest.java @@ -67,10 +67,7 @@ public void testRuntime(TestInfo testInfo, Apps app, MvnCmds mvnCmds, String sub // Clean target directory cleanTarget(app); - // Delete dir with special chars - if (appDestDir.exists()) { - FileUtils.deleteDirectory(appDestDir); - } + removeDirWithSpecialCharacters(appDestDir); // Make dir with special chars if (!appDestDir.mkdir()) { @@ -154,28 +151,24 @@ public void testRuntime(TestInfo testInfo, Apps app, MvnCmds mvnCmds, String sub } writeReport(cn, mn, whatIDidReport.toString()); - // Remove dir with special chars - if (appDestDir.exists()) { - FileUtils.deleteDirectory(appDestDir); - } + removeDirWithSpecialCharacters(appDestDir); } } - @Test public void spacesJVM(TestInfo testInfo) throws IOException, InterruptedException { - testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.JVM, "s p a c e s"); + testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.JVM, "s p a c e s j v m"); } @Test public void spacesDEV(TestInfo testInfo) throws IOException, InterruptedException { - testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.DEV, "s p a c e s"); + testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.DEV, "s p a c e s d e v"); } @Test @Tag("native") public void spacesNative(TestInfo testInfo) throws IOException, InterruptedException { - testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.NATIVE, "s p a c e s"); + testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.NATIVE, "s p a c e s n a t i v e"); } @Test @@ -191,6 +184,7 @@ public void specialDEV(TestInfo testInfo) throws IOException, InterruptedExcepti @Test @Tag("native") + @DisabledOnOs({OS.WINDOWS}) // https://github.com/quarkusio/quarkus/issues/9707 public void specialNative(TestInfo testInfo) throws IOException, InterruptedException { testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.NATIVE, ",;~!@#$%^&()"); } @@ -201,12 +195,14 @@ public void diacriticsJVM(TestInfo testInfo) throws IOException, InterruptedExce } @Test + @DisabledOnOs({OS.WINDOWS}) // https://github.com/quarkusio/quarkus/issues/9707 public void diacriticsDEV(TestInfo testInfo) throws IOException, InterruptedException { testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.DEV, "ěščřžýáíéůú"); } @Test @Tag("native") + @DisabledOnOs({OS.WINDOWS}) // https://github.com/quarkusio/quarkus/issues/9707 public void diacriticsNative(TestInfo testInfo) throws IOException, InterruptedException { testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.NATIVE, "ěščřžýáíéůú"); } @@ -224,6 +220,7 @@ public void japaneseDEV(TestInfo testInfo) throws IOException, InterruptedExcept @Test @Tag("native") + @DisabledOnOs({OS.WINDOWS}) // https://github.com/quarkusio/quarkus/issues/9707 public void japaneseNative(TestInfo testInfo) throws IOException, InterruptedException { testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.NATIVE, "元気かい"); } @@ -241,8 +238,20 @@ public void otherDEV(TestInfo testInfo) throws IOException, InterruptedException @Test @Tag("native") + @DisabledOnOs({OS.WINDOWS}) // https://github.com/quarkusio/quarkus/issues/9707 public void otherNative(TestInfo testInfo) throws IOException, InterruptedException { testRuntime(testInfo, Apps.JAX_RS_MINIMAL, MvnCmds.NATIVE, "Îñţérñåţîöñåļîžåţîờñ"); } + private void removeDirWithSpecialCharacters(File appDestDir) { + // Remove dir with special chars + try { + if (appDestDir.exists()) { + FileUtils.deleteDirectory(appDestDir); + } + } catch (IOException ignored) { + // ignored when the folder could not be deleted. + } + } + } diff --git a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/LogBuilder.java b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/LogBuilder.java index a59ca88f..a89f7178 100644 --- a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/LogBuilder.java +++ b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/LogBuilder.java @@ -92,6 +92,13 @@ public LogBuilder startedInMs(long startedInMs) { } public LogBuilder stoppedInMs(long stoppedInMs) { + // Quarkus is not being gratefully shutdown in Windows when running in Dev mode. + // Reported by https://github.com/quarkusio/quarkus/issues/14647. + if (stoppedInMs <= 0 && Commands.isThisWindows) { + // do nothing in Windows + return this; + } + if (stoppedInMs <= 0) { throw new IllegalArgumentException("stoppedInMs must be a positive long, was: " + stoppedInMs); } diff --git a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/Logs.java b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/Logs.java index cb22175f..9acfcbc2 100644 --- a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/Logs.java +++ b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/Logs.java @@ -38,6 +38,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.stream.Stream; import static io.quarkus.ts.startstop.StartStopTest.BASE_DIR; import static io.quarkus.ts.startstop.utils.Commands.isThisWindows; @@ -72,6 +73,7 @@ public class Logs { private static final Pattern stoppedPatternControlSymbols = Pattern.compile(".* stopped in .*188m([0-9\\.]+).*", Pattern.DOTALL); private static final Pattern warnErrorDetectionPattern = Pattern.compile("(?i:.*(ERROR|WARN|SLF4J:).*)"); + private static final Pattern devModeError = Pattern.compile(".*Failed to run: Dev mode process did not complete successfully.*"); private static final Pattern listeningOnDetectionPattern = Pattern.compile("(?i:.*Listening on:.*)"); private static final Pattern devExpectedHostPattern = Pattern.compile("(?i:.*localhost:.*)"); private static final Pattern defaultExpectedHostPattern = Pattern.compile("(?i:.*0.0.0.0:.*)"); @@ -94,6 +96,13 @@ public static void checkLog(String testClass, String testMethod, Apps app, MvnCm } } } + + // Randomly fails when vertx-cache temporary directory exists. Related to https://github.com/quarkusio/quarkus/issues/7678 + // And https://github.com/quarkusio/quarkus/pull/15541/files#diff-a38e0d86cf6a637c19b6e0a0e23959f644886bdcc0f0e5615ce7cfa0e6bc9909R244 + if (Commands.isThisWindows && isDevModeError(offendingLines)) { + Stream.of(WhitelistLogLines.WINDOWS_DEV_MODE_ERRORS.errs).forEach(lineToIgnore -> offendingLines.removeIf(line -> lineToIgnore.matcher(line).matches())); + } + assertTrue(offendingLines.isEmpty(), cmd.name() + " log should not contain error or warning lines that are not whitelisted. " + "See testsuite" + File.separator + "target" + File.separator + "archived-logs" + @@ -125,6 +134,10 @@ public static void checkListeningHost(String testClass, String testMethod, MvnCm " and check the listening host."); } + private static boolean isDevModeError(Set offendingLines) { + return offendingLines.stream().anyMatch(line -> devModeError.matcher(line).matches()); + } + private static boolean isWhiteListed(Pattern[] patterns, String line) { for (Pattern p : patterns) { if (p.matcher(line).matches()) { diff --git a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/WhitelistLogLines.java b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/WhitelistLogLines.java index e09496a3..05f1fd33 100755 --- a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/WhitelistLogLines.java +++ b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/WhitelistLogLines.java @@ -73,9 +73,30 @@ public enum WhitelistLogLines { Pattern.compile(".*This application uses the MP Metrics API. The micrometer extension currently provides a compatibility layer that supports the MP Metrics API, but metric names and recorded values will be different. Note that the MP Metrics compatibility layer will move to a different extension in the future.*"), // kubernetes-client tries to configure client from service account Pattern.compile(".*Error reading service account token from.*"), + // hibernate-orm issues this warning when default datasource is ambiguous + // (no explicit configuration, none or multiple JDBC driver extensions) + // Result of DevServices support https://github.com/quarkusio/quarkus/pull/14960 + Pattern.compile(".*Unable to determine a database type for default datasource.*"), // Maven 3.8.1 throw a warn msg related to a mirror default configuration Pattern.compile(".*org.apache.maven.settings.io.SettingsParseException: Unrecognised tag: 'blocked'.*"), + }), + // Quarkus is not being gratefully shutdown in Windows when running in Dev mode. + // Reported by https://github.com/quarkusio/quarkus/issues/14647. + WINDOWS_DEV_MODE_ERRORS(new Pattern[]{ + Pattern.compile(".*Re-run Maven using the -X switch to enable full debug logging.*"), + Pattern.compile(".*For more information about the errors and possible solutions, please read the following articles.*"), + Pattern.compile(".*Failed to run: Dev mode process did not complete successfully.*"), + Pattern.compile(".*http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException.*"), + Pattern.compile(".*To see the full stack trace of the errors, re-run Maven with the -e switch.*"), + Pattern.compile("\\[ERROR\\] *"), }); + + // Depending to the OS and also on the Quarkus extensions, the Native build might print some warnings about duplicate entries + private static final Pattern COMMON_WARNING_DUPLICATE_ENTRY_NATIVE = Pattern.compile(".*Duplicate entry about.html entry.*"); + private static final Pattern COMMON_WARNING_DUPLICATE_ENTRIES_NATIVE = Pattern.compile(".*Dependencies with duplicate files detected.*"); + // When + private static final Pattern WARNING_MISSING_OBJCOPY_NATIVE = Pattern.compile(".*objcopy executable not found in PATH. Debug symbols will not be separated from executable.*"); + private static final Pattern WARNING_MISSING_OBJCOPY_RESULT_NATIVE = Pattern.compile(".*That will result in a larger native image with debug symbols embedded in it.*"); public final Pattern[] errs; @@ -87,8 +108,27 @@ public final Pattern[] platformErrs() { switch (OS.current()) { case MAC: return new Pattern[] { - Pattern.compile(".*objcopy executable not found in PATH. Debug symbols will not be separated from executable.*"), - Pattern.compile(".*That will result in a larger native image with debug symbols embedded in it.*"), + COMMON_WARNING_DUPLICATE_ENTRY_NATIVE, + COMMON_WARNING_DUPLICATE_ENTRIES_NATIVE, + WARNING_MISSING_OBJCOPY_NATIVE, + WARNING_MISSING_OBJCOPY_RESULT_NATIVE, + }; + case WINDOWS: + return new Pattern[] { + COMMON_WARNING_DUPLICATE_ENTRY_NATIVE, + COMMON_WARNING_DUPLICATE_ENTRIES_NATIVE, + WARNING_MISSING_OBJCOPY_NATIVE, + WARNING_MISSING_OBJCOPY_RESULT_NATIVE, + Pattern.compile(".*Uber JAR strategy is used for native image source JAR generation on Windows.*"), + // Randomly fails when vertx-cache temporary directory exists. Reported by https://github.com/quarkusio/quarkus/issues/16895 + Pattern.compile(".*Unable to make the Vert.x cache directory.*"), + // Randomly prints some SLF4J traces. Reported by https://github.com/quarkusio/quarkus/issues/16896 + Pattern.compile(".*SLF4J:.*"), + }; + case LINUX: + return new Pattern[] { + COMMON_WARNING_DUPLICATE_ENTRY_NATIVE, + COMMON_WARNING_DUPLICATE_ENTRIES_NATIVE, }; } return new Pattern[] {};