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

[1.11] Adapt Start Stop TS to Windows #79

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
50 changes: 42 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
6 changes: 4 additions & 2 deletions app-full-microprofile/threshold.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions app-jax-rs-minimal/threshold.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 21 additions & 12 deletions testsuite/src/it/java/io/quarkus/ts/startstop/SpecialCharsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
Expand All @@ -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, ",;~!@#$%^&()");
}
Expand All @@ -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, "ěščřžýáíéůú");
}
Expand All @@ -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, "元気かい");
}
Expand All @@ -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.
}
}

}
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 @@ -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);
}
Expand Down
Loading