Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDB is considered healthy in UPDATING status #725

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public boolean createLeaseTableIfNotExists(@NonNull final Long readCapacity, @No
*/
@Override
public boolean leaseTableExists() throws DependencyException {
return TableStatus.ACTIVE == tableStatus();
TableStatus tableStatus = tableStatus();
return TableStatus.ACTIVE == tableStatus || TableStatus.UPDATING == tableStatus;
}

private TableStatus tableStatus() throws DependencyException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package software.amazon.kinesis.leases.dynamodb;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyLong;
Expand Down Expand Up @@ -54,6 +56,8 @@
import software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException;
import software.amazon.awssdk.services.dynamodb.model.ScanRequest;
import software.amazon.awssdk.services.dynamodb.model.ScanResponse;
import software.amazon.awssdk.services.dynamodb.model.TableDescription;
import software.amazon.awssdk.services.dynamodb.model.TableStatus;
import software.amazon.awssdk.services.dynamodb.model.UpdateItemRequest;
import software.amazon.awssdk.services.dynamodb.model.UpdateItemResponse;
import software.amazon.awssdk.services.dynamodb.model.BillingMode;
Expand Down Expand Up @@ -149,6 +153,46 @@ public void testCreateLeaseIfNotExistsTimesOut() throws Exception {
verifyCancel(mockPutItemFuture, () -> leaseRefresher.createLeaseIfNotExists(lease));
}

@Test
public void testWaitUntilLeaseTableExistsUpdatingStatus() throws Exception {
when(dynamoDbClient.describeTable(any(DescribeTableRequest.class))).thenReturn(mockDescribeTableFuture);
when(mockDescribeTableFuture.get(anyLong(), any()))
.thenReturn(DescribeTableResponse.builder()
.table(TableDescription.builder().tableStatus(TableStatus.UPDATING).build())
.build());
assertTrue(leaseRefresher.waitUntilLeaseTableExists(0, 0));
}

@Test
public void testWaitUntilLeaseTableExistsActiveStatus() throws Exception {
when(dynamoDbClient.describeTable(any(DescribeTableRequest.class))).thenReturn(mockDescribeTableFuture);
when(mockDescribeTableFuture.get(anyLong(), any()))
.thenReturn(DescribeTableResponse.builder()
.table(TableDescription.builder().tableStatus(TableStatus.ACTIVE).build())
.build());
assertTrue(leaseRefresher.waitUntilLeaseTableExists(0, 0));
}

@Test
public void testWaitUntilLeaseTableExistsCreatingStatus() throws Exception {
when(dynamoDbClient.describeTable(any(DescribeTableRequest.class))).thenReturn(mockDescribeTableFuture);
when(mockDescribeTableFuture.get(anyLong(), any()))
.thenReturn(DescribeTableResponse.builder()
.table(TableDescription.builder().tableStatus(TableStatus.CREATING).build())
.build());
assertFalse(leaseRefresher.waitUntilLeaseTableExists(0, 0));
}

@Test
public void testWaitUntilLeaseTableExistsDeletingStatus() throws Exception {
when(dynamoDbClient.describeTable(any(DescribeTableRequest.class))).thenReturn(mockDescribeTableFuture);
when(mockDescribeTableFuture.get(anyLong(), any()))
.thenReturn(DescribeTableResponse.builder()
.table(TableDescription.builder().tableStatus(TableStatus.DELETING).build())
.build());
assertFalse(leaseRefresher.waitUntilLeaseTableExists(0, 0));
}

@Test
public void testGetLeaseTimesOut() throws Exception {
TimeoutException te = setRuleForDependencyTimeout();
Expand Down