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.31k stars 451 forks source link

[Enhancement]: Docs/example for redis cluster #2400

Open hughesjj opened 3 months ago

hughesjj commented 3 months ago

Proposal

I'm a maintainer of opentelemetry-collector-contrib/receiver/redis, and have attempted to implement testing a redis cluster. This is important as some metrics only appear (ctrl+f If the instance is a replica) when a redis is configured as a cluster.

While we have good examples for creating a single redis container, it would be nice to do so as well for clusters. It seems like I'm not alone in this desire, as someone had previously tried the same

I'll note that this line of desire would also apply to kafka, and pretty much every open source distributed service.

JY8752 commented 2 months ago

@hughesjj I also want to write a test for redis cluster using testcontainers but it is failing. Please let me know if you make any progress!!

eddumelendez commented 1 month ago

I did an example using Testcontainers for Java in the past. See SO https://stackoverflow.com/questions/74822259/testcontainers-jedisconnectionexception-could-not-get-a-resource-from-the-pool/75251597#75251597

kiview commented 1 month ago

@hughesjj Since you shared already your tests that utilizes a Redis cluster setup, would you like to contribute it?

@mdelapenya Should such an example go into the tests, or do we also have a plan for dedicated example modules within tc-go?

mdelapenya commented 1 month ago

For examples, I usually suggest using the testable example pattern, in the examples_test.go file.