Repository navigation
Conversation
Macbet
force-pushed
the
build/speed-up-backend-build
branch
from
November 29, 2026 12:58
1ed46ba to
864cc89
Compare
Macbet
force-pushed
the
build/speed-up-backend-build
branch
from
November 29, 2026 19:29
864cc89 to
3843e77
Compare
The API suite ran in one JVM after every other module and took 5 of the build's 6:42. Surefire now forks 3 JVMs for api and executor (terrakube.test.forkCount, default 1), and CI builds modules with -T 1C so registry and executor run beside api. Measured locally: 6:42 -> ~3:10. Parallel JVMs exposed shared state that a single JVM had hidden: - registry tests bound WireMock to fixed port 9999; it now uses a free port passed in with @DynamicPropertySource - LocalTerraformStateImplTest deleted ~/.terraform-spring-boot recursively while api and registry tests used it; it now runs with a private user.home - TerraformHttpBackendIntegrationTest shared the seeded workspace's backend state file with WorkspaceTests; it now creates its own workspace
The bound build-image goal forks the lifecycle to package, so after the tests every app module compiled, tested and repackaged a second time, even with -Dspring-boot.build-image.skip=true. build-image-no-fork is the goal Spring Boot provides for bound executions. Invoking spring-boot:build-image on the command line would now build each image twice (its own fork runs the bound no-fork execution), so the release workflows, terrakubeBuild.sh and the minikube notes run package instead.
Two tests waited for the sweep's */30 cron trigger, up to 30s each. They now call sweep.execute(null), as the third test in the class already does, and keep polling only for ScheduleJob's asynchronous pickup. The class drops from 44s to about 8s.
Each distinct set of bean overrides and test properties boots its own API context. - The three login broker test classes now take their properties and the DexExchangeClient mock from LoginBrokerEnabledTestBase. Its api-url is a loopback address that differs from the test profile's default, so the well-known test still proves the configured value is used. - JobPlanArtifactsPermissionTest mocks StorageTypeService instead of spying on it (deleteJobArtifacts is void), joining the other storage-mock tests. - WorkspaceUnlockWakesQueueTests mocks ScheduleJobService with Quartz off, the same overrides as the RemoteTfe*Tests. It only verifies calls.
setup-java's cache: maven replaces the hand-written actions/cache steps. Its key hashes every pom.xml (the release workflows hashed only the root one, so module changes restored a stale cache) and includes the runner architecture, so the arm release job no longer shares an x86 cache. It caches only ~/.m2/repository. It has no restore-keys: the first run after a pom change downloads dependencies again.
The test profile set Spring Security and the organization checks to DEBUG, and every context start printed each Liquibase changeset and Hibernate deprecation notice: most of the 15 MB CI log. No test asserts on those loggers; the tests that capture logs attach to their own classes.
On a 4-vCPU runner the tests are CPU-bound: more surefire forks only made them compete for cores (the first Spring context took 108s per fork instead of 35s). The api tests now run in three jobs, each taking a third of the classes from scripts/ci/test-shard.py, and common, registry and executor in a fourth. Each job uses 2 forks, the fastest setting measured on a 4-CPU container. build-jammy waits for them, merges their JaCoCo data and runs the Sonar analysis without running tests again. Test output goes to report files that are uploaded with the coverage, so the job logs keep only the build, the test summaries and the failures.
Local storage keys files by job id (the job context lives in ~/.terraform-spring-boot/local/output/context/<jobId>/context.json), and each fork's in-memory H2 database numbers jobs from 1. Two forks therefore wrote the same files: in CI StructuredOutputSpoolRecoveryIntegrationTest read a context that ContextPatchIntegrationTest had written in the other fork. Each fork now gets user.home under target/test-home/fork-N. This also keeps api tests out of the developer's real home directory.
It created references as TERRAKUBE_DEVELOPERS and passed only because CollectionTests had already given that team manageCollection earlier in the same JVM. In a test shard without CollectionTests every request got 403.
With three shards the slowest test job took 3:54 and bounded the run; about half of each job is setup and compilation, so a fourth shard trims the test part further.
setup-java's maven cache has one key per pom hash, and only the first job to finish can save it. After the last pom change that was the common, registry, executor job, so the cache held none of the api dependencies: each api shard downloaded about 2000 artifacts and build-jammy 576, and no later run could fix the entry. The api shards, the other-modules job and build-jammy now each cache under their own key, with restore-keys so a pom change starts from the previous cache instead of an empty one.
The agent instrumented every class the test JVMs loaded, including the thousands from Spring, Hibernate and Elide, while the coverage report only covers io.terrakube classes. Instrumenting just those cuts the first Spring context start in a test JVM from 14.1s to 10.4s locally, the same as running without the agent. Each CI shard pays that start once per fork.
Macbet
force-pushed
the
build/speed-up-backend-build
branch
from
November 29, 2026 19:34
3843e77 to
e46485f
Compare
|
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.



The backend CI build took 11:54. It now takes about 5:15 (5:07 and 5:26 in two runs of the same commit). All 4836 tests pass, and Sonar coverage is unchanged (76.9% vs 77.0% on #4058). Locally,
mvn -T 1C verifytakes 3:04 instead of 6:42.CI: tests split across parallel jobs
scripts/ci/test-shard.py, and common, registry and executor in a fifth.build-jammywaits for them, merges their JaCoCo data and runs the Sonar analysis without running the tests again. Onlybuild-jammyhas the secrets.io.terrakube.*. Instrumenting every Spring, Hibernate and Elide class added about a third to each JVM's first Spring context start (14.1s vs 10.4s locally), and every fork pays that start.test-results-*artifact. The job log keeps the build, the test summaries and the failures. The test profile no longer logs Spring Security at DEBUG or each Liquibase changeset.Build
terrakube.test.forkCount), and-T 1Cbuilds registry and executor while the api tests run.build-image-no-fork, so packaging no longer recompiles and retests every module. The release workflows andterrakubeBuild.shrunpackage, which builds each image once (spring-boot:build-imageon the command line would now build it twice).Test fixes that parallel runs exposed
user.home. Local storage keys files by job id, and every fork's H2 database numbers jobs from 1, so forks read each other's files.LocalTerraformStateImplTestdeleted~/.terraform-spring-bootwhile other modules' tests were using it.TerraformHttpBackendIntegrationTestshared the seeded workspace's state file.ReferenceScopeTestsrelied on a permission thatCollectionTestsgranted earlier in the same JVM.JobReconciliationSweepIntegrationTestcalls the sweep directly instead of waiting for its 30s cron. More test classes share a cached Spring context.Worth checking
build-jammykeeps its name, so a required check on it still works.package. I verified locally that this builds one image per module, but did not run the release workflow.ReferenceScopeTestsdid.