chore(ci): Skip all generated gapic unit tests#13683
Draft
lqiu96 wants to merge 21 commits into
Draft
Conversation
Skip unit tests for all pure GAPIC generated modules to speed up CI. Handwritten libraries, including combo and manual libraries, are configured to override this behavior so that their handwritten unit tests still run. Pure GAPIC submodules of combo libraries are configured to still skip unit tests. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Contributor
|
Warning Gemini is experiencing higher than usual traffic and was unable to create the review. Please try again in a few hours by commenting |
Instead of using mvn install to execute unit tests, use mvn test to avoid the packaging phase and skip building JAR files, speeding up the test lifecycle. Handwritten libraries share the same execution path under JOB_TYPE=test, and since install_modules compiles and installs their external dependencies to .m2 beforehand, running mvn test is sufficient and correct for both handwritten and generated libraries. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
…testing Upgraded the flatten-maven-plugin to 1.6.0. This allows the skip feature (via flatten.skip property) to work during quick-build executions, providing a compile speedup. Restored the test execution command in build.sh to use mvn package instead of mvn test. This is necessary because some downstream modules (such as java-accessapproval) have dependencies on test-jar artifacts (specifically gax-grpc testlib) from other modules in the same reactor. If we only run up to the 'test' phase, these test-jars are never packaged, causing downstream test compilation to fail with "cannot find symbol" errors for test utility classes (e.g. MockServiceHelper, MockGrpcService). Using mvn package ensures the test-jars are packaged during the build while still skipping integration tests (via skipITs). TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Optimized the unit test target in build.sh when running on the entire repository (global run): 1. Dynamically resolve all Maven modules that should run unit tests (modules under java-* that have skipUnitTests=false in their parents, excluding any submodules that explicitly override it to true). 2. Changed the test command from 'mvn package' back to 'mvn test' and targeted only the resolved modules using the '-pl' flag. 3. Removed the '--also-make' flag from the global run to prevent Maven from pulling sdk-platform-java back into the reactor. This ensures that: - We do not build JAR files for any of the client library modules, saving I/O and time. - We do not compile or build the 250+ skipped pure GAPIC modules during the test run. - Core dependencies from sdk-platform-java (which are pre-installed in .m2) are resolved from the local repository cache, bypassing the reactor test-jar dependency issues. For subdirectory runs (where BUILD_SUBDIR is set), we continue using --also-make and mvn test, as the reactor is already restricted to that subdirectory and dependencies are pre-populated in .m2. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Replaced the dynamic python-based module resolution with a static list of exclusions in build.sh for the global unit test run. We run 'mvn test' (which compiles classes but skips JAR packaging) and exclude the core modules that generate test-jars (gax, gax-grpc, gax-httpjson, google-cloud-core) from the reactor. This forces Maven to resolve these test-jar dependencies from the pre-installed local .m2 cache instead of the reactor, avoiding compilation failures. This satisfies the requirement to avoid building JARs during the unit test run without introducing dynamic scripts in build.sh. Note that this will compile all remaining modules in the repository, which will increase the build time compared to targeting only test-enabled modules. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Map the standard Maven property `maven.test.skip` to our custom `skipUnitTests` property in `google-cloud-jar-parent/pom.xml`. This skips compiling test sources and copying test resources for all modules that have `skipUnitTests=true` (which is the default for GAPIC generated libraries). This will significantly speed up compilation during global `mvn test` runs by avoiding compilation of tests that are not going to be executed anyway. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Add comments in `google-cloud-jar-parent/pom.xml` explaining the relationship between `skipUnitTests` and `maven.test.skip`, and how they are used to skip both compilation and execution of tests by default, while still allowing integration tests to compile and run when needed. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Add `-DskipUnitTests=true` to `SUREFIRE_JVM_OPT` in `.kokoro/build.sh` for global runs (where `BUILD_SUBDIR` is empty). Since `skipUnitTests` is mapped to `maven.test.skip` in `google-cloud-jar-parent`, this will skip both compilation and execution of tests for all client libraries (both GAPIC and veneers) in the global unit test job. This is safe because veneers have their own individual `split-units` jobs that run their tests, so we don't need to build or run them in the global job. This should yield another significant speedup by avoiding compiling/running tests for the handwritten libraries in the global run. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Update `java-spanner-jdbc/pom.xml` to set `<skip>${maven.test.skip}</skip>`
for the `generate_connection_properties_documentation` execution of
`exec-maven-plugin`.
This avoids `ClassNotFoundException` during builds where test
compilation is skipped (like the global unit test run with
`skipUnitTests=true` -> `maven.test.skip=true`), because the class it
attempts to run (`ConnectionPropertiesFileGenerator`) is in
`src/test/java` and will not be compiled.
TAG=agy
CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Add `-Dmaven.test.skip=true` to `SUREFIRE_JVM_OPT` in `.kokoro/build.sh` for global runs. While we previously mapped `skipUnitTests` to `maven.test.skip` in `google-cloud-jar-parent` for client libraries, core modules (like `gapic-generator-java`) and `google-auth-library-java` do not inherit from it and thus were still compiling their tests during the global compilation check. In particular, `gapic-generator-java` was recompiling its 750+ tests due to dependency changes (caused by reactor exclusions), taking ~8 seconds. By passing `-Dmaven.test.skip=true` globally on the command line, we ensure all modules in the reactor skip test compilation during this job, as we only want to verify that the main classes compile successfully. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
…tall Remove the pre-installation step for `sdk-platform-java` and the static reactor exclusions (`MVN_ARGS`) in `.kokoro/build.sh` for the global `test` job. Now that we pass `-Dmaven.test.skip=true` globally on the command line, Maven completely skips test compilation for all modules. As a result, it no longer attempts to resolve test-scoped dependencies (including `test-jar`s like `gax-grpc:testlib`). This allows us to: 1. Run `mvn test` on the full reactor without getting reactor resolution errors for `test-jar`s of unpackaged modules. 2. Remove the `install_modules "sdk-platform-java"` step that was previously required to pre-populate `.m2` with core jars, saving ~1 minute of build time. The entire monorepo compilation is now verified in a single maven invocation. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Remove `MVN_ARGS=("--also-make")` in `.kokoro/build.sh` for targeted runs
(`BUILD_SUBDIR` case).
Since the script performs a `pushd "${BUILD_SUBDIR}"` and runs `mvn test`
from within that directory without specifying a project list (`-pl`),
the `--also-make` (`-am`) flag has no effect and is redundant.
Also document this in the plan.
TAG=agy
CONV=2e2339aa-553a-429d-a821-1c9ae142d816
- Remove the `MVN_ARGS` variable entirely from the `test` job in `.kokoro/build.sh`, as it is now empty for both global and targeted runs. - Add a detailed comment in `.kokoro/build.sh` explaining why both `-DskipUnitTests=true` and `-Dmaven.test.skip=true` are required to correctly skip test compilation and execution across different module types (core vs client libraries). - Update the plan artifact to reflect these changes. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
- Remove the activation of the `bulkTests` profile (`-PbulkTests`) in `.kokoro/build.sh` for global runs. Since we skip all tests globally using properties, we no longer need the profile to selectively skip handwritten/core tests. - Remove the unused `EXTRA_PROFILE_OPTS` variable entirely from the `test` and `clirr` jobs in `.kokoro/build.sh`. - Update the plan to document these changes. Note: The `bulkTests` profile definitions are kept in POMs for now as they are still needed by the integration test runner (`run_integration_tests` in `common.sh`) to skip transitively included modules' unit tests. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
Using maven.test.skip=true globally on the CLI overrides all module configurations and skips all test compilation. This breaks compilation of gapic-generator-java because it depends on gax-grpc testlib, which is not compiled and cannot be resolved in the reactor. Switch to using -DskipTests=true globally to skip execution for all modules, and -DskipUnitTests=true to skip test compilation for client libraries (via google-cloud-jar-parent mapping). Core modules (gax, etc.) do not inherit this mapping, so their tests are compiled, resolving the reactor dependency issues. TAG=agy CONV=2e2339aa-553a-429d-a821-1c9ae142d816
…kip-gapic-unit-tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In an attempt to speed up the CIs in the google-cloud-java, opt to skip all the generated unit tests and simply rely on showcase tests.
Essentially, the units CI for GAPICs because a compilation step.
Run from the code changes: https://github.com/googleapis/google-cloud-java/actions/runs/28965549148/job/85947902511?pr=13683