Skip to content

Commit

Permalink
fix: avoid polluting default wait strategies in pulsar
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Sep 11, 2023
1 parent c8a8a7b commit 1f64536
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions modules/pulsar/pulsar.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func WithFunctionsWorker() testcontainers.CustomizeRequestOption {
return func(req *testcontainers.GenericContainerRequest) {
req.Cmd = []string{"/bin/bash", "-c", defaultPulsarCmd}

// add the waiting strategy for the functions worker
defaultWaitStrategies.Strategies = append(
defaultWaitStrategies.Strategies,
ss := []wait.Strategy{
wait.ForLog("Function worker service started"),
)
}

req.WaitingFor = defaultWaitStrategies
ss = append(ss, defaultWaitStrategies.Strategies...)

req.WaitingFor = wait.ForAll(ss...)
}
}

Expand Down Expand Up @@ -108,15 +108,16 @@ func WithTransactions() testcontainers.CustomizeRequestOption {
return func(req *testcontainers.GenericContainerRequest) {
WithPulsarEnv("transactionCoordinatorEnabled", "true")(req)

// add the waiting strategy for the transaction topic
defaultWaitStrategies.Strategies = append(
defaultWaitStrategies.Strategies,
// clone defaultWaitStrategies
ss := []wait.Strategy{
wait.ForHTTP(transactionTopicEndpoint).WithPort(defaultPulsarAdminPort).WithStatusCodeMatcher(func(statusCode int) bool {
return statusCode == 200
}),
)
}

ss = append(ss, defaultWaitStrategies.Strategies...)

req.WaitingFor = defaultWaitStrategies
req.WaitingFor = wait.ForAll(ss...)
}
}

Expand Down

0 comments on commit 1f64536

Please sign in to comment.