Skip to content

Commit

Permalink
Merge pull request #32571 from snazy/gradle-int-tests-win
Browse files Browse the repository at this point in the history
Gradle integration tests: tackle (Windows) CI issues
  • Loading branch information
aloubyansky authored Apr 15, 2023
2 parents da97cfc + 32f74e0 commit e9c5730
Show file tree
Hide file tree
Showing 26 changed files with 177 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-actions-incremental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ jobs:
MAVEN_OPTS: -Xmx1g
# Skip main in forks
if: "needs.calculate-test-jobs.outputs.run_gradle == 'true' && (github.repository == 'quarkusio/quarkus' || !endsWith(github.ref, '/main'))"
timeout-minutes: 80
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<!-- These 2 properties are used by CreateProjectMojo to add the Maven Wrapper -->
<proposed-maven-version>3.8.8</proposed-maven-version>
<maven-wrapper.version>3.2.0</maven-wrapper.version>
<gradle-wrapper.version>8.0.2</gradle-wrapper.version>
<gradle-wrapper.version>8.1</gradle-wrapper.version>
<quarkus-gradle-plugin.version>${project.version}</quarkus-gradle-plugin.version>
<quarkus-maven-plugin.version>${project.version}</quarkus-maven-plugin.version>
<maven-plugin-plugin.version>3.8.1</maven-plugin-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ public boolean isSatisfiedBy(Task t) {

tasks.register(BUILD_NATIVE_TASK_NAME, DefaultTask.class, task -> {
task.finalizedBy(quarkusBuild);
task.doFirst(t -> project.getLogger()
task.doFirst(t -> t.getLogger()
.warn("The 'buildNative' task has been deprecated in favor of 'build -Dquarkus.package.type=native'"));

});

configureBuildNativeTask(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ private void configureProcessWorkerSpec(ProcessWorkerSpec processWorkerSpec, Map

customizations.forEach(a -> a.execute(forkOptions));

String quarkusWorkerMaxHeap = System.getProperty("quarkus.gradle-worker.max-heap");
if (quarkusWorkerMaxHeap != null && forkOptions.getAllJvmArgs().stream().noneMatch(arg -> arg.startsWith("-Xmx"))) {
forkOptions.jvmArgs("-Xmx" + quarkusWorkerMaxHeap);
}

// Pass all environment variables
forkOptions.environment(System.getenv());

Expand Down
5 changes: 3 additions & 2 deletions devtools/gradle/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
# https://gradle.org/release-checksums/
distributionSha256Sum=2cbafcd2c47a101cb2165f636b4677fac0b954949c9429c1c988da399defe6a9
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion independent-projects/bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<plexus-utils.version>3.5.1</plexus-utils.version>
<smallrye-common.version>2.1.0</smallrye-common.version>
<smallrye-beanbag.version>1.1.0</smallrye-beanbag.version>
<gradle-tooling.version>8.0.2</gradle-tooling.version>
<gradle-tooling.version>8.1</gradle-tooling.version>
<quarkus-fs-util.version>0.0.9</quarkus-fs-util.version>
<org-crac.version>0.1.3</org-crac.version>
<formatter-maven-plugin.version>2.22.0</formatter-maven-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ language:
base:
data:
gradle:
version: 8.0.2
version: 8.1
shared-data:
buildtool:
cli: ./gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
"supported-maven-versions": "[3.6.2,)",
"proposed-maven-version": "3.8.8",
"maven-wrapper-version": "3.2.0",
"gradle-wrapper-version": "8.0.2"
"gradle-wrapper-version": "8.1"
}
},
"codestarts-artifacts": [
Expand Down
2 changes: 1 addition & 1 deletion independent-projects/tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<!-- These properties are used by CreateProjectMojo to add the Maven Wrapper -->
<proposed-maven-version>3.8.8</proposed-maven-version>
<maven-wrapper.version>3.2.0</maven-wrapper.version>
<gradle-wrapper.version>8.0.2</gradle-wrapper.version>
<gradle-wrapper.version>8.1</gradle-wrapper.version>

<!-- These properties are needed in order for them to be resolvable by the generated projects -->
<!-- Quarkus uses jboss-parent and it comes with 3.8.1-jboss-1, we don't want that in the templates -->
Expand Down
10 changes: 9 additions & 1 deletion integration-tests/gradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
version=999-SNAPSHOT

# Idle timeout in milliseconds
org.gradle.daemon.idletimeout=10000
systemProp.org.gradle.daemon.idletimeout=10000

# Override Java default heap size calculation for the Quarkus Gradle plugin worker processes, important for CI
systemProp.quarkus.gradle-worker.max-heap=256m

# Use the miniumu Java heap sizes for a Gradle daemon, important for CI
org.gradle.jvmargs=-Xms128m -Xmx256m \
-Dfile.encoding=UTF-8 \
-Duser.language=en -Duser.country=US -Duser.variant=
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
# https://gradle.org/release-checksums/
distributionSha256Sum=2cbafcd2c47a101cb2165f636b4677fac0b954949c9429c1c988da399defe6a9
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions integration-tests/gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@
</build>
</profile>
<profile>
<id>jdk19-workarounds</id>
<id>jdk20-workarounds</id>
<activation>
<jdk>[19,)</jdk>
<jdk>[20,)</jdk>
</activation>
<properties>
<!-- auto-exclude tests that are known to fail on JDK 19 or above (tagged via @Tag("failsOnJDK19")) -->
<excludedGroups>failsOnJDK19</excludedGroups>
<excludedGroups>failsOnJDK20</excludedGroups>
</properties>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.acme;

import io.quarkus.arc.config.ConfigProperties;
import io.smallrye.config.ConfigMapping;

@ConfigProperties(prefix = "example")
public class Config {
public String message;
@ConfigMapping(prefix = "example")
public interface Config {
public String message();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class ExampleResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return config.message;
return config.message();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ void verify(String packageType) {
private void verifyBuild(String override) throws IOException, InterruptedException, URISyntaxException {
File rootDir = getProjectDir(ROOT_PROJECT_NAME);
BuildResult buildResult = runGradleWrapper(rootDir, "clean", "quarkusBuild",
// Package type is not included in the Gradle cache inputs, see https://github.com/quarkusio/quarkus/issues/30852
"--no-build-cache",
override != null ? "-Dquarkus.package.type=" + override : "-Dfoo=bar");
soft.assertThat(buildResult.unsuccessfulTasks()).isEmpty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public void testFastJarFormatWorks() throws Exception {

final File projectDir = getProjectDir("test-that-fast-jar-format-works");

BuildResult result = runGradleWrapper(projectDir, "clean", "build");
result.getTasks().forEach((k, v) -> System.err.println(" " + k + " --> " + v));
System.err.println(result.getOutput());
runGradleWrapper(projectDir, "clean", "build");

final Path quarkusApp = projectDir.toPath().resolve("build").resolve("quarkus-app");
assertThat(quarkusApp).exists();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testProtocErrorOutput() throws Exception {
final Path protoDirectory = new File(projectDir, "application/src/main/proto/").toPath();
Files.copy(projectDir.toPath().resolve("invalid.proto"), protoDirectory.resolve("invalid.proto"));
try {
final BuildResult buildResult = runGradleWrapper(projectDir, ":application:quarkusBuild", "--info");
final BuildResult buildResult = runGradleWrapper(true, projectDir, ":application:quarkusBuild", "--info");
assertTrue(buildResult.getOutput().contains("invalid.proto:5:1: Missing field number."));
} finally {
Files.delete(protoDirectory.resolve("invalid.proto"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ public class JandexMultiModuleTest extends QuarkusGradleWrapperTestBase {

@Test
public void testBasicMultiModuleBuildKordamp() throws Exception {
// Kordamp Jandex plugin's not compatible w/ the Gradle configuration cache
gradleConfigurationCache(false);
jandexTest("jandex-basic-multi-module-project-kordamp", ":common:jandex");
}

@Test
public void testBasicMultiModuleBuildJandex() throws Exception {
gradleConfigurationCache(true);
jandexTest("jandex-basic-multi-module-project-vlsi", ":common:processJandexIndex");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static void disableDevToolsTestConfig() {

@Override
protected void setupTestCommand() {
gradleNoWatchFs(false);
for (Map.Entry<?, ?> prop : devToolsProps.entrySet()) {
setSystemProperty(prop.getKey().toString(), prop.getValue().toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.assertj.core.api.Assertions;

public class QuarkusGradleWrapperTestBase extends QuarkusGradleTestBase {

private static final String GRADLE_WRAPPER_WINDOWS = "gradlew.bat";
Expand All @@ -19,33 +21,66 @@ public class QuarkusGradleWrapperTestBase extends QuarkusGradleTestBase {

private Map<String, String> systemProps;

private boolean configurationCacheEnable = true;
private boolean noWatchFs = true;

protected void setupTestCommand() {

}

/**
* Gradle's configuration cache is enabled by default for all tests. This option can be used to disable the
* configuration test.
*/
protected void gradleConfigurationCache(boolean configurationCacheEnable) {
this.configurationCacheEnable = configurationCacheEnable;
}

/**
* Gradle is run by default with {@code --no-watch-fs} to reduce I/O load during tests. Some tests might run into issues
* with this option.
*/
protected void gradleNoWatchFs(boolean noWatchFs) {
this.noWatchFs = noWatchFs;
}

public BuildResult runGradleWrapper(File projectDir, String... args) throws IOException, InterruptedException {
return runGradleWrapper(false, projectDir, args);
}

public BuildResult runGradleWrapper(boolean expectError, File projectDir, String... args)
throws IOException, InterruptedException {
setupTestCommand();
List<String> command = new ArrayList<>();
command.add(getGradleWrapperCommand());
addSystemProperties(command);
command.add("-Dorg.gradle.console=plain");
command.add("-Dorg.gradle.daemon=false");
command.add("--configuration-cache");
if (configurationCacheEnable) {
command.add("--configuration-cache");
}
command.add("--stacktrace");
if (noWatchFs) {
command.add("--no-watch-fs");
}
command.add("--info");
command.add("--daemon");
command.addAll(Arrays.asList(args));

File logOutput = new File(projectDir, "command-output.log");

System.out.println("$ " + String.join(" ", command));
Process p = new ProcessBuilder()
ProcessBuilder pb = new ProcessBuilder()
.directory(projectDir)
.command(command)
.redirectInput(ProcessBuilder.Redirect.INHERIT)
.redirectError(logOutput)
.redirectOutput(logOutput)
.start();
// Should prevent "fragmented" output (parts of stdout and stderr interleaved)
.redirectErrorStream(true);
if (System.getenv("JAVA_HOME") == null) {
// This helps running the tests in IntelliJ w/o configuring an explicit JAVA_HOME env var.
pb.environment().put("JAVA_HOME", System.getProperty("java.home"));
}
Process p = pb.start();

//long timeout for native tests
//that may also need to download docker
Expand All @@ -55,8 +90,14 @@ public BuildResult runGradleWrapper(File projectDir, String... args) throws IOEx
}
final BuildResult commandResult = BuildResult.of(logOutput);
int exitCode = p.exitValue();
if (exitCode != 0) {

// The test failed, if the Gradle build exits with != 0 and the tests expects no failure, or if the test
// expects a failure and the exit code is 0.
if (expectError == (exitCode == 0)) {
// Only print the output, if the test does not expect a failure.
printCommandOutput(projectDir, command, commandResult, exitCode);
// Fail hard, if the test does not expect a failure.
Assertions.fail("Gradle build failed with exit code %d", exitCode);
}
return commandResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import com.google.common.collect.ImmutableMap;

@org.junit.jupiter.api.Tag("failsOnJDK19")
@org.junit.jupiter.api.Tag("failsOnJDK20")
public class BasicKotlinApplicationModuleDevModeTest extends QuarkusDevGradleTestBase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Disabled;

import com.google.common.collect.ImmutableMap;

@Disabled
@org.junit.jupiter.api.Tag("failsOnJDK19")
@org.junit.jupiter.api.Tag("failsOnJDK20")
public class MultiModuleKotlinProjectDevModeTest extends QuarkusDevGradleTestBase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.google.common.collect.ImmutableMap;

@org.junit.jupiter.api.Tag("failsOnJDK19")
@org.junit.jupiter.api.Tag("failsOnJDK20")
public class MultiSourceProjectDevModeTest extends QuarkusDevGradleTestBase {

@Override
Expand Down
Loading

0 comments on commit e9c5730

Please sign in to comment.