Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf6f7e4f

Browse files
Merge pull request#46945 from holly-cummins/tests-for-test-retries
Add tests to make sure our test framework tolerates maven reruns even with test profiles
2 parentsc749166 +b516d18 commitf6f7e4f

File tree

13 files changed

+478
-1
lines changed

13 files changed

+478
-1
lines changed

‎integration-tests/maven/src/test/java/io/quarkus/maven/it/FlakyDevMojoIT.java‎renamed to ‎integration-tests/maven/src/test/java/io/quarkus/maven/it/AuxiliaryTestsForDevMojoIT.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* This test has been isolated as it is very flaky and causing issues with Develocity PTS.
2020
*/
2121
@DisableForNative
22-
publicclassFlakyDevMojoITextendsRunAndCheckMojoTestBase {
22+
publicclassAuxiliaryTestsForDevMojoITextendsRunAndCheckMojoTestBase {
2323

2424
protectedDevModeClientdevModeClient =newDevModeClient(getPort());
2525

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
packageio.quarkus.maven.it;
2+
3+
importstaticorg.assertj.core.api.Assertions.assertThat;
4+
importstaticorg.awaitility.Awaitility.await;
5+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
6+
7+
importjava.io.IOException;
8+
importjava.util.Arrays;
9+
importjava.util.Collections;
10+
importjava.util.concurrent.TimeUnit;
11+
12+
importorg.apache.maven.shared.invoker.MavenInvocationException;
13+
importorg.junit.jupiter.api.Test;
14+
15+
importio.quarkus.maven.it.verifier.MavenProcessInvocationResult;
16+
importio.quarkus.maven.it.verifier.RunningInvoker;
17+
18+
/**
19+
* Test that `mvn -Dsurefire.rerunFailingTestsCount=xx test` (where xx is more than one) works with QuarkusTests,
20+
* win the case when a test fails.
21+
*/
22+
@DisableForNative
23+
publicclassSurefireRerunFailedTestsITextendsRunAndCheckMojoTestBase {
24+
25+
@Test
26+
publicvoidtestFlakyTestsInSingleProfileCase()throwsMavenInvocationException,IOException {
27+
testDir =initProject("projects/test-flaky-test-single-profile","projects/test-flaky-test-single-profile-processed");
28+
finalRunningInvokerrunning =newRunningInvoker(testDir,false);
29+
30+
// trigger mvn verify -Dsurefire.rerunFailingTestsCount=2
31+
finalString[]mvnArgs =newString[] {"verify","-Dsurefire.rerunFailingTestsCount=3" };
32+
finalMavenProcessInvocationResultresult =running.execute(Arrays.asList(mvnArgs),Collections.emptyMap());
33+
await().atMost(5,TimeUnit.MINUTES)
34+
.until(() ->result.getProcess() !=null && !result.getProcess()
35+
.isAlive());
36+
finalStringprocessLog =running.log();
37+
assertEquals(running.getResult()
38+
.getExitCode(),0);
39+
assertThat(processLog).containsIgnoringCase("BUILD SUCCESS");
40+
// Also do a sense check that the test is functioning correctly and did have a failed execution first
41+
assertThat(processLog).containsIgnoringCase("deliberate failure run 1");
42+
assertThat(processLog).containsIgnoringCase("Run 2: PASS");
43+
}
44+
45+
@Test
46+
publicvoidtestFlakyTestsInMultipleProfileCase()throwsMavenInvocationException,IOException {
47+
testDir =initProject("projects/test-flaky-test-multiple-profiles",
48+
"projects/test-flaky-test-multiple-profiles-processed");
49+
finalRunningInvokerrunning =newRunningInvoker(testDir,false);
50+
51+
// trigger mvn verify -Dsurefire.rerunFailingTestsCount=2
52+
finalString[]mvnArgs =newString[] {"verify","-Dsurefire.rerunFailingTestsCount=3" };
53+
finalMavenProcessInvocationResultresult =running.execute(Arrays.asList(mvnArgs),Collections.emptyMap());
54+
await().atMost(5,TimeUnit.MINUTES)
55+
.until(() ->result.getProcess() !=null && !result.getProcess()
56+
.isAlive());
57+
finalStringprocessLog =running.log();
58+
assertEquals(running.getResult()
59+
.getExitCode(),0);
60+
assertThat(processLog).containsIgnoringCase("BUILD SUCCESS");
61+
// Also do a sense check that the test is functioning correctly and did have a failed execution first
62+
assertThat(processLog).containsIgnoringCase("deliberate failure run 1");
63+
assertThat(processLog).containsIgnoringCase("Run 2: PASS");
64+
}
65+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?xml version="1.0"?>
2+
<projectxsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.acme</groupId>
6+
<artifactId>acme</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<properties>
9+
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
10+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
11+
<quarkus.platform.version>@project.version@</quarkus.platform.version>
12+
<quarkus-plugin.version>@project.version@</quarkus-plugin.version>
13+
<compiler-plugin.version>${compiler-plugin.version}</compiler-plugin.version>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
16+
<maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
17+
18+
<!-- do not update this dependency, it needs to be stable for testing-->
19+
<webjar.jquery-ui.version>1.13.0</webjar.jquery-ui.version>
20+
</properties>
21+
<dependencyManagement>
22+
<dependencies>
23+
<!-- insert managed dependencies here-->
24+
<dependency>
25+
<groupId>\${quarkus.platform.group-id}</groupId>
26+
<artifactId>\${quarkus.platform.artifact-id}</artifactId>
27+
<version>\${quarkus.platform.version}</version>
28+
<type>pom</type>
29+
<scope>import</scope>
30+
</dependency>
31+
</dependencies>
32+
</dependencyManagement>
33+
<dependencies>
34+
<!-- insert test dependencies here-->
35+
<dependency>
36+
<groupId>io.quarkus</groupId>
37+
<artifactId>quarkus-resteasy</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>io.quarkus</groupId>
41+
<artifactId>quarkus-smallrye-context-propagation</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>io.quarkus</groupId>
45+
<artifactId>quarkus-websockets</artifactId>
46+
</dependency>
47+
<dependency>
48+
<groupId>io.smallrye.common</groupId>
49+
<artifactId>smallrye-common-vertx-context</artifactId>
50+
<version>1.13.2</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.webjars</groupId>
54+
<artifactId>jquery-ui</artifactId>
55+
<version>\${webjar.jquery-ui.version}</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>commons-io</groupId>
59+
<artifactId>commons-io</artifactId>
60+
</dependency>
61+
<dependency>
62+
<groupId>io.quarkus</groupId>
63+
<artifactId>quarkus-junit5</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>io.rest-assured</groupId>
68+
<artifactId>rest-assured</artifactId>
69+
<scope>test</scope>
70+
</dependency>
71+
</dependencies>
72+
<build>
73+
<plugins>
74+
<plugin>
75+
<artifactId>maven-compiler-plugin</artifactId>
76+
<version>\${compiler-plugin.version}</version>
77+
</plugin>
78+
<plugin>
79+
<groupId>io.quarkus</groupId>
80+
<artifactId>quarkus-maven-plugin</artifactId>
81+
<version>\${quarkus-plugin.version}</version>
82+
<executions>
83+
<execution>
84+
<goals>
85+
<goal>generate-code</goal>
86+
<goal>generate-code-tests</goal>
87+
<goal>build</goal>
88+
</goals>
89+
</execution>
90+
</executions>
91+
</plugin>
92+
</plugins>
93+
</build>
94+
<profiles>
95+
<profile>
96+
<id>native</id>
97+
<properties>
98+
<quarkus.native.enabled>true</quarkus.native.enabled>
99+
</properties>
100+
</profile>
101+
<profile>
102+
<id>customOutputDir</id>
103+
<build>
104+
<directory>target-other</directory>
105+
</build>
106+
</profile>
107+
</profiles>
108+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
packageorg.acme;
2+
3+
importjakarta.ws.rs.GET;
4+
importjakarta.ws.rs.Path;
5+
importjakarta.ws.rs.Produces;
6+
importjakarta.ws.rs.core.MediaType;
7+
8+
@Path("/hello")
9+
publicclassHelloResource {
10+
11+
@GET
12+
@Produces(MediaType.TEXT_PLAIN)
13+
publicStringhello() {
14+
return"hello";
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
packageorg.acme;
2+
3+
publicclassFlaker {
4+
privatestaticintcount =0;
5+
6+
publicstaticvoidflake()throwsFlakingException {
7+
count++;
8+
9+
if (count ==1) {
10+
thrownewFlakingException("deliberate failure run " +count);
11+
}
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
packageorg.acme;
2+
3+
publicclassFlakingExceptionextendsException {
4+
publicFlakingException(Stringmessage) {
5+
super(message);
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
packageorg.acme;
2+
3+
importstaticio.restassured.RestAssured.given;
4+
importstaticorg.hamcrest.CoreMatchers.is;
5+
6+
importjava.lang.reflect.InvocationTargetException;
7+
importjava.lang.reflect.Method;
8+
9+
importorg.junit.jupiter.api.Test;
10+
11+
importio.quarkus.test.junit.QuarkusTest;
12+
importio.quarkus.test.junit.QuarkusTestProfile;
13+
importio.quarkus.test.junit.TestProfile;
14+
15+
@TestProfile(FlakyHelloResourceWithAnotherProfileTest.AnotherProfile.class)
16+
@QuarkusTest
17+
publicclassFlakyHelloResourceWithAnotherProfileTest {
18+
19+
@Test
20+
publicvoidtestHelloEndpoint()throwsException {
21+
given()
22+
.when().get("/hello")
23+
.then()
24+
.statusCode(200)
25+
.body(is("hello"));
26+
27+
// Should fail the first invocation and pass subsequent ones
28+
// Use the system classloader to give a consistent view of static variables
29+
ClassflakerClass =ClassLoader.getSystemClassLoader().loadClass(Flaker.class.getName());
30+
MethodflakeMethod =flakerClass.getMethod("flake");
31+
32+
try {
33+
flakeMethod.invoke(null);
34+
}catch (InvocationTargetExceptione) {
35+
thrownewFlakingException(e.getCause().getMessage());
36+
}
37+
}
38+
39+
publicstaticclassAnotherProfileimplementsQuarkusTestProfile {
40+
41+
publicAnotherProfile() {
42+
}
43+
}
44+
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
packageorg.acme;
2+
3+
importstaticio.restassured.RestAssured.given;
4+
importstaticorg.hamcrest.CoreMatchers.is;
5+
6+
importjava.lang.reflect.InvocationTargetException;
7+
importjava.lang.reflect.Method;
8+
9+
importorg.junit.jupiter.api.Test;
10+
11+
importio.quarkus.test.junit.QuarkusTest;
12+
importio.quarkus.test.junit.QuarkusTestProfile;
13+
importio.quarkus.test.junit.TestProfile;
14+
15+
@TestProfile(FlakyHelloResourceWithSomeProfileTest.SomeProfile.class)
16+
@QuarkusTest
17+
publicclassFlakyHelloResourceWithSomeProfileTest {
18+
19+
@Test
20+
publicvoidtestHelloEndpoint()throwsException {
21+
given()
22+
.when().get("/hello")
23+
.then()
24+
.statusCode(200)
25+
.body(is("hello"));
26+
27+
// Should fail the first invocation and pass subsequent ones
28+
// Use the system classloader to give a consistent view of static variables
29+
ClassflakerClass =ClassLoader.getSystemClassLoader().loadClass(Flaker.class.getName());
30+
MethodflakeMethod =flakerClass.getMethod("flake");
31+
try {
32+
flakeMethod.invoke(null);
33+
}catch (InvocationTargetExceptione) {
34+
thrownewFlakingException(e.getCause().getMessage());
35+
}
36+
}
37+
38+
publicstaticclassSomeProfileimplementsQuarkusTestProfile {
39+
40+
publicSomeProfile() {
41+
}
42+
}
43+
44+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp