forked from opensearch-project/opensearch-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added backoff to RFS Metadata work leases (opensearch-project#650)
Signed-off-by: Chris Helma <chelma+github@amazon.com>
- Loading branch information
Showing
5 changed files
with
79 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.rfs.cms; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
public class CmsEntryTest { | ||
|
||
static Stream<Arguments> provide_Metadata_getLeaseExpiry_HappyPath_args() { | ||
// Generate an argument for each possible number of attempts | ||
Stream<Arguments> argStream = Stream.of(); | ||
for (int i = 1; i <= CmsEntry.Metadata.MAX_ATTEMPTS; i++) { | ||
argStream = Stream.concat(argStream, Stream.of(Arguments.of(i))); | ||
} | ||
return argStream; | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provide_Metadata_getLeaseExpiry_HappyPath_args") | ||
void Metadata_getLeaseExpiry_HappyPath(int numAttempts) { | ||
// Run the test | ||
String result = CmsEntry.Metadata.getLeaseExpiry(0, numAttempts); | ||
|
||
// Check the results | ||
assertEquals(Long.toString(CmsEntry.Metadata.METADATA_LEASE_MS * numAttempts), result); | ||
} | ||
|
||
static Stream<Arguments> provide_Metadata_getLeaseExpiry_UnhappyPath_args() { | ||
return Stream.of( | ||
Arguments.of(0), | ||
Arguments.of(CmsEntry.Metadata.MAX_ATTEMPTS + 1) | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provide_Metadata_getLeaseExpiry_UnhappyPath_args") | ||
void Metadata_getLeaseExpiry_UnhappyPath(int numAttempts) { | ||
// Run the test | ||
assertThrows(CmsEntry.CouldNotFindNextLeaseDuration.class, () -> { | ||
CmsEntry.Metadata.getLeaseExpiry(0, numAttempts); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters