use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput in project genius by opendaylight.
the class LockManagerTest method testLockAndUnLock.
@Test
public void testLockAndUnLock() throws InterruptedException, ExecutionException, TimeoutException {
LockInput lockInput = new LockInputBuilder().setLockName("testLock").build();
assertVoidRpcSuccess(lockManager.lock(lockInput));
UnlockInput unlockInput = new UnlockInputBuilder().setLockName("testLock").build();
assertVoidRpcSuccess(lockManager.unlock(unlockInput));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput in project genius by opendaylight.
the class LockManagerTest method testLockAndReLockSameAgain.
@Test
public // lock() RPC will infinitely retry, and it will only come out when the key is unlocked
void testLockAndReLockSameAgain() throws InterruptedException, ExecutionException, TimeoutException {
LockInput lockInput = new LockInputBuilder().setLockName("testLock").build();
assertVoidRpcSuccess(lockManager.lock(lockInput));
runUnlockTimerTask("testLock", 3000);
// This will retry infinitely since the other lock is not released!
// After 5 seconds, the parallel thread will unlock the key, and the below TC will pass
assertVoidRpcSuccess(lockManager.lock(lockInput));
}
Aggregations