diff --git a/data-prepper-plugins/dynamodb-source-coordination-store/src/test/java/org/opensearch/dataprepper/plugins/sourcecoordinator/dynamodb/DynamoDbClientWrapperTest.java b/data-prepper-plugins/dynamodb-source-coordination-store/src/test/java/org/opensearch/dataprepper/plugins/sourcecoordinator/dynamodb/DynamoDbClientWrapperTest.java index d64913e862..d7c340c6a0 100644 --- a/data-prepper-plugins/dynamodb-source-coordination-store/src/test/java/org/opensearch/dataprepper/plugins/sourcecoordinator/dynamodb/DynamoDbClientWrapperTest.java +++ b/data-prepper-plugins/dynamodb-source-coordination-store/src/test/java/org/opensearch/dataprepper/plugins/sourcecoordinator/dynamodb/DynamoDbClientWrapperTest.java @@ -465,7 +465,7 @@ void getAvailablePartition_with_no_items_from_query_returns_empty_optional(final final int pageLimit = new Random().nextInt(20); - final Duration ttl = Duration.ofSeconds(new Random().nextInt()); + final Duration ttl = Duration.ofSeconds(new Random().nextInt(5)+10); final Optional result = objectUnderTest.getAvailablePartition( ownerId, ownershipTimeout, SourcePartitionStatus.valueOf(sourcePartitionStatus), sourceStatusCombinationKey, pageLimit, ttl); @@ -516,7 +516,7 @@ void getAvailablePartition_will_continue_until_tryAcquirePartition_succeeds(fina final DynamoDbClientWrapper objectUnderTest = createObjectUnderTest(); reflectivelySetField(objectUnderTest, "table", table); - final Duration ttl = Duration.ofSeconds(new Random().nextInt()); + final Duration ttl = Duration.ofSeconds(new Random().nextInt(5)+10); final Optional result = objectUnderTest.getAvailablePartition( ownerId, ownershipTimeout, SourcePartitionStatus.valueOf(sourcePartitionStatus), sourceStatusCombinationKey, new Random().nextInt(20), ttl); @@ -583,7 +583,7 @@ void getAvailablePartition_with_multiple_pages_continue_until_tryAcquirePartitio final DynamoDbClientWrapper objectUnderTest = createObjectUnderTest(); reflectivelySetField(objectUnderTest, "table", table); - final Duration ttl = Duration.ofSeconds(new Random().nextInt()); + final Duration ttl = Duration.ofSeconds(new Random().nextInt(5)+10); final Optional result = objectUnderTest.getAvailablePartition( ownerId, ownershipTimeout, SourcePartitionStatus.valueOf(sourcePartitionStatus), sourceStatusCombinationKey, new Random().nextInt(20), ttl); @@ -650,7 +650,7 @@ void getAvailablePartition_with_multiple_pages_will_iterate_through_all_items_wi final DynamoDbClientWrapper objectUnderTest = createObjectUnderTest(); reflectivelySetField(objectUnderTest, "table", table); - final Duration ttl = Duration.ofSeconds(new Random().nextInt()); + final Duration ttl = Duration.ofSeconds(new Random().nextInt(5)+10); final Optional result = objectUnderTest.getAvailablePartition( ownerId, ownershipTimeout, SourcePartitionStatus.valueOf(sourcePartitionStatus), sourceStatusCombinationKey, new Random().nextInt(20), ttl); diff --git a/data-prepper-plugins/dynamodb-source-coordination-store/src/test/java/org/opensearch/dataprepper/plugins/sourcecoordinator/dynamodb/DynamoDbSourceCoordinationStoreTest.java b/data-prepper-plugins/dynamodb-source-coordination-store/src/test/java/org/opensearch/dataprepper/plugins/sourcecoordinator/dynamodb/DynamoDbSourceCoordinationStoreTest.java index 77ffb49c6b..2150fa55c8 100644 --- a/data-prepper-plugins/dynamodb-source-coordination-store/src/test/java/org/opensearch/dataprepper/plugins/sourcecoordinator/dynamodb/DynamoDbSourceCoordinationStoreTest.java +++ b/data-prepper-plugins/dynamodb-source-coordination-store/src/test/java/org/opensearch/dataprepper/plugins/sourcecoordinator/dynamodb/DynamoDbSourceCoordinationStoreTest.java @@ -245,8 +245,9 @@ void getAvailablePartition_with_no_item_acquired_returns_empty_optional() { final String ownerId = UUID.randomUUID().toString(); final String sourceIdentifier = UUID.randomUUID().toString(); final Duration ownershipTimeout = Duration.ofMinutes(2); - final Duration ttl = Duration.ofSeconds(new Random().nextInt()); + final Duration ttl = Duration.ofSeconds(new Random().nextInt(5)+10); + given(dynamoStoreSettings.getTtl()).willReturn(ttl); given(dynamoDbClientWrapper.getAvailablePartition(ownerId, ownershipTimeout, SourcePartitionStatus.ASSIGNED, String.format(SOURCE_STATUS_COMBINATION_KEY_FORMAT, sourceIdentifier, SourcePartitionStatus.ASSIGNED), @@ -273,8 +274,8 @@ void getAvailablePartition_with_acquired_ASSIGNED_partition_returns_the_partitio final String ownerId = UUID.randomUUID().toString(); final String sourceIdentifier = UUID.randomUUID().toString(); final Duration ownershipTimeout = Duration.ofMinutes(2); - final Duration ttl = Duration.ofSeconds(new Random().nextInt()); - + final Duration ttl = Duration.ofSeconds(new Random().nextInt(5)+10); + given(dynamoStoreSettings.getTtl()).willReturn(ttl); final DynamoDbSourcePartitionItem acquiredItem = mock(DynamoDbSourcePartitionItem.class); given(dynamoDbClientWrapper.getAvailablePartition(ownerId, ownershipTimeout, @@ -296,8 +297,9 @@ void getAvailablePartition_with_acquired_CLOSED_partition_returns_the_partition( final String ownerId = UUID.randomUUID().toString(); final String sourceIdentifier = UUID.randomUUID().toString(); final Duration ownershipTimeout = Duration.ofMinutes(2); - final Duration ttl = Duration.ofSeconds(new Random().nextInt()); + final Duration ttl = Duration.ofSeconds(new Random().nextInt(5)+10); + given(dynamoStoreSettings.getTtl()).willReturn(ttl); final DynamoDbSourcePartitionItem acquiredItem = mock(DynamoDbSourcePartitionItem.class); given(dynamoDbClientWrapper.getAvailablePartition(ownerId, ownershipTimeout, @@ -329,8 +331,9 @@ void getAvailablePartition_with_acquired_UNASSIGNED_partition_returns_the_partit final String ownerId = UUID.randomUUID().toString(); final String sourceIdentifier = UUID.randomUUID().toString(); final Duration ownershipTimeout = Duration.ofMinutes(2); - final Duration ttl = Duration.ofSeconds(new Random().nextInt()); + final Duration ttl = Duration.ofSeconds(new Random().nextInt(5)+10); + given(dynamoStoreSettings.getTtl()).willReturn(ttl); final DynamoDbSourcePartitionItem acquiredItem = mock(DynamoDbSourcePartitionItem.class); given(dynamoDbClientWrapper.getAvailablePartition(ownerId, ownershipTimeout,