Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startup timeout will be ignored when enabling functionsWorkerEnabled in pulsar container #5252

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
import org.testcontainers.containers.wait.strategy.WaitStrategy;
import org.testcontainers.utility.DockerImageName;

import java.time.Duration;

/**
* This container wraps Apache Pulsar running in standalone mode
*/
Expand All @@ -19,6 +22,8 @@ public class PulsarContainer extends GenericContainer<PulsarContainer> {

private boolean functionsWorkerEnabled = false;

private Duration startupTimeout;

/**
* @deprecated use {@link PulsarContainer(DockerImageName)} instead
*/
Expand Down Expand Up @@ -54,11 +59,20 @@ protected void configure() {
waitingFor(
new WaitAllStrategy()
.withStrategy(waitStrategy)
.withStrategy(Wait.forLogMessage(".*Function worker service started.*", 1))
.withStrategy(Wait.forLogMessage(".*Function worker service started.*", 1)
// NOTE withStartupTimeout must be called at the end, because start timeout will be
// applied to all strategies above
.withStartupTimeout(startupTimeout))
);
}
}

@Override
public PulsarContainer withStartupTimeout(Duration startupTimeout) {
this.startupTimeout = startupTimeout;
return super.withStartupTimeout(startupTimeout);
}

public PulsarContainer withFunctionsWorker() {
functionsWorkerEnabled = true;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void testUsage() throws Exception {

@Test
public void shouldNotEnableFunctionsWorkerByDefault() throws Exception {
try (PulsarContainer pulsar = new PulsarContainer("2.5.1")) {
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)) {
pulsar.start();

PulsarAdmin pulsarAdmin = PulsarAdmin.builder()
Expand All @@ -44,7 +44,8 @@ public void shouldNotEnableFunctionsWorkerByDefault() throws Exception {

@Test
public void shouldWaitForFunctionsWorkerStarted() throws Exception {
try (PulsarContainer pulsar = new PulsarContainer("2.5.1").withFunctionsWorker()) {
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withFunctionsWorker()) {

pulsar.start();

PulsarAdmin pulsarAdmin = PulsarAdmin.builder()
Expand Down