Skip to content

Commit 21bcb4a

Browse files
authored
Merge pull request #4075 from graphql-java/ban-fork-2
Prohibit JMH tests from having more than 2 forks
2 parents 7a5f9ac + 697b463 commit 21bcb4a

20 files changed

Lines changed: 74 additions & 42 deletions

build.gradle

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ dependencies {
144144

145145
testImplementation 'org.testng:testng:7.11.0' // use for reactive streams test inheritance
146146
testImplementation "com.tngtech.archunit:archunit-junit5:1.4.1"
147+
testImplementation 'org.openjdk.jmh:jmh-core:1.37' // required for ArchUnit to check JMH tests
147148

148149
antlr 'org.antlr:antlr4:' + antlrVersion
149150

@@ -309,13 +310,17 @@ artifacts {
309310

310311
List<TestDescriptor> failedTests = []
311312

312-
test {
313+
tasks.withType(Test) {
313314
useJUnitPlatform()
314315
testLogging {
315316
events "FAILED", "SKIPPED"
316317
exceptionFormat = "FULL"
317318
}
318319

320+
// Required for JMH ArchUnit tests
321+
classpath += sourceSets.jmh.output
322+
dependsOn "jmhClasses"
323+
319324
afterTest { TestDescriptor descriptor, TestResult result ->
320325
if (result.getFailedTestCount() > 0) {
321326
failedTests.add(descriptor)
@@ -327,34 +332,11 @@ tasks.register('testWithJava17', Test) {
327332
javaLauncher = javaToolchains.launcherFor {
328333
languageVersion = JavaLanguageVersion.of(17)
329334
}
330-
useJUnitPlatform()
331-
testLogging {
332-
events "FAILED", "SKIPPED"
333-
exceptionFormat = "FULL"
334-
}
335-
336-
afterTest { TestDescriptor descriptor, TestResult result ->
337-
if (result.getFailedTestCount() > 0) {
338-
failedTests.add(descriptor)
339-
}
340-
}
341-
342335
}
343336
tasks.register('testWithJava11', Test) {
344337
javaLauncher = javaToolchains.launcherFor {
345338
languageVersion = JavaLanguageVersion.of(11)
346339
}
347-
useJUnitPlatform()
348-
testLogging {
349-
events "FAILED", "SKIPPED"
350-
exceptionFormat = "FULL"
351-
}
352-
353-
afterTest { TestDescriptor descriptor, TestResult result ->
354-
if (result.getFailedTestCount() > 0) {
355-
failedTests.add(descriptor)
356-
}
357-
}
358340
}
359341
test.dependsOn testWithJava17
360342
test.dependsOn testWithJava11

src/jmh/java/benchmark/AssertBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
@Warmup(iterations = 2, time = 5, batchSize = 50)
2020
@Measurement(iterations = 3, batchSize = 50)
21-
@Fork(3)
21+
@Fork(2)
2222
public class AssertBenchmark {
2323

2424
private static final int LOOPS = 100;

src/jmh/java/benchmark/AstPrinterBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
@Warmup(iterations = 2, time = 5)
1818
@Measurement(iterations = 3, time = 10)
19-
@Fork(3)
19+
@Fork(2)
2020
public class AstPrinterBenchmark {
2121
/**
2222
* Note: this query is a redacted version of a real query

src/jmh/java/benchmark/ChainedInstrumentationBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@State(Scope.Benchmark)
3636
@Warmup(iterations = 2, time = 5)
3737
@Measurement(iterations = 3)
38-
@Fork(3)
38+
@Fork(2)
3939
public class ChainedInstrumentationBenchmark {
4040

4141
@Param({"0", "1", "10"})

src/jmh/java/benchmark/CompletableFuturesBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@State(Scope.Benchmark)
2424
@Warmup(iterations = 2, time = 1)
2525
@Measurement(iterations = 3, time = 10, batchSize = 10)
26-
@Fork(3)
26+
@Fork(2)
2727
public class CompletableFuturesBenchmark {
2828

2929

src/jmh/java/benchmark/CreateExtendedSchemaBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
@Warmup(iterations = 2, time = 5)
2929
@Measurement(iterations = 3)
30-
@Fork(3)
30+
@Fork(2)
3131
public class CreateExtendedSchemaBenchmark {
3232

3333
private static final String SDL = mkSDL();

src/jmh/java/benchmark/CreateSchemaBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
@Warmup(iterations = 2, time = 5)
2020
@Measurement(iterations = 3)
21-
@Fork(3)
21+
@Fork(2)
2222
public class CreateSchemaBenchmark {
2323

2424
static String largeSDL = BenchmarkUtils.loadResource("large-schema-3.graphqls");

src/jmh/java/benchmark/GetterAccessBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
@Warmup(iterations = 2, time = 5, batchSize = 500)
1515
@Measurement(iterations = 3, batchSize = 500)
16-
@Fork(3)
16+
@Fork(2)
1717
public class GetterAccessBenchmark {
1818

1919
public static class Pojo {

src/jmh/java/benchmark/IntMapBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@State(Scope.Benchmark)
1616
@Warmup(iterations = 2, time = 5)
1717
@Measurement(iterations = 3)
18-
@Fork(3)
18+
@Fork(2)
1919
public class IntMapBenchmark {
2020

2121
@Benchmark

src/jmh/java/benchmark/IntrospectionBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@State(Scope.Benchmark)
2222
@Warmup(iterations = 2, time = 5)
2323
@Measurement(iterations = 3)
24-
@Fork(3)
24+
@Fork(2)
2525
public class IntrospectionBenchmark {
2626

2727
@Benchmark

0 commit comments

Comments
 (0)