Also consider TableStatus.UPDATING status
This commit is contained in:
parent
17ecc87d71
commit
41c08c3b04
2 changed files with 25 additions and 1 deletions
|
|
@ -162,7 +162,8 @@ public class LeaseManager<T extends Lease> implements ILeaseManager<T> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean leaseTableExists() throws DependencyException {
|
public boolean leaseTableExists() throws DependencyException {
|
||||||
return TableStatus.ACTIVE == tableStatus();
|
TableStatus tableStatus = tableStatus();
|
||||||
|
return TableStatus.ACTIVE == tableStatus || TableStatus.UPDATING == tableStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TableStatus tableStatus() throws DependencyException {
|
private TableStatus tableStatus() throws DependencyException {
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,29 @@ public class LeaseManagerIntegrationTest extends LeaseIntegrationTest {
|
||||||
Assert.assertTrue(manager.waitUntilLeaseTableExists(1, 1));
|
Assert.assertTrue(manager.waitUntilLeaseTableExists(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWaitUntilLeaseTableExistsUpdatingStatus() throws LeasingException {
|
||||||
|
AmazonDynamoDBClient ddbMock = Mockito.mock(ddbClient.getClass());
|
||||||
|
DescribeTableResult result = Mockito.mock(DescribeTableResult.class);
|
||||||
|
TableDescription description = Mockito.mock(TableDescription.class);
|
||||||
|
Mockito.when(description.getTableStatus()).thenReturn(TableStatus.UPDATING.name());
|
||||||
|
Mockito.when(result.getTable()).thenReturn(description);
|
||||||
|
Mockito.when(ddbMock.describeTable(Mockito.any(DescribeTableRequest.class))).thenReturn(result);
|
||||||
|
KinesisClientLeaseManager manager = new KinesisClientLeaseManager("existing_table", ddbMock, true,
|
||||||
|
KinesisClientLibConfiguration.DEFAULT_DDB_BILLING_MODE) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
long sleep(long timeToSleepMillis) {
|
||||||
|
Assert.fail("Should not sleep");
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Assert.assertTrue(manager.waitUntilLeaseTableExists(1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWaitUntilLeaseTableExistsPayPerRequest() throws LeasingException {
|
public void testWaitUntilLeaseTableExistsPayPerRequest() throws LeasingException {
|
||||||
AmazonDynamoDBClient ddbMock = Mockito.mock(ddbClient.getClass());
|
AmazonDynamoDBClient ddbMock = Mockito.mock(ddbClient.getClass());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue