forked from camunda-community-hub/zeebe-test-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZeebeClusterWithGatewayExampleTest.java
69 lines (63 loc) · 2.3 KB
/
ZeebeClusterWithGatewayExampleTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright © 2019 camunda services GmbH ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.zeebe.containers.examples.cluster;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.BrokerInfo;
import io.camunda.zeebe.client.api.response.Topology;
import io.zeebe.containers.cluster.ZeebeCluster;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
/**
* Showcases how you can create a test with a cluster of two brokers and one standalone gateway.
* Configuration is kept to minimum, as the goal here is only to showcase how to connect the
* different nodes together.
*/
class ZeebeClusterWithGatewayExampleTest {
private final ZeebeCluster cluster =
ZeebeCluster.builder()
.withEmbeddedGateway(false)
.withGatewaysCount(1)
.withBrokersCount(1)
.withPartitionsCount(1)
.withReplicationFactor(1)
.build();
@AfterEach
void tearDown() {
cluster.stop();
}
@Test
@Timeout(value = 15, unit = TimeUnit.MINUTES)
void shouldStartCluster() {
// given
cluster.start();
// when
final Topology topology;
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(1)
.extracting(BrokerInfo::getAddress)
.containsExactlyInAnyOrder(cluster.getBrokers().get(0).getInternalCommandAddress());
}
}