use of io.zeebe.containers.ZeebeContainer in project zeebe-test-container by camunda-community-hub.
the class RestartWithExtractedDataExampleTest method shouldGenerateData.
/**
* Start a container with a volume, deploy a process, and extract the generated data to some
* folder. In the next test, we will reuse this data to create a process instance, proving that
* the data was successfully reused.
*
* <p>NOTE: since Zeebe is an asynchronous system, and we cannot guarantee when the engine is
* idle, we stop the container before extracting the data. This causes us to start a second
* (albeit tiny) container to extract the data.
*
* <p>If you all you wanted was to extract data from a live container, then you can use the {@link
* ContainerArchive#builder()} directly and pass in your live container. For such a use case, you
* wouldn't even need to be using a volume.
*/
@Test
@Order(1)
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void shouldGenerateData() throws IOException {
// given
final ZeebeVolume volume = ZeebeVolume.newVolume();
final Path destination = tempDir.resolve(DATA_DIR);
// when
try (final ZeebeContainer container = new ZeebeContainer().withZeebeData(volume)) {
container.start();
deployProcess(container);
}
volume.extract(destination);
// then
assertThat(destination).isNotEmptyDirectory();
}
use of io.zeebe.containers.ZeebeContainer in project zeebe-test-container by camunda-community-hub.
the class TriggerTimerStartEventTest 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().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();
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-test-container by camunda-community-hub.
the class ClusterWithEmbeddedGatewaysExampleTest method shouldStartCluster.
@Test
@Timeout(value = 15, unit = TimeUnit.MINUTES)
void shouldStartCluster() {
// given
Startables.deepStart(containers).join();
// when
for (final ZeebeContainer gateway : containers) {
try (final ZeebeClient client = newZeebeClient(gateway)) {
// then
final Topology topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
final List<BrokerInfo> brokers = topology.getBrokers();
Assertions.assertThat(brokers).as("the topology contains all the brokers, advertising the correct address").hasSize(3).extracting(BrokerInfo::getAddress).containsExactlyInAnyOrder(nodeZeroContainer.getInternalCommandAddress(), nodeOneContainer.getInternalCommandAddress(), nodeTwoContainer.getInternalCommandAddress());
}
}
}
Aggregations