use of io.camunda.zeebe.client.ZeebeClient in project zeebe-test-container by camunda-community-hub.
the class ZeebeClusterWithEmbeddedGatewaysExampleTest method shouldStartCluster.
@Test
@Timeout(value = 15, unit = TimeUnit.MINUTES)
void shouldStartCluster() {
// given
final Topology topology;
// when
try (final ZeebeClient client = cluster.newClientBuilder().build()) {
topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
}
// then
final List<BrokerInfo> brokers = topology.getBrokers();
Assertions.assertThat(brokers).as("the topology contains all the brokers, advertising the expected address").hasSize(2).extracting(BrokerInfo::getAddress).containsExactlyInAnyOrder(cluster.getBrokers().get(0).getInternalCommandAddress(), cluster.getBrokers().get(1).getInternalCommandAddress());
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe-test-container by camunda-community-hub.
the class ZeebeBrokerNodeTest method shouldReuseHostDataOnRestart.
@Timeout(value = 5, unit = TimeUnit.MINUTES)
@ParameterizedTest(name = "{0}")
@MethodSource("reuseDataTestCases")
@EnabledOnOs(LINUX)
void shouldReuseHostDataOnRestart(@SuppressWarnings("unused") final String testName, final BrokerNodeProvider brokerNodeProvider, @TempDir final Path dataDir) {
// given
final ZeebeBrokerNode<?> broker = brokerNodeProvider.apply(dataDir);
final ZeebeGatewayContainer gateway = new ZeebeGatewayContainer().withEnv("ZEEBE_GATEWAY_CLUSTER_CONTACTPOINT", broker.getInternalClusterAddress());
// when
broker.start();
gateway.start();
try (final ZeebeClient client = ZeebeClientFactory.newZeebeClient(gateway)) {
// deploy a new process, which we can use on restart to assert that the data was correctly
// reused
final DeploymentEvent deployment = deploySampleProcess(client);
broker.stop();
// on restart we need to wait until the gateway is aware of the new leader
broker.start();
awaitUntilTopologyIsComplete(client);
final ProcessInstanceEvent processInstance = createSampleProcessInstance(client);
// then
assertThat(processInstance).as("the process instance was successfully created").isNotNull().extracting(ProcessInstanceEvent::getProcessDefinitionKey).isEqualTo(deployment.getProcesses().get(0).getProcessDefinitionKey());
} finally {
CloseHelper.quietCloseAll(gateway, broker);
}
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe-test-container by camunda-community-hub.
the class ZeebeContainerTest method shouldStartWithEmbeddedGatewayByDefault.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void shouldStartWithEmbeddedGatewayByDefault() {
// given
final Topology topology;
// when
try (final ZeebeClient client = ZeebeClientFactory.newZeebeClient(zeebeContainer)) {
topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
}
// then
// as we're not testing the client/gateway themselves, it's fine to simply assert we get a
// successful response here - the property we assert isn't too important
Assertions.assertThat(topology.getGatewayVersion()).as("the gateway is started").isEqualTo(ZeebeDefaults.getInstance().getDefaultVersion());
}
use of io.camunda.zeebe.client.ZeebeClient in project spring-zeebe by camunda-community-hub.
the class DeploymentPostProcessor method apply.
@Override
public Consumer<ZeebeClient> apply(final ClassInfo beanInfo) {
final ZeebeDeploymentValue value = reader.applyOrThrow(beanInfo);
LOGGER.info("deployment: {}", value);
return client -> {
DeployResourceCommandStep1 deployResourceCommand = client.newDeployResourceCommand();
DeploymentEvent deploymentResult = value.getResources().stream().flatMap(resource -> Stream.of(getResources(resource))).map(resource -> {
try (InputStream inputStream = resource.getInputStream()) {
return deployResourceCommand.addResourceStream(inputStream, resource.getFilename());
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}).filter(Objects::nonNull).reduce((first, second) -> second).orElseThrow(() -> new IllegalArgumentException("Requires at least one resource to deploy")).send().join();
LOGGER.info("Deployed: {}", Stream.concat(deploymentResult.getDecisionRequirements().stream().map(wf -> String.format("<%s:%d>", wf.getDmnDecisionRequirementsId(), wf.getVersion())), deploymentResult.getProcesses().stream().map(wf -> String.format("<%s:%d>", wf.getBpmnProcessId(), wf.getVersion()))).collect(Collectors.joining(",")));
};
}
use of io.camunda.zeebe.client.ZeebeClient in project spring-zeebe by camunda-community-hub.
the class InitializeAllZeebePostProcessor method postProcessAfterInitialization.
@Override
public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException {
final ClassInfo beanInfo = ClassInfo.builder().bean(bean).beanName(beanName).build();
for (final AbstractZeebePostProcessor p : processors) {
if (!p.test(beanInfo)) {
continue;
}
final Consumer<ZeebeClient> c = p.apply(beanInfo);
clientLifecycle.addStartListener(c);
}
return bean;
}
Aggregations