use of io.etcd.jetcd.Response in project jetcd by coreos.
the class LoadBalancerTest method testPickFirstBalancerFactory.
@Test
public void testPickFirstBalancerFactory() throws Exception {
final List<URI> endpoints = cluster.clientEndpoints();
final ClientBuilder builder = Client.builder().endpoints(endpoints).loadBalancerPolicy("pick_first");
try (Client client = builder.build();
KV kv = client.getKVClient()) {
long lastMemberId = 0;
final String allEndpoints = endpoints.stream().map(URI::toString).collect(Collectors.joining(","));
for (int i = 0; i < allEndpoints.length() * 2; i++) {
Response response = kv.put(TestUtil.randomByteSequence(), TestUtil.randomByteSequence()).get();
if (i == 0) {
lastMemberId = response.getHeader().getMemberId();
}
assertThat(response.getHeader().getMemberId()).isEqualTo(lastMemberId);
}
}
}
Aggregations