Skip to content

Commit 142493e

Browse files
committed
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 <[email protected]>
1 parent 3cd7a6f commit 142493e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

redis_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ func setupRedisContainer(ctx context.Context, t *testing.T) (testcontainers.Cont
9797
req := testcontainers.ContainerRequest{
9898
Image: "redis:6",
9999
ExposedPorts: []string{"6379/tcp"},
100-
WaitingFor: wait.ForLog("Ready to accept connections"),
100+
WaitingFor: wait.NewExecStrategy(
101+
[]string{"redis-cli", "-h", "localhost", "-p", "6379", "ping"},
102+
),
101103
}
102104
redisC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
103105
ContainerRequest: req,

0 commit comments

Comments
 (0)