Skip to content

Commit

Permalink
Improve Pulsar's wait strategy to rely on clusterName (#5613)
Browse files Browse the repository at this point in the history
`PulsarContainer` allow to override configuration using env vars,
using `PULSAR_PREFIX_clusterName" will override the default's value
"standalone". The endpoint response should adapt accordingly.
  • Loading branch information
eddumelendez committed Jul 28, 2022
1 parent fca585d commit 1419cf2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -96,13 +96,13 @@ protected void setupCommandAndEnv() {

withCommand("/bin/bash", "-c", standaloneBaseCommand);

final String clusterName = getEnvMap().getOrDefault("PULSAR_PREFIX_clusterName", "standalone");
final String response = String.format("[\"%s\"]", clusterName);

List<WaitStrategy> waitStrategies = new ArrayList<>();
waitStrategies.add(Wait.defaultWaitStrategy());
waitStrategies.add(
Wait
.forHttp(ADMIN_CLUSTERS_ENDPOINT)
.forPort(BROKER_HTTP_PORT)
.forResponsePredicate("[\"standalone\"]"::equals)
Wait.forHttp(ADMIN_CLUSTERS_ENDPOINT).forPort(BROKER_HTTP_PORT).forResponsePredicate(response::equals)
);
if (transactionsEnabled) {
withEnv("PULSAR_PREFIX_transactionCoordinatorEnabled", "true");
Expand Down
Expand Up @@ -54,6 +54,17 @@ public void envVarsUsage() throws Exception {
}
}

@Test
public void customClusterName() throws Exception {
try (
PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)
.withEnv("PULSAR_PREFIX_clusterName", "tc-cluster");
) {
pulsar.start();
testPulsarFunctionality(pulsar.getPulsarBrokerUrl());
}
}

@Test
public void shouldNotEnableFunctionsWorkerByDefault() throws Exception {
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)) {
Expand Down

0 comments on commit 1419cf2

Please sign in to comment.