testcontainers / testcontainers/testcontainers-java
[Feature]: Allow testcontainers.properties filename/pathname to be injected by property or env variable
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 8.7k
- Fork
- 1.9k
- Merge medio
- 2g 17h
- PR unite (30g)
- 9
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando come viene individuato testcontainers.properties e come viene configurato TESTCONTAINERS_IMAGE_SUBSTITUTOR. Confronta i nomi proposti testcontainers-ci.properties, testcontainers-ci-legacy.properties, testcontainers-ci-next.properties e testcontainers-ci-snapshot.properties con il comportamento predefinito esistente. Il lavoro è completato quando una proprietà o una variabile d’ambiente può selezionare un file alternativo, mentre la configurazione predefinita rimane invariata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- testing
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100