use of io.camunda.zeebe.client.ZeebeClient in project zeebe-process-test by camunda-cloud.
the class ZeebeProcessTestExtension method afterEach.
/**
* After each test the test engine en client will be closed. The {@link RecordStream} will get
* reset.
*
* @param extensionContext jUnit5 extension context
*/
@Override
public void afterEach(final ExtensionContext extensionContext) {
BpmnAssert.resetRecordStream();
final Object clientContent = getStore(extensionContext).get(KEY_ZEEBE_CLIENT);
final ZeebeClient client = (ZeebeClient) clientContent;
client.close();
final Object engineContent = getStore(extensionContext).get(KEY_ZEEBE_ENGINE);
final ZeebeTestEngine engine = (ZeebeTestEngine) engineContent;
engine.stop();
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe by zeebe-io.
the class ResponsiveHealthIndicatorTest method testCreateZeebeClientShouldPassCertificateChainPathIfSecurityIsEnabled.
@Test
public void testCreateZeebeClientShouldPassCertificateChainPathIfSecurityIsEnabled() {
// given
final var securityEnabledGatewayCfg = new GatewayCfg();
securityEnabledGatewayCfg.getNetwork().setHost("testhost");
securityEnabledGatewayCfg.getNetwork().setPort(1234);
securityEnabledGatewayCfg.getSecurity().setEnabled(true);
securityEnabledGatewayCfg.getSecurity().setCertificateChainPath(new File(CERTIFICATE_CHAIN_PATH));
securityEnabledGatewayCfg.init();
// when
final ZeebeClient actualZeebeClient = ResponsiveHealthIndicator.createZeebeClient(securityEnabledGatewayCfg, TEST_DURATION);
// then
assertThat(actualZeebeClient.getConfiguration().isPlaintextConnectionEnabled()).isFalse();
assertThat(actualZeebeClient.getConfiguration().getCaCertificatePath()).isEqualTo(CERTIFICATE_CHAIN_PATH);
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe by zeebe-io.
the class ResponsiveHealthIndicatorTest method testCreateZeebeClientShouldConfigureContactPoint.
@Test
public void testCreateZeebeClientShouldConfigureContactPoint() {
// when
final ZeebeClient actual = ResponsiveHealthIndicator.createZeebeClient(TEST_CFG, TEST_DURATION);
// then
assertThat(actual.getConfiguration().getGatewayAddress()).isEqualTo("testhost:1234");
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe by zeebe-io.
the class ResponsiveHealthIndicatorTest method testCreateZeebeClientShouldEnablePlainTextCommunicationIfSecurityIsDisabled.
@Test
public void testCreateZeebeClientShouldEnablePlainTextCommunicationIfSecurityIsDisabled() {
// when
final ZeebeClient actual = ResponsiveHealthIndicator.createZeebeClient(TEST_CFG, TEST_DURATION);
// then
assertThat(actual.getConfiguration().isPlaintextConnectionEnabled()).isTrue();
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe by zeebe-io.
the class WorkloadGenerator method performSampleWorkload.
/**
* Given a client, deploy a process, start instances, work on service tasks, create and resolve
* incidents and finish the instance.
*/
public static void performSampleWorkload(final ZeebeClient client) {
client.newDeployResourceCommand().addProcessModel(SAMPLE_PROCESS, "sample_process.bpmn").send().join();
final Map<String, Object> variables = new HashMap<>();
variables.put("orderId", "foo-bar-123");
variables.put("largeValue", "x".repeat(8192));
variables.put("unicode", "Á");
variables.put("nullable", null);
final long processInstanceKey = client.newCreateInstanceCommand().bpmnProcessId("testProcess").latestVersion().variables(variables).send().join().getProcessInstanceKey();
// create job worker which fails on first try and sets retries to 0 to create an incident
final AtomicBoolean fail = new AtomicBoolean(true);
final JobWorker worker = client.newWorker().jobType("work").handler((handlerClient, job) -> {
if (fail.getAndSet(false)) {
// fail job
handlerClient.newFailCommand(job.getKey()).retries(0).errorMessage("failed").send().join();
} else {
handlerClient.newCompleteCommand(job.getKey()).send().join();
}
}).open();
client.newPublishMessageCommand().messageName("catch").correlationKey("foo-bar-123").send().join();
// wait for incident and resolve it
final Record<IncidentRecordValue> incident = Awaitility.await("the incident was created").timeout(Duration.ofMinutes(1)).until(() -> RecordingExporter.incidentRecords(IncidentIntent.CREATED).withProcessInstanceKey(processInstanceKey).withElementId("task").findFirst(), Optional::isPresent).orElseThrow();
client.newUpdateRetriesCommand(incident.getValue().getJobKey()).retries(3).send().join();
client.newResolveIncidentCommand(incident.getKey()).send().join();
// wrap up
Awaitility.await("the process instance was completed").timeout(Duration.ofMinutes(1)).until(() -> RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_COMPLETED).filter(r -> r.getKey() == processInstanceKey).exists());
worker.close();
}
Aggregations