Search in sources :

Example 21 with ZeebeClient

use of io.zeebe.client.ZeebeClient in project zeebe by zeebe-io.

the class BrokerRecoveryTest method shouldCreateUniquePartitionIdsAfterRestart.

@Test
public void shouldCreateUniquePartitionIdsAfterRestart() {
    // given
    final ZeebeClient client = clientRule.getClient();
    client.topics().create("foo", 2).execute();
    restartBroker();
    // when
    client.topics().create("bar", 2).execute();
    // then
    final TopologyResponse topology = client.requestTopology().execute();
    final List<TopologyBroker> brokers = topology.getBrokers();
    assertThat(brokers).hasSize(1);
    final TopologyBroker topologyBroker = brokers.get(0);
    final List<BrokerPartitionState> partitions = topologyBroker.getPartitions();
    // default partition + system partition + 4 partitions we create here
    assertThat(partitions).hasSize(6);
    assertThat(partitions).extracting("partitionId").doesNotHaveDuplicates();
}
Also used : ZeebeClient(io.zeebe.client.ZeebeClient) TopologyResponse(io.zeebe.client.clustering.impl.TopologyResponse) BrokerPartitionState(io.zeebe.client.clustering.impl.BrokerPartitionState) TopologyBroker(io.zeebe.client.clustering.impl.TopologyBroker) Test(org.junit.Test)

Example 22 with ZeebeClient

use of io.zeebe.client.ZeebeClient in project zeebe by zeebe-io.

the class TaskQueueTest method shouldFailCreateTaskIfTopicNameIsNotValid.

@Test
public void shouldFailCreateTaskIfTopicNameIsNotValid() {
    final ZeebeClient client = clientRule.getClient();
    thrown.expect(RuntimeException.class);
    thrown.expectMessage("Cannot determine target partition for request. " + "Request was: [ topic = unknown-topic, partition = any, event type = TASK, state = CREATE ]");
    client.tasks().create("unknown-topic", "foo").addCustomHeader("k1", "a").addCustomHeader("k2", "b").payload("{ \"payload\" : 123 }").execute();
}
Also used : ZeebeClient(io.zeebe.client.ZeebeClient) Test(org.junit.Test)

Aggregations

ZeebeClient (io.zeebe.client.ZeebeClient)22 Test (org.junit.Test)15 ClientProperties (io.zeebe.client.ClientProperties)8 Properties (java.util.Properties)7 ZeebeClientImpl (io.zeebe.client.impl.ZeebeClientImpl)5 TaskEvent (io.zeebe.client.event.TaskEvent)4 TopologyBroker (io.zeebe.client.clustering.impl.TopologyBroker)3 TopologyResponse (io.zeebe.client.clustering.impl.TopologyResponse)3 Duration (java.time.Duration)3 Scanner (java.util.Scanner)3 BrokerPartitionState (io.zeebe.client.clustering.impl.BrokerPartitionState)2 ClientCommandRejectedException (io.zeebe.client.cmd.ClientCommandRejectedException)2 TaskSubscription (io.zeebe.client.task.TaskSubscription)2 Topic (io.zeebe.client.topic.Topic)2 Topics (io.zeebe.client.topic.Topics)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Rule (org.junit.Rule)2 ClientRule (io.zeebe.broker.it.ClientRule)1