Skip to content

Commit

Permalink
[HUDI-4518] Add unit test for reentrant lock in diff lockProvider (ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightChess authored and fengjian committed Apr 5, 2023
1 parent 68ad280 commit 6fc264c
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -125,6 +125,28 @@ public void testReentrantLock() throws Exception {
// expected
}
lockProvider.unlock();

// not acquired in the beginning
HiveMetastoreBasedLockProvider lockProvider1 = new HiveMetastoreBasedLockProvider(lockConfiguration, hiveConf());
HiveMetastoreBasedLockProvider lockProvider2 = new HiveMetastoreBasedLockProvider(lockConfiguration, hiveConf());
lockComponent.setOperationType(DataOperationType.NO_TXN);
Assertions.assertTrue(lockProvider1.acquireLock(lockConfiguration.getConfig()
.getLong(LOCK_ACQUIRE_WAIT_TIMEOUT_MS_PROP_KEY), TimeUnit.MILLISECONDS, lockComponent));
try {
boolean acquireStatus = lockProvider2.acquireLock(lockConfiguration.getConfig()
.getLong(LOCK_ACQUIRE_WAIT_TIMEOUT_MS_PROP_KEY), TimeUnit.MILLISECONDS, lockComponent);
Assertions.assertFalse(acquireStatus);
} catch (IllegalArgumentException e) {
// expected
}
lockProvider1.unlock();
Assertions.assertTrue(lockProvider2.acquireLock(lockConfiguration.getConfig()
.getLong(LOCK_ACQUIRE_WAIT_TIMEOUT_MS_PROP_KEY), TimeUnit.MILLISECONDS, lockComponent));
lockProvider2.unlock();

lockProvider.close();
lockProvider1.close();
lockProvider2.close();
}

@Test
Expand Down

0 comments on commit 6fc264c

Please sign in to comment.