-
Notifications
You must be signed in to change notification settings - Fork 0
chore: integrate Testcontainers for automatic Docker Compose management in integration tests #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
csikb
wants to merge
7
commits into
main
Choose a base branch
from
integration-testcontainers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2b8241c
chore: integrate Testcontainers for automatic Docker Compose manageme…
csikb 57d6349
chore: refactor DefaultFeignConfig and IntegrationTest for improved r…
csikb 547b803
chore: enhance integration test command with verbose output
csikb 62d73f9
chore: update .gitignore to include Visual Studio Code settings and l…
csikb c5ba578
chore: add settings.json for automatic Java build configuration updates
csikb 37db849
chore: refactor integration tests to use Spring-managed Docker Compos…
csikb 7bce671
chore: clean up comments in TestContainerConfiguration for clarity
csikb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| services: | ||
| app: | ||
| ports: !override | ||
| ports: | ||
| - "8080" | ||
| postgres: | ||
| ports: !override | ||
| ports: | ||
| - "5432" | ||
| mock-file-api: | ||
| ports: !override | ||
| ports: | ||
| - "8080" | ||
| volumes: [] | ||
| mock-oidc: | ||
| ports: !override | ||
| ports: | ||
| - "5556" |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,22 +9,45 @@ import hu.bsstudio.bssweb.video.repository.DetailedVideoRepository | |
| import hu.bsstudio.bssweb.videocrew.repository.VideoCrewRepository | ||
| import org.junit.jupiter.api.BeforeEach | ||
| import org.springframework.beans.factory.annotation.Autowired | ||
| import org.springframework.test.context.TestPropertySource | ||
| import org.springframework.test.context.DynamicPropertyRegistry | ||
| import org.springframework.test.context.DynamicPropertySource | ||
| import org.springframework.test.context.junit.jupiter.SpringJUnitConfig | ||
| import org.testcontainers.containers.DockerComposeContainer | ||
| import org.testcontainers.junit.jupiter.Container | ||
| import org.testcontainers.junit.jupiter.Testcontainers | ||
| import java.io.File | ||
|
|
||
| @Testcontainers | ||
| @SpringJUnitConfig(classes = [BssFeignConfig::class, DataConfig::class]) | ||
| @TestPropertySource( | ||
| properties = [ | ||
| "bss.client.url=http://localhost:8080", | ||
| "bss.client.username=user", | ||
| "bss.client.password=password", | ||
| "spring.flyway.enabled=false", | ||
| "spring.datasource.url=jdbc:postgresql://localhost:5432/bss?currentSchema=private", | ||
| "spring.datasource.username=user", | ||
| "spring.datasource.password=password", | ||
| ], | ||
| ) | ||
| open class IntegrationTest { | ||
| companion object { | ||
| @Container | ||
| @JvmStatic | ||
| val compose: DockerComposeContainer<*> = | ||
| DockerComposeContainer(File("../docker-compose.yml"), File("../docker-compose.ci.yml")) | ||
| .withExposedService("postgres", 5432) | ||
| .withExposedService("app", 8080) | ||
| .withOptions("--profile app") | ||
| .withBuild(true) | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @DynamicPropertySource | ||
| @JvmStatic | ||
| fun configureProperties(registry: DynamicPropertyRegistry) { | ||
| val postgresHost = compose.getServiceHost("postgres", 5432) | ||
| val postgresPort = compose.getServicePort("postgres", 5432) | ||
| val appHost = compose.getServiceHost("app", 8080) | ||
| val appPort = compose.getServicePort("app", 8080) | ||
|
|
||
| registry.add("spring.datasource.url") { | ||
| "jdbc:postgresql://$postgresHost:$postgresPort/bss?currentSchema=private" | ||
| } | ||
| registry.add("spring.datasource.username") { "user" } | ||
| registry.add("spring.datasource.password") { "password" } | ||
| registry.add("spring.flyway.enabled") { "false" } | ||
| registry.add("bss.client.url") { "http://$appHost:$appPort" } | ||
| } | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove extraneous blank line to fix spotlessKotlinCheck failure. The pipeline failure indicates formatting violations including an extraneous blank line near the class declaration. @SpringJUnitConfig(classes = [TestContainerConfiguration::class, BssFeignConfig::class, DataConfig::class])
-
open class IntegrationTest {🤖 Prompt for AI Agents |
||
| @Autowired protected lateinit var eventRepository: DetailedEventRepository | ||
|
|
||
| @Autowired protected lateinit var videoRepository: DetailedVideoRepository | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify service names and configuration match docker-compose.yml.
The DockerComposeContainer configuration references service names "postgres" and "app", uses profile "app", and enables image building. Ensure these match your docker-compose.yml configuration to avoid runtime failures.
Run the following script to verify the Docker Compose configuration:
🏁 Script executed:
Length of output: 492
🏁 Script executed:
Length of output: 81
🏁 Script executed:
Length of output: 1436
🏁 Script executed:
Length of output: 854
Adjust DockerComposeContainer profile and test schema setup
withOptions("--profile app")—noprofiles: [app]defined in your compose files.currentSchemato an existing schema.user/password) and ports match your compose configuration.🤖 Prompt for AI Agents