From 142493ef86a7e475a2f84acca9a87ca59b3dbf8f Mon Sep 17 00:00:00 2001 From: appleboy Date: Sat, 18 Jan 2025 17:55:48 +0800 Subject: [PATCH] refactor: improve Redis container readiness check with CLI ping command - Change the Redis container readiness check from waiting for a log message to executing a Redis CLI ping command. Signed-off-by: appleboy --- redis_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/redis_test.go b/redis_test.go index 1494cb5..660ff28 100644 --- a/redis_test.go +++ b/redis_test.go @@ -97,7 +97,9 @@ func setupRedisContainer(ctx context.Context, t *testing.T) (testcontainers.Cont req := testcontainers.ContainerRequest{ Image: "redis:6", ExposedPorts: []string{"6379/tcp"}, - WaitingFor: wait.ForLog("Ready to accept connections"), + WaitingFor: wait.NewExecStrategy( + []string{"redis-cli", "-h", "localhost", "-p", "6379", "ping"}, + ), } redisC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ ContainerRequest: req,