Search in sources :

Example 1 with ExceptionMatchers

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);
}
Also used : LockRefreshToken(com.palantir.lock.LockRefreshToken) ExceptionMatchers(com.palantir.atlasdb.timelock.util.ExceptionMatchers) Test(org.junit.Test)

Aggregations

ExceptionMatchers (com.palantir.atlasdb.timelock.util.ExceptionMatchers)1 LockRefreshToken (com.palantir.lock.LockRefreshToken)1 Test (org.junit.Test)1