Skip to content

Commit

Permalink
fix: use a timeout in pulsar example
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Nov 10, 2022
1 parent 4210a10 commit 853375f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions examples/pulsar/pulsar.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import (
"context"
"fmt"
"io"
"time"

"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
)

const defaultTimeout = time.Minute * 3

type pulsarContainer struct {
testcontainers.Container
URI string
Expand All @@ -24,9 +27,9 @@ func setupPulsar(ctx context.Context) (*pulsarContainer, error) {
Image: "docker.io/apachepulsar/pulsar:2.10.2",
ExposedPorts: []string{"6650/tcp", "8080/tcp"},
WaitingFor: wait.ForAll(
wait.ForHTTP("/admin/v2/clusters").WithPort("8080/tcp").WithResponseMatcher(matchAdminResponse),
wait.ForLog("Successfully updated the policies on namespace public/default"),
),
wait.ForHTTP("/admin/v2/clusters").WithPort("8080/tcp").WithResponseMatcher(matchAdminResponse).WithStartupTimeout(defaultTimeout),
wait.ForLog("Successfully updated the policies on namespace public/default").WithStartupTimeout(defaultTimeout),
).WithStartupTimeout(defaultTimeout),
Cmd: []string{
"/bin/bash",
"-c",
Expand Down
2 changes: 1 addition & 1 deletion examples/pulsar/pulsar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestPulsar(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
defer cancel()

c, err := setupPulsar(ctx)
Expand Down

0 comments on commit 853375f

Please sign in to comment.