use of io.zeebe.containers.ZeebeGatewayContainer in project zeebe by zeebe-io.
the class GatewayHealthProbeIntegrationTest method shouldReportReadinessUpIfNotAvailable.
@Test
public void shouldReportReadinessUpIfNotAvailable() throws IOException, InterruptedException {
// given
final ZeebeGatewayContainer gateway = new ZeebeGatewayContainer(ZeebeTestContainerDefaults.defaultTestImage()).withEnv("ZEEBE_GATEWAY_MONITORING_ENABLED", "true").withExposedPorts(ZeebePort.MONITORING.getPort()).withoutTopologyCheck().withStartupCheckStrategy(new IsRunningStartupCheckStrategy());
gateway.start();
final Integer actuatorPort = gateway.getMappedPort(ZeebePort.MONITORING.getPort());
final String containerIPAddress = gateway.getExternalHost();
final RequestSpecification gatewayServerSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).setBaseUri("http://" + containerIPAddress).setPort(actuatorPort).addFilter(new ResponseLoggingFilter()).addFilter(new RequestLoggingFilter()).build();
// when
// we are trying to kill process to make application unavailable
gateway.execInContainer("killbyname", "java");
// gateway finds the broker
try {
Awaitility.await("wait until status turns DOWN").atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofMillis(100)).untilAsserted(() -> given().spec(gatewayServerSpec).when().get(PATH_READINESS_PROBE).then().statusCode(503));
} catch (final ConditionTimeoutException e) {
// it can happen that a single request takes too long and causes awaitility to timeout,
// in which case we want to try a second time to run the request without timeout
given().spec(gatewayServerSpec).when().get(PATH_READINESS_PROBE).then().statusCode(503);
}
// --- shutdown ------------------------------------------
gateway.stop();
}
use of io.zeebe.containers.ZeebeGatewayContainer in project zeebe-test-container by camunda-community-hub.
the class ZeebeClusterBuilder method createStandaloneGateways.
private void createStandaloneGateways() {
final ThreadLocalRandom random = ThreadLocalRandom.current();
for (int i = 0; i < gatewaysCount; i++) {
final String memberId = GATEWAY_NETWORK_ALIAS_PREFIX + i;
final ZeebeGatewayContainer gateway = createStandaloneGateway(memberId);
gateway.withStartupTimeout(Duration.ofMinutes((long) gatewaysCount + brokersCount));
if (brokersCount > 0) {
final ZeebeBrokerNode<?> contactPoint = brokers.get(random.nextInt(0, brokers.size()));
gateway.dependsOn(contactPoint.self()).withEnv("ZEEBE_GATEWAY_CLUSTER_CONTACTPOINT", contactPoint.getInternalClusterAddress());
}
}
}
use of io.zeebe.containers.ZeebeGatewayContainer in project zeebe by camunda.
the class GatewayHealthProbeIntegrationTest method shouldReportReadinessUpIfApplicationIsUp.
@Test
public void shouldReportReadinessUpIfApplicationIsUp() {
// given
final ZeebeGatewayContainer gateway = new ZeebeGatewayContainer(ZeebeTestContainerDefaults.defaultTestImage()).withEnv("ZEEBE_GATEWAY_MONITORING_ENABLED", "true").withExposedPorts(ZeebePort.MONITORING.getPort()).withoutTopologyCheck().withStartupCheckStrategy(new IsRunningStartupCheckStrategy());
gateway.start();
final Integer actuatorPort = gateway.getMappedPort(ZeebePort.MONITORING.getPort());
final String containerIPAddress = gateway.getExternalHost();
final RequestSpecification gatewayServerSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).setBaseUri("http://" + containerIPAddress).setPort(actuatorPort).addFilter(new ResponseLoggingFilter()).addFilter(new RequestLoggingFilter()).build();
// gateway finds the broker
try {
Awaitility.await("wait until status turns UP").atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofMillis(100)).untilAsserted(() -> given().spec(gatewayServerSpec).when().get(PATH_READINESS_PROBE).then().statusCode(200));
} catch (final ConditionTimeoutException e) {
// it can happen that a single request takes too long and causes awaitility to timeout,
// in which case we want to try a second time to run the request without timeout
given().spec(gatewayServerSpec).when().get(PATH_READINESS_PROBE).then().statusCode(200);
}
// --- shutdown ------------------------------------------
gateway.stop();
}
use of io.zeebe.containers.ZeebeGatewayContainer in project zeebe by camunda.
the class GatewayHealthProbeIntegrationTest method shouldReportReadinessUpIfNotAvailable.
@Test
public void shouldReportReadinessUpIfNotAvailable() throws IOException, InterruptedException {
// given
final ZeebeGatewayContainer gateway = new ZeebeGatewayContainer(ZeebeTestContainerDefaults.defaultTestImage()).withEnv("ZEEBE_GATEWAY_MONITORING_ENABLED", "true").withExposedPorts(ZeebePort.MONITORING.getPort()).withoutTopologyCheck().withStartupCheckStrategy(new IsRunningStartupCheckStrategy());
gateway.start();
final Integer actuatorPort = gateway.getMappedPort(ZeebePort.MONITORING.getPort());
final String containerIPAddress = gateway.getExternalHost();
final RequestSpecification gatewayServerSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).setBaseUri("http://" + containerIPAddress).setPort(actuatorPort).addFilter(new ResponseLoggingFilter()).addFilter(new RequestLoggingFilter()).build();
// when
// we are trying to kill process to make application unavailable
gateway.execInContainer("killbyname", "java");
// gateway finds the broker
try {
Awaitility.await("wait until status turns DOWN").atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofMillis(100)).untilAsserted(() -> given().spec(gatewayServerSpec).when().get(PATH_READINESS_PROBE).then().statusCode(503));
} catch (final ConditionTimeoutException e) {
// it can happen that a single request takes too long and causes awaitility to timeout,
// in which case we want to try a second time to run the request without timeout
given().spec(gatewayServerSpec).when().get(PATH_READINESS_PROBE).then().statusCode(503);
}
// --- shutdown ------------------------------------------
gateway.stop();
}
use of io.zeebe.containers.ZeebeGatewayContainer in project zeebe by camunda.
the class GatewayHealthProbeIntegrationTest method shouldReportLivenessDownIfNotConnectedToBroker.
@Test
public void shouldReportLivenessDownIfNotConnectedToBroker() {
// --- given ---------------------------------------
final ZeebeGatewayContainer gateway = new ZeebeGatewayContainer(ZeebeTestContainerDefaults.defaultTestImage()).withEnv("ZEEBE_GATEWAY_MONITORING_ENABLED", "true").withoutTopologyCheck();
gateway.addExposedPorts(ZeebePort.MONITORING.getPort());
gateway.start();
final Integer actuatorPort = gateway.getMappedPort(ZeebePort.MONITORING.getPort());
final String containerIPAddress = gateway.getExternalHost();
final RequestSpecification gatewayServerSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).setBaseUri("http://" + containerIPAddress).setPort(actuatorPort).addFilter(new ResponseLoggingFilter()).addFilter(new RequestLoggingFilter()).build();
// --- when + then ---------------------------------------
given().spec(gatewayServerSpec).when().get(PATH_LIVENESS_PROBE).then().statusCode(503);
// --- shutdown ------------------------------------------
gateway.stop();
}
Aggregations