Adding a unit test
This commit is contained in:
parent
cadbc0503b
commit
15c45d2029
2 changed files with 21 additions and 8 deletions
|
|
@ -81,14 +81,16 @@ public class LeaseCleanupManager {
|
||||||
* {@link LeaseCleanupManager#leaseCleanupIntervalMillis}
|
* {@link LeaseCleanupManager#leaseCleanupIntervalMillis}
|
||||||
*/
|
*/
|
||||||
public void start() {
|
public void start() {
|
||||||
|
if (!isRunning) {
|
||||||
log.debug("Starting lease cleanup thread.");
|
log.debug("Starting lease cleanup thread.");
|
||||||
|
completedLeaseStopwatch.reset().start();
|
||||||
completedLeaseStopwatch.start();
|
garbageLeaseStopwatch.reset().start();
|
||||||
garbageLeaseStopwatch.start();
|
|
||||||
|
|
||||||
deletionThreadPool.scheduleAtFixedRate(new LeaseCleanupThread(), INITIAL_DELAY, leaseCleanupIntervalMillis,
|
deletionThreadPool.scheduleAtFixedRate(new LeaseCleanupThread(), INITIAL_DELAY, leaseCleanupIntervalMillis,
|
||||||
TimeUnit.MILLISECONDS);
|
TimeUnit.MILLISECONDS);
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
|
} else {
|
||||||
|
log.debug("Lease cleanup thread already running, no need to start.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
package software.amazon.kinesis.leases;
|
package software.amazon.kinesis.leases;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
@ -83,6 +84,16 @@ public class LeaseCleanupManagerTest {
|
||||||
when(leaseCoordinator.updateLease(any(Lease.class), any(UUID.class), any(String.class), any(String.class))).thenReturn(true);
|
when(leaseCoordinator.updateLease(any(Lease.class), any(UUID.class), any(String.class), any(String.class))).thenReturn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests subsequent calls to start {@link LeaseCleanupManager}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public final void testSubsequentStarts() {
|
||||||
|
leaseCleanupManager.start();
|
||||||
|
Assert.assertTrue(leaseCleanupManager.isRunning());
|
||||||
|
leaseCleanupManager.start();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that when both child shard leases are present, we are able to delete the parent shard for the completed
|
* Tests that when both child shard leases are present, we are able to delete the parent shard for the completed
|
||||||
* shard case.
|
* shard case.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue