Prohibit JMH tests from having more than 2 forks by dondonz · Pull Request #4075 · graphql-java/graphql-java

Fixes #4010. Adds an ArchUnit test to prohibit JMH tests that use more than 2 forks. This is to save time in our automated testing pipeline, because extra forks don't add much value.

I had to update our test config because our JMH benchmarks are not in the usual package as everything else. ArchUnit reads .class files. Without this configuration change, ArchUnit can't read any JMH tests.

While I'm here I also:

  • Tidied up the test config, to reduce repetition
  • Changed all offending JMH tests to 2 forks, even if they don't run in the automated pipeline (in performance), because I'd rather we apply this rule equally to all benchmarks
  • Created a new home for ArchUnit tests, make it easier to find

Sample error output

Architecture Violation [Priority: MEDIUM] - Rule 'classes that are annotated with @Fork and are top level classes should have a @Fork value of at most 2' was violated (17 times):
Class benchmark.AssertBenchmark has a @Fork value of 3 which is > 2
Class benchmark.AstPrinterBenchmark has a @Fork value of 3 which is > 2
Class benchmark.ChainedInstrumentationBenchmark has a @Fork value of 3 which is > 2
Class benchmark.CompletableFuturesBenchmark has a @Fork value of 3 which is > 2
Class benchmark.CreateExtendedSchemaBenchmark has a @Fork value of 3 which is > 2
Class benchmark.CreateSchemaBenchmark has a @Fork value of 3 which is > 2
Class benchmark.GetterAccessBenchmark has a @Fork value of 3 which is > 2
Class benchmark.IntMapBenchmark has a @Fork value of 3 which is > 2
Class benchmark.IntrospectionBenchmark has a @Fork value of 3 which is > 2
Class benchmark.MapBenchmark has a @Fork value of 3 which is > 2
Class benchmark.OverlappingFieldValidationBenchmark has a @Fork value of 3 which is > 2
Class benchmark.PropertyFetcherBenchMark has a @Fork value of 3 which is > 2
Class benchmark.SchemaTransformerBenchmark has a @Fork value of 3 which is > 2
Class benchmark.SimpleQueryBenchmark has a @Fork value of 3 which is > 2
Class benchmark.TwitterBenchmark has a @Fork value of 3 which is > 2
Class benchmark.TypeDefinitionParserVersusSerializeBenchmark has a @Fork value of 3 which is > 2
Class benchmark.ValidatorBenchmark has a @Fork value of 3 which is > 2