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 a2d1c931..2c948539 100644 --- a/testsuite/src/it/java/io/quarkus/ts/startstop/SpecialCharsTest.java +++ b/testsuite/src/it/java/io/quarkus/ts/startstop/SpecialCharsTest.java @@ -130,7 +130,7 @@ public void testRuntime(TestInfo testInfo, Apps app, MvnCmds mvnCmds, String sub // Test web page LOGGER.info("Testing web page content..."); - int timeout = mvnCmds != MvnCmds.DEV ? 5 : 60; + int timeout = mvnCmds != MvnCmds.DEV ? 30 : 120; for (String[] urlContent : app.urlContent.urlContent) { WebpageTester.testWeb(urlContent[0], timeout, urlContent[1], false); } diff --git a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/Commands.java b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/Commands.java index df7a1561..e81b0a7d 100644 --- a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/Commands.java +++ b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/Commands.java @@ -19,18 +19,8 @@ */ package io.quarkus.ts.startstop.utils; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.jboss.logging.Logger; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; +import static io.quarkus.ts.startstop.StartStopTest.BASE_DIR; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; @@ -49,6 +39,9 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -63,7 +56,24 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import static io.quarkus.ts.startstop.StartStopTest.BASE_DIR; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.jboss.logging.Logger; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Michal Karm Babacek @@ -71,12 +81,15 @@ public class Commands { private static final Logger LOGGER = Logger.getLogger(Commands.class.getName()); - public static final String MVNW = Commands.isThisWindows ? "mvnw.cmd" : "./mvnw"; public static final boolean isThisWindows = System.getProperty("os.name").matches(".*[Ww]indows.*"); private static final Pattern numPattern = Pattern.compile("[ \t]*[0-9]+[ \t]*"); private static final Pattern quarkusVersionPattern = Pattern.compile("[ \t]*([^<]*).*"); private static final Pattern trailingSlash = Pattern.compile("/+$"); + public static String mvnw() { + return Commands.isThisWindows ? "mvnw.cmd" : "./mvnw"; + } + public static String getArtifactGeneBaseDir() { for (String p : new String[]{"ARTIFACT_GENERATOR_WORKSPACE", "artifact.generator.workspace"}) { String env = System.getenv().get(p); @@ -304,11 +317,12 @@ public static List getGeneratorCommand(String[] baseCommand, String[] ex * @throws IOException */ public static String download(Collection extensions, String destinationZipFile) throws IOException { + disableSslVerification(); String downloadURL = getCodeQuarkusURL() + "/api/download?s=" + extensions.stream().map(x -> x.shortId).collect(Collectors.joining(".")); try (ReadableByteChannel readableByteChannel = Channels.newChannel( new URL(downloadURL).openStream()); - FileChannel fileChannel = new FileOutputStream(destinationZipFile).getChannel()) { + FileChannel fileChannel = new FileOutputStream(destinationZipFile).getChannel()) { fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE); } return downloadURL; @@ -425,7 +439,7 @@ public static void pidKiller(long pid, boolean force) { if (!force) { Process p = Runtime.getRuntime().exec(new String[]{ BASE_DIR + File.separator + "testsuite" + File.separator + "src" + File.separator + "it" + File.separator + "resources" + File.separator + - "CtrlC.exe ", Long.toString(pid)}); + "CtrlC.exe ", Long.toString(pid)}); p.waitFor(1, TimeUnit.MINUTES); } Runtime.getRuntime().exec(new String[]{"cmd", "/C", "taskkill", "/PID", Long.toString(pid), "/F", "/T"}); @@ -451,7 +465,7 @@ public static long getRSSkB(long pid) throws IOException, InterruptedException { pa.redirectErrorStream(true); Process p = pa.start(); try (BufferedReader processOutputReader = - new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) { + new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) { String l; while ((l = processOutputReader.readLine()) != null) { if (numPattern.matcher(l).matches()) { @@ -481,7 +495,7 @@ public static long getOpenedFDs(long pid) throws IOException, InterruptedExcepti pa.redirectErrorStream(true); Process p = pa.start(); try (BufferedReader processOutputReader = - new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) { + new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) { if (isThisWindows) { String l; // TODO: We just get a magical number with all FDs... Is it O.K.? @@ -525,7 +539,7 @@ public static long getOpenedFDs(long pid) throws IOException, InterruptedExcepti 29,310,015 branch-misses:u # 3.19% of all branches 3.473028811 seconds time elapsed - */ + */ public static void processStopper(Process p, boolean force) throws InterruptedException, IOException { p.children().forEach(child -> { @@ -541,6 +555,46 @@ public static void processStopper(Process p, boolean force) throws InterruptedEx pidKiller(p.pid(), force); } + private static void disableSslVerification() { + try + { + // Create a trust manager that does not validate certificate chains + TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + @Override + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + @Override + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + } + }; + + // Install the all-trusting trust manager + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + + // Create all-trusting host name verifier + HostnameVerifier allHostsValid = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + + // Install the all-trusting host verifier + HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (KeyManagementException e) { + e.printStackTrace(); + } + } + public static class ProcessRunner implements Runnable { final File directory; final File log; diff --git a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/MvnCmds.java b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/MvnCmds.java index 91b91a9b..1e234b1a 100755 --- a/testsuite/src/it/java/io/quarkus/ts/startstop/utils/MvnCmds.java +++ b/testsuite/src/it/java/io/quarkus/ts/startstop/utils/MvnCmds.java @@ -54,14 +54,14 @@ public enum MvnCmds { } }), MVNW_DEV(new String[][]{ - new String[]{Commands.MVNW, "quarkus:dev"} + new String[]{Commands.mvnw(), "quarkus:dev"} }), MVNW_JVM(new String[][]{ - new String[]{Commands.MVNW, "clean", "compile", "quarkus:build", "-Dquarkus.package.output-name=quarkus"}, + new String[]{Commands.mvnw(), "clean", "compile", "quarkus:build", "-Dquarkus.package.output-name=quarkus"}, new String[]{"java", "-jar", "target/quarkus-app/quarkus-run.jar"} }), MVNW_NATIVE(new String[][]{ - Stream.concat(Stream.of(Commands.MVNW, "clean", "compile", "package", "-Pnative", "-Dquarkus.package.output-name=quarkus"), + Stream.concat(Stream.of(Commands.mvnw(), "clean", "compile", "package", "-Pnative", "-Dquarkus.package.output-name=quarkus"), getQuarkusNativeProperties().stream()).toArray(String[]::new), new String[]{Commands.isThisWindows ? "target\\quarkus-runner" : "./target/quarkus-runner"} }); 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 05f1fd33..57af6e3d 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 @@ -68,7 +68,7 @@ public enum WhitelistLogLines { // When GraalVM is used; unrelated to the test Pattern.compile(".*forcing TieredStopAtLevel to full optimization because JVMCI is enabled.*"), Pattern.compile(".*error_prone_annotations.*"), - Pattern.compile(".*SRGQL010000: Schema is null, or it has no operations. Not bootstrapping SmallRye GraphQL*"), + Pattern.compile(".*SRGQL010000: Schema is null, or it has no operations. Not bootstrapping SmallRye GraphQL.*"), Pattern.compile(".*No WebJars were found in the project.*"), 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 @@ -124,6 +124,10 @@ public final Pattern[] platformErrs() { 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:.*"), + // When network failures, Windows uses translateErrorToIOException method to throw IO exceptions + // The problem is that the method name contains "Error" and hence it became an offending line. + // For example: this is happening with using Mongo extension (without a Mongo instance). + Pattern.compile(".*translateErrorToIOException.*"), }; case LINUX: return new Pattern[] {