Skip to content

Commit

Permalink
refactor: improve Redis container readiness check with CLI ping command
Browse files Browse the repository at this point in the history
- Change the Redis container readiness check from waiting for a log message to executing a Redis CLI ping command.

Signed-off-by: appleboy <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Jan 18, 2025
1 parent 3cd7a6f commit 142493e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 142493e

Please sign in to comment.