Repository navigation
Remove withLocalCompose(true) in the Testcontainers 2 migration - #1281
Merged
Merged
Conversation
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.
Testcontainers2MigrationchangesDockerComposeContainertoComposeContainerbut keeps.withLocalCompose(true). Testcontainers 2 removedwithLocalCompose(boolean)from both classes, so the call no longer compiles. In Testcontainers 2 aComposeContainerbuilt from compose files alone, without aDockerImageName, already uses the local Docker Compose binary, sowithLocalCompose(true)has no replacement and can go.Before:
After the migration today (does not compile):
After this change:
This surfaced while validating the Spring Boot 4.1 migration over open source Spring Boot 3.x repositories, in adorsys/open-banking-gateway (
opba-protocols/sandboxes/xs2a-sandbox/.../BasicTest.java):cannot find symbol: method withLocalCompose(boolean)onComposeContainer.This adds
RemoveLocalCompose, which removeswithLocalCompose(true)onDockerComposeContainerandComposeContainer, in a chain or as a statement, usingRemoveMethodInvocationsVisitorwithisTrueArgument(). It runs inTestcontainers2Migrationbefore the type change.withLocalCompose(false)and non-literal arguments are left alone: their Testcontainers 2 form is a constructor that takes aDockerImageName, which needs a choice of image.Is this the right change?
RemoveMethodInvocationsremoves the call whatever its argument, which would turnwithLocalCompose(false)into local compose without a word. The recipe is a thin wrapper aroundRemoveMethodInvocationsVisitorwith an argument predicate.withLocalCompose(true)is the usual way to use Docker Compose v2 from Testcontainers 1.x, and every such call breaks.true, which is the Testcontainers 2 default for these constructors.trueis removed;falseand expressions stay, for a person to decide.Tests: new
RemoveLocalComposeTest(removal in a chain and as a statement;falseand a variable unchanged) andTestcontainersBestPracticesTest#composeContainerWithLocalCompose(the full migration on the shape from open-banking-gateway; failed before).TestcontainersBestPracticesTestandTestcontainers2LocalStackTestpass.