Skip to content

Commit

Permalink
Merge pull request #9100 from camunda/backport-9097-to-stable/8.0
Browse files Browse the repository at this point in the history
[Backport stable/8.0] Wait for gateway start in StandaloneGateway
  • Loading branch information
npepinpe authored Apr 11, 2022
2 parents fc61f30 + 52fdd39 commit 4bf32f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void run(final String... args) throws Exception {

actorScheduler.start();
atomixCluster.start();
gateway.start();
gateway.start().join(30, TimeUnit.SECONDS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
import static org.assertj.core.api.Assertions.assertThat;

import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.Topology;
import io.camunda.zeebe.client.api.command.ClientStatusException;
import io.camunda.zeebe.gateway.StandaloneGateway;
import io.camunda.zeebe.gateway.impl.configuration.GatewayCfg;
import io.grpc.Status.Code;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.filter.log.RequestLoggingFilter;
import io.restassured.filter.log.ResponseLoggingFilter;
import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import java.time.Duration;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -71,15 +70,16 @@ void smokeTest() {
.then()
.statusCode(200);

// we have to assert on the message here as we cannot otherwise differentiate between an
// UNAVAILABLE returned by the client, and one returned by the gateway, other than them having
// different messages
assertThat((CompletionStage<Topology>) topology)
.as("fails with UNAVAILABLE since there are no brokers")
.failsWithin(Duration.ofSeconds(5))
.withThrowableOfType(ExecutionException.class)
.havingRootCause()
.withMessage("UNAVAILABLE: No brokers available");
// depending on how fast the gateway is, we may get an unavailable error or an empty topology
try {
final var result = topology.join(5L, TimeUnit.SECONDS);
assertThat(result.getBrokers()).as("there are no known brokers").isEmpty();
} catch (final ClientStatusException e) {
assertThat(e).hasRootCauseMessage("UNAVAILABLE: No brokers available");
assertThat(e.getStatus().getCode()).isEqualTo(Code.UNAVAILABLE);
} catch (final Exception e) {
throw e;
}
}
}

Expand Down

0 comments on commit 4bf32f2

Please sign in to comment.