Limit the logical database index when creating new connections for redis in tests.
Redis provides by default 16 logical databases for one instance. Currently, we are not limiting this index, and when a test file creates more than 16 connections the tests starts to break
@@ -49,6 +49,9 @@ func WithRedisContainer(exec func(redisAddress string)) {
}
func GetRedisConnection(t *testing.T, redisAddress string) *redis.Client {
+ if atomic.LoadInt32(&dbNumber) >= 15 {
+ atomic.StoreInt32(&dbNumber, -1)
+ }
db := atomic.AddInt32(&dbNumber, 1)
client := redis.NewClient(&redis.Options{
Addr: redisAddress,
