Search in sources :

Example 1 with LeaseOption

use of io.etcd.jetcd.options.LeaseOption in project jetcd by coreos.

the class LeaseTest method testTimeToLiveWithKeys.

@Test
public void testTimeToLiveWithKeys() throws ExecutionException, InterruptedException {
    long ttl = 5;
    long leaseID = leaseClient.grant(ttl).get().getID();
    PutOption putOption = PutOption.newBuilder().withLeaseId(leaseID).build();
    kvClient.put(KEY_2, VALUE, putOption).get();
    LeaseOption leaseOption = LeaseOption.newBuilder().withAttachedKeys().build();
    LeaseTimeToLiveResponse resp = leaseClient.timeToLive(leaseID, leaseOption).get();
    assertThat(resp.getTTl()).isGreaterThan(0);
    assertThat(resp.getGrantedTTL()).isEqualTo(ttl);
    assertThat(resp.getKeys().size()).isEqualTo(1);
    assertThat(resp.getKeys().get(0)).isEqualTo(KEY_2);
}
Also used : LeaseTimeToLiveResponse(io.etcd.jetcd.lease.LeaseTimeToLiveResponse) LeaseOption(io.etcd.jetcd.options.LeaseOption) PutOption(io.etcd.jetcd.options.PutOption) Test(org.junit.jupiter.api.Test)

Aggregations

LeaseTimeToLiveResponse (io.etcd.jetcd.lease.LeaseTimeToLiveResponse)1 LeaseOption (io.etcd.jetcd.options.LeaseOption)1 PutOption (io.etcd.jetcd.options.PutOption)1 Test (org.junit.jupiter.api.Test)1