use of io.zeebe.containers.ZeebeContainer in project zeebe-test-container by camunda-community-hub.
the class ClusterWithEmbeddedGatewaysExampleTest method getConfiguredClusterBroker.
/**
* Will configure the broker in {@code brokers} at index {@code index} for a basic cluster that
* contains all {@code brokers}. Note that depending on the machine on which you're running, the
* containers may be quite slow, so make sure to provide them enough cores/memory.
*
* @param index the index of the broker to configure and return in {@code brokers}
* @param brokers all the brokers part of the cluster
* @return the broker at index {@code index} in {@code brokers}, configured for clustering
*/
private ZeebeContainer getConfiguredClusterBroker(final int index, final List<ZeebeContainer> brokers) {
final int clusterSize = brokers.size();
final String initialContactPoints = brokers.stream().map(ZeebeBrokerNode::getInternalClusterAddress).collect(Collectors.joining(","));
final ZeebeContainer broker = brokers.get(index);
return broker.withTopologyCheck(new ZeebeTopologyWaitStrategy().forBrokersCount(clusterSize).forReplicationFactor(clusterSize)).withStartupTimeout(Duration.ofMinutes(5)).withEnv("ZEEBE_BROKER_CLUSTER_NODEID", String.valueOf(index)).withEnv("ZEEBE_BROKER_CLUSTER_CLUSTERSIZE", String.valueOf(clusterSize)).withEnv("ZEEBE_BROKER_CLUSTER_REPLICATIONFACTOR", String.valueOf(clusterSize)).withEnv("ZEEBE_BROKER_CLUSTER_INITIALCONTACTPOINTS", initialContactPoints);
}
use of io.zeebe.containers.ZeebeContainer in project zeebe-test-container by camunda-community-hub.
the class TriggerTimerCatchEventTest method shouldTriggerTimerStartEvent.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void shouldTriggerTimerStartEvent() {
// given
final ZeebeClock clock = ZeebeClock.newDefaultClock(zeebeContainer);
final BpmnModelInstance process = Bpmn.createExecutableProcess("process").startEvent().intermediateCatchEvent().timerWithDate(TIMER_DATE.toString()).serviceTask("task", b -> b.zeebeJobType(JOB_TYPE)).endEvent().done();
final List<ActivatedJob> activatedJobs = new CopyOnWriteArrayList<>();
final Instant brokerTime;
// when
final JobHandler handler = (client, job) -> activatedJobs.add(job);
try (final ZeebeClient client = newZeebeClient(zeebeContainer);
final JobWorker worker = newJobWorker(handler, client)) {
client.newDeployCommand().addProcessModel(process, "process.bpmn").send().join();
client.newCreateInstanceCommand().bpmnProcessId("process").latestVersion().send().join();
brokerTime = clock.addTime(TIME_OFFSET);
Awaitility.await("until a job has been activated by the worker").untilAsserted(() -> Assertions.assertThat(activatedJobs).hasSize(1));
}
// then
Assertions.assertThat(activatedJobs).as("the timer event was triggered and a job is now available").hasSize(1);
Assertions.assertThat(brokerTime).as("the modified time is at least equal to one day from now").isAfterOrEqualTo(TIMER_DATE);
}
use of io.zeebe.containers.ZeebeContainer in project zeebe by camunda.
the class ContainerState method start.
public void start(final boolean enableDebug, final boolean withRemoteDebugging) {
final String contactPoint;
broker = new ZeebeContainer(ZeebeTestContainerDefaults.defaultTestImage().withTag(brokerVersion)).withEnv("ZEEBE_LOG_LEVEL", "DEBUG").withEnv("ZEEBE_BROKER_NETWORK_MAXMESSAGESIZE", "128KB").withEnv("ZEEBE_BROKER_DATA_LOGSEGMENTSIZE", "64MB").withEnv("ZEEBE_BROKER_DATA_SNAPSHOTPERIOD", "1m").withEnv("ZEEBE_BROKER_DATA_LOGINDEXDENSITY", "1").withZeebeData(volume).withNetwork(network);
this.withRemoteDebugging = withRemoteDebugging;
if (withRemoteDebugging) {
RemoteDebugger.configureContainer(broker);
LOG.info("================================================");
LOG.info("About to start broker....");
LOG.info("The broker will wait for a debugger to connect to it at port " + RemoteDebugger.DEFAULT_REMOTE_DEBUGGER_PORT + ". It will wait for " + RemoteDebugger.DEFAULT_START_TIMEOUT.toString());
LOG.info("================================================");
}
if (enableDebug) {
broker = broker.withEnv("ZEEBE_DEBUG", "true");
}
Failsafe.with(CONTAINER_START_RETRY_POLICY).run(() -> broker.self().start());
if (gatewayVersion == null) {
contactPoint = broker.getExternalGatewayAddress();
} else {
gateway = new ZeebeGatewayContainer(ZeebeTestContainerDefaults.defaultTestImage().withTag(gatewayVersion)).withEnv("ZEEBE_GATEWAY_CLUSTER_CONTACTPOINT", broker.getInternalClusterAddress()).withEnv("ZEEBE_LOG_LEVEL", "DEBUG").withNetwork(network);
Failsafe.with(CONTAINER_START_RETRY_POLICY).run(() -> gateway.self().start());
contactPoint = gateway.getExternalGatewayAddress();
}
client = ZeebeClient.newClientBuilder().gatewayAddress(contactPoint).usePlaintext().build();
partitionsActuatorClient = new PartitionsActuatorClient(broker.getExternalMonitoringAddress());
}
use of io.zeebe.containers.ZeebeContainer in project zeebe by camunda-cloud.
the class ContainerState method start.
public void start(final boolean enableDebug, final boolean withRemoteDebugging) {
final String contactPoint;
broker = new ZeebeContainer(brokerImage).withEnv("ZEEBE_LOG_LEVEL", "DEBUG").withEnv("ZEEBE_BROKER_NETWORK_MAXMESSAGESIZE", "128KB").withEnv("ZEEBE_BROKER_DATA_LOGSEGMENTSIZE", "64MB").withEnv("ZEEBE_BROKER_DATA_SNAPSHOTPERIOD", "1m").withEnv("ZEEBE_BROKER_DATA_LOGINDEXDENSITY", "1").withZeebeData(volume).withNetwork(network);
this.withRemoteDebugging = withRemoteDebugging;
if (withRemoteDebugging) {
RemoteDebugger.configureContainer(broker);
LOG.info("================================================");
LOG.info("About to start broker....");
LOG.info("The broker will wait for a debugger to connect to it at port " + RemoteDebugger.DEFAULT_REMOTE_DEBUGGER_PORT + ". It will wait for " + RemoteDebugger.DEFAULT_START_TIMEOUT.toString());
LOG.info("================================================");
}
if (enableDebug) {
broker = broker.withEnv("ZEEBE_DEBUG", "true");
}
Failsafe.with(CONTAINER_START_RETRY_POLICY).run(() -> broker.self().start());
if (gatewayImage == null) {
contactPoint = broker.getExternalGatewayAddress();
} else {
gateway = new ZeebeGatewayContainer(gatewayImage).withEnv("ZEEBE_GATEWAY_CLUSTER_CONTACTPOINT", broker.getInternalClusterAddress()).withEnv("ZEEBE_LOG_LEVEL", "DEBUG").withNetwork(network);
Failsafe.with(CONTAINER_START_RETRY_POLICY).run(() -> gateway.self().start());
contactPoint = gateway.getExternalGatewayAddress();
}
client = ZeebeClient.newClientBuilder().gatewayAddress(contactPoint).usePlaintext().build();
partitionsActuatorClient = new PartitionsActuatorClient(broker.getExternalMonitoringAddress());
}
use of io.zeebe.containers.ZeebeContainer in project zeebe by zeebe-io.
the class BrokerMonitoringEndpointTest method setUpClass.
@BeforeClass
public static void setUpClass() {
sutBroker = new ZeebeContainer(ZeebeTestContainerDefaults.defaultTestImage());
sutBroker.start();
final Integer monitoringPort = sutBroker.getMappedPort(ZeebePort.MONITORING.getPort());
final String containerIPAddress = sutBroker.getExternalHost();
brokerServerSpec = new RequestSpecBuilder().setContentType(ContentType.TEXT).setBaseUri("http://" + containerIPAddress).setPort(monitoringPort).addFilter(new ResponseLoggingFilter()).addFilter(new RequestLoggingFilter()).build();
}
Aggregations