Skip to content

Commit

Permalink
Allow sharding for Dagger compiler tests.
Browse files Browse the repository at this point in the history
Recently, some of our tests have started timing out on GitHub Actions (https://github.com/google/dagger/actions/runs/6355090490/job/17262572158?pr=4082):

```
//javatests/dagger/internal/codegen:ComponentProcessorTest              TIMEOUT in 315.2s
```

This CL adds the ability to shard some of our large and medium sized tests.

RELNOTES=N/A
PiperOrigin-RevId: 569583640
  • Loading branch information
bcorso authored and Dagger Team committed Sep 29, 2023
1 parent 5cc209c commit bca691a
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 42 deletions.
142 changes: 100 additions & 42 deletions javatests/dagger/internal/codegen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,118 @@ java_library(
srcs = [
"CompilerMode.java",
"Compilers.java",
"ComponentCreatorTestHelper.java",
"DaggerModuleMethodSubject.java",
"GeneratingProcessingStep.java",
"JavaFileBuilder.java",
"TestUtils.java",
],
deps = [
"//java/dagger:core",
"//java/dagger/internal/codegen:package_info",
"//java/dagger/internal/codegen:processor",
"//java/dagger/internal/codegen/base",
"//java/dagger/internal/codegen/binding",
"//java/dagger/internal/codegen/xprocessing:xprocessing-testing",
"//java/dagger/producers",
"//java/dagger/testing/compile",
"//third_party/java/compile_testing",
"//third_party/java/guava/base",
"//third_party/java/guava/collect",
"//third_party/java/javapoet",
"//third_party/java/truth",
"@com_google_auto_value_auto_value//jar",
],
)

# These are tests with over 25 test cases.
LARGE_TESTS = [
"ComponentCreatorTest.java",
"ComponentProcessorTest.java",
"InjectConstructorFactoryGeneratorTest.java",
"MembersInjectionTest.java",
"MissingBindingValidationTest.java",
"ModuleFactoryGeneratorTest.java",
"ProducerModuleFactoryGeneratorTest.java",
"SubcomponentCreatorValidationTest.java",
]

# These are tests with over 10 test cases
MEDIUM_TESTS = [
"BindsMethodValidationTest.java",
"DaggerSuperficialValidationTest.java",
"DelegateRequestRepresentationTest.java",
"DuplicateBindingsValidationTest.java",
"IgnoreProvisionKeyWildcardsTest.java",
"MapMultibindingValidationTest.java",
"MultibindsValidationTest.java",
"ProductionComponentProcessorTest.java",
"ProductionGraphValidationTest.java",
"SubcomponentValidationTest.java",
]

DEPS = [
":compilers",
":java_lib_no_dagger_compiler",
":kt_lib_no_dagger_compiler",
"//third_party/java/guava/base",
"//third_party/java/guava/collect",
"//third_party/java/guava/util/concurrent",
"//third_party/java/auto:value",
"@com_google_auto_value_auto_value//jar",
"//third_party/java/auto:common",
"//third_party/java/compile_testing",
"//third_party/java/javapoet",
"//third_party/java/jsr250_annotations", # Include @Generated in generated files.
"//third_party/java/jsr330_inject",
"//third_party/java/junit",
"//third_party/java/mockito",
"//third_party/java/truth",
"//java/dagger:core",
"//java/dagger/internal/codegen:package_info",
"//java/dagger/internal/codegen:processor",
"//java/dagger/internal/codegen/base",
"//java/dagger/internal/codegen/binding",
"//java/dagger/internal/codegen/bindinggraphvalidation",
"//java/dagger/internal/codegen/compileroption",
"//java/dagger/internal/codegen/extension",
"//java/dagger/internal/codegen/javac",
"//java/dagger/internal/codegen/javapoet",
"//java/dagger/internal/codegen/kotlin",
"//java/dagger/internal/codegen/langmodel",
"//java/dagger/internal/codegen/model",
"//java/dagger/internal/codegen/validation",
"//java/dagger/internal/codegen/writing",
"//java/dagger/internal/codegen/xprocessing",
"//java/dagger/internal/codegen/xprocessing:xprocessing-testing",
"//java/dagger/model/testing",
"//java/dagger/producers",
"//java/dagger/spi",
"//java/dagger/spi/model/testing",
"//java/dagger/testing/compile",
"//java/dagger/testing/golden",
]

GenJavaTests(
name = "large_compiler_tests",
srcs = LARGE_TESTS,
functional = False,
javacopts = DOCLINT_HTML_AND_SYNTAX,
plugins = ["//java/dagger/internal/codegen/bootstrap"],
shard_count = 7,
deps = DEPS,
)

GenJavaTests(
name = "medium_compiler_tests",
srcs = MEDIUM_TESTS,
functional = False,
javacopts = DOCLINT_HTML_AND_SYNTAX,
plugins = ["//java/dagger/internal/codegen/bootstrap"],
shard_count = 3,
deps = DEPS,
)

GenJavaTests(
name = "compiler_tests",
srcs = glob(
Expand All @@ -75,50 +173,10 @@ GenJavaTests(
"Compilers.java",
"InvalidInjectConstructor.java",
"JavaFileBuilder.java",
],
] + LARGE_TESTS + MEDIUM_TESTS,
),
functional = False,
javacopts = DOCLINT_HTML_AND_SYNTAX,
plugins = ["//java/dagger/internal/codegen/bootstrap"],
deps = [
":compilers",
":java_lib_no_dagger_compiler",
":kt_lib_no_dagger_compiler",
"//java/dagger:core",
"//java/dagger/internal/codegen:package_info",
"//java/dagger/internal/codegen:processor",
"//java/dagger/internal/codegen/base",
"//java/dagger/internal/codegen/binding",
"//java/dagger/internal/codegen/bindinggraphvalidation",
"//java/dagger/internal/codegen/compileroption",
"//java/dagger/internal/codegen/extension",
"//java/dagger/internal/codegen/javac",
"//java/dagger/internal/codegen/javapoet",
"//java/dagger/internal/codegen/kotlin",
"//java/dagger/internal/codegen/langmodel",
"//java/dagger/internal/codegen/model",
"//java/dagger/internal/codegen/validation",
"//java/dagger/internal/codegen/writing",
"//java/dagger/internal/codegen/xprocessing",
"//java/dagger/internal/codegen/xprocessing:xprocessing-testing",
"//java/dagger/model/testing",
"//java/dagger/producers",
"//java/dagger/spi",
"//java/dagger/spi/model/testing",
"//java/dagger/testing/compile",
"//java/dagger/testing/golden",
"//third_party/java/auto:common",
"//third_party/java/auto:value",
"//third_party/java/compile_testing",
"//third_party/java/guava/base",
"//third_party/java/guava/collect",
"//third_party/java/guava/util/concurrent",
"//third_party/java/javapoet",
"//third_party/java/jsr250_annotations", # Include @Generated in generated files.
"//third_party/java/jsr330_inject",
"//third_party/java/junit",
"//third_party/java/mockito",
"//third_party/java/truth",
"@com_google_auto_value_auto_value//jar",
],
deps = DEPS,
)
12 changes: 12 additions & 0 deletions test_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def GenKtLibrary(
deps = deps,
gen_library_deps = gen_library_deps,
test_only_deps = None,
shard_count = None,
plugins = plugins,
javacopts = javacopts,
functional = functional,
Expand All @@ -64,6 +65,7 @@ def GenKtTests(
test_only_deps = None,
plugins = None,
javacopts = None,
shard_count = None,
functional = True,
require_jdk7_syntax = True):
_GenTestsWithVariants(
Expand All @@ -76,6 +78,7 @@ def GenKtTests(
test_only_deps = test_only_deps,
plugins = plugins,
javacopts = javacopts,
shard_count = shard_count,
functional = functional,
require_jdk7_syntax = require_jdk7_syntax,
)
Expand All @@ -101,6 +104,7 @@ def GenJavaLibrary(
test_only_deps = None,
plugins = plugins,
javacopts = javacopts,
shard_count = None,
functional = functional,
require_jdk7_syntax = require_jdk7_syntax,
)
Expand All @@ -113,6 +117,7 @@ def GenJavaTests(
test_only_deps = None,
plugins = None,
javacopts = None,
shard_count = None,
functional = True,
require_jdk7_syntax = True):
if any([src for src in srcs if src.endswith(".kt")]):
Expand All @@ -127,6 +132,7 @@ def GenJavaTests(
test_only_deps = test_only_deps,
plugins = plugins,
javacopts = javacopts,
shard_count = shard_count,
functional = functional,
require_jdk7_syntax = require_jdk7_syntax,
)
Expand All @@ -138,6 +144,7 @@ def GenRobolectricTests(
test_only_deps = None,
plugins = None,
javacopts = None,
shard_count = None,
functional = True,
require_jdk7_syntax = True,
manifest_values = None):
Expand All @@ -152,6 +159,7 @@ def GenRobolectricTests(
test_only_deps = test_only_deps,
plugins = plugins,
javacopts = javacopts,
shard_count = shard_count,
functional = functional,
require_jdk7_syntax = require_jdk7_syntax,
test_kwargs = {"manifest_values": manifest_values},
Expand All @@ -167,6 +175,7 @@ def _GenTestsWithVariants(
test_only_deps,
plugins,
javacopts,
shard_count,
functional,
require_jdk7_syntax,
test_kwargs = None):
Expand Down Expand Up @@ -242,6 +251,7 @@ def _GenTestsWithVariants(
deps = test_deps + variant_deps,
plugins = plugins,
javacopts = javacopts + variant_javacopts,
shard_count = shard_count,
jvm_flags = jvm_flags,
functional = functional,
test_kwargs = test_kwargs,
Expand Down Expand Up @@ -291,6 +301,7 @@ def _GenTestWithVariant(
deps,
plugins,
javacopts,
shard_count,
jvm_flags,
functional,
test_kwargs):
Expand Down Expand Up @@ -319,6 +330,7 @@ def _GenTestWithVariant(
jvm_flags = jvm_flags,
plugins = plugins,
tags = tags,
shard_count = shard_count,
test_class = test_class,
deps = deps,
**test_kwargs_with_javacopts
Expand Down

0 comments on commit bca691a

Please sign in to comment.