Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More changes windows #83

Merged
merged 5 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
90 changes: 72 additions & 18 deletions testsuite/src/it/java/io/quarkus/ts/startstop/utils/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -63,20 +56,40 @@
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 <[email protected]>
*/
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]*<quarkus.version>([^<]*)</quarkus.version>.*");
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);
Expand Down Expand Up @@ -304,11 +317,12 @@ public static List<String> getGeneratorCommand(String[] baseCommand, String[] ex
* @throws IOException
*/
public static String download(Collection<CodeQuarkusExtensions> 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;
Expand Down Expand Up @@ -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"});
Expand All @@ -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()) {
Expand Down Expand Up @@ -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.?
Expand Down Expand Up @@ -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 -> {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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[] {
Expand Down