testcontainers / testcontainers-go

Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.
https://golang.testcontainers.org
MIT License
3.57k stars 492 forks source link

[Enhancement]: dependsOn() implementation #1791

Open oleg-nenashev opened 12 months ago

oleg-nenashev commented 12 months ago

Proposal

As a test developer, I would be interested to provision a cluster of services depending on each other. For that the Java implementation offers the dependsOn() implementation: https://java.testcontainers.org/features/startup_and_waits/#depending-on-another-container . It would be nice to have a similar feature in Testcontainers for Go.

Why not Docker Compose?. As discussed on Slack, at the moment Docker Compose in Testcontainers for Go is considered rather temporary and not stable. So it is better. My experiments in Testcontainers for C/C++ show that it rather does not work at all with recent API versions. So it is preferred to have a native implementation instead.

References

hughesjj commented 10 months ago

Has anyone taken this yet? We have a need for such in the opentelemetry collector and was wondering if it would be better for me to work around on my end or to contribute upstream.

If the latter, I'm a bit confused that ContainerRequest doesn't seem to exist for java, and dependsOn only exists for java and C#

Mathew-Estafanous commented 10 months ago

I've opened a draft PR (https://github.com/testcontainers/testcontainers-go/pull/2035). I'd appreciate any set of eyes on the PR and/or feedback on the implementation.