testcontainers / testcontainers/testcontainers-java

[Feature]: Allow testcontainers.properties filename/pathname to be injected by property or env variable

Offen
#7,046 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

type/feature
Vorherrschende Sprache
Java
Sterne
8.7k
Forks
1.9k
Ø Merge
2 T. 17 Std.
Gemergte PRs (30 T.)
9

Beschreibung

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.properties can 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit nachzuverfolgen, wie testcontainers.properties entdeckt wird und wie TESTCONTAINERS_IMAGE_SUBSTITUTOR konfiguriert wird. Vergleiche die vorgeschlagenen Namen testcontainers-ci.properties, testcontainers-ci-legacy.properties, testcontainers-ci-next.properties und testcontainers-ci-snapshot.properties mit dem bestehenden Standardverhalten. Die Aufgabe ist abgeschlossen, wenn eine Property oder Umgebungsvariable eine alternative Datei auswählen kann, während die Standardkonfiguration unverändert bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
testing
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.