testcontainers / testcontainers/testcontainers-java
[Feature]: Allow testcontainers.properties filename/pathname to be injected by property or env variable
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
Module
Core
Problem
For Spring Data Relational, we have two submodules, Spring Data JDBC and Spring Data R2DBC. For each of these to test properly, we need to apply a custom ImageNameSubstitutor that rewrites the canonical name of each container we use for testing.
However, these submodules each must have their own version of this image name substitutor since there is no common test-based artifact to draw upon. This drives us to create org.springframework.data.jdbc.support.ProxyImageNameSubstitutor as well as org.springframework.data.r2dbc.support.ProxyImageNameSubstitutor. However, there is only one TESTCONTAINERS_IMAGE_SUBSTITUTOR we can apply.
An alternative idea would be to have a testcontainers.properties in each submodule, each pointing to its respective image name substitutor, but the way things are now, this file would get applied unconditionally whether or not we are building on CI. Building locally, we'd rather NOT do a substutition.
Solution
If it were possible to have a different name, like testcontainers-ci.properties that is then injected by setting some env variable on CI, this configuration would ONLY kick in on CI.
This also opens the door to different CI stages able to run alternative flavors, like testcontainers-ci-legacy.properties, testcontainers-ci-next.properties, testcontainers-ci-snapshot.properties, whatever. Each being applied in a different CI stage.
Benefit
- This makes it so that multiple versions of
testcontainers.propertiescan be crafted and maintained within the same project - It also makes it possible to split up image name substitutors and make each of them simpler instead of injecting one mega-name substitutor with uber smarts.
Alternatives
I can write a script whereby the testcontainers.properties file is stash elsewhere or with a different name and have the CI server copy it into the "right" name so that it only kicks in during a CI run, but that seems like a bit of a hack.
Would you like to help contributing this feature?
Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how testcontainers.properties is discovered and how TESTCONTAINERS_IMAGE_SUBSTITUTOR is configured. Compare the proposed testcontainers-ci.properties, testcontainers-ci-legacy.properties, testcontainers-ci-next.properties, and testcontainers-ci-snapshot.properties names with the existing default behavior. Done means a property or environment variable can select an alternate file while the default configuration remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100