use of com.palantir.atlasdb.timelock.util.ExceptionMatchers in project atlasdb by palantir.
the class MultiNodePaxosTimeLockServerIntegrationTest method blockedLockRequestThrows503OnLeaderElectionForRemoteLock.
@Test
public void blockedLockRequestThrows503OnLeaderElectionForRemoteLock() throws InterruptedException {
LockRefreshToken lock = CLUSTER.remoteLock(CLIENT_1, BLOCKING_LOCK_REQUEST);
assertThat(lock).isNotNull();
TestableTimelockServer leader = CLUSTER.currentLeader();
CompletableFuture<LockRefreshToken> lockRefreshTokenCompletableFuture = CompletableFuture.supplyAsync(() -> {
try {
return leader.remoteLock(CLIENT_2, BLOCKING_LOCK_REQUEST);
} catch (InterruptedException e) {
return null;
}
});
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
CLUSTER.nonLeaders().forEach(TestableTimelockServer::kill);
// Lock on leader so that AwaitingLeadershipProxy notices leadership loss.
assertThatThrownBy(() -> leader.remoteLock(CLIENT_3, BLOCKING_LOCK_REQUEST)).satisfies(ExceptionMatchers::isRetryableExceptionWhereLeaderCannotBeFound);
assertThat(catchThrowable(lockRefreshTokenCompletableFuture::get).getCause()).satisfies(ExceptionMatchers::isRetryableExceptionWhereLeaderCannotBeFound);
}
Aggregations