Fix flaky HashRangesAreAlwaysComplete test
Updates depth value for Merge and Reshard with some In-Progress Parents tests to prevent invalid hierarchy trees.
This commit is contained in:
parent
c23d83dc9a
commit
28a21d776b
1 changed files with 5 additions and 18 deletions
|
|
@ -58,6 +58,8 @@ import static software.amazon.kinesis.leases.LeaseManagementConfig.DEFAULT_CONSE
|
|||
|
||||
public class PeriodicShardSyncManagerTest {
|
||||
|
||||
private static final int MAX_DEPTH_WITH_IN_PROGRESS_PARENTS = 1;
|
||||
|
||||
private StreamIdentifier streamIdentifier;
|
||||
private PeriodicShardSyncManager periodicShardSyncManager;
|
||||
@Mock
|
||||
|
|
@ -446,7 +448,7 @@ public class PeriodicShardSyncManagerTest {
|
|||
for (int i = 0; i < 1000; i++) {
|
||||
int maxInitialLeaseCount = 100;
|
||||
List<Lease> leases = generateInitialLeases(maxInitialLeaseCount);
|
||||
reshard(leases, 5, ReshardType.MERGE, maxInitialLeaseCount, true);
|
||||
reshard(leases, MAX_DEPTH_WITH_IN_PROGRESS_PARENTS, ReshardType.MERGE, maxInitialLeaseCount, true);
|
||||
Collections.shuffle(leases);
|
||||
Assert.assertFalse(periodicShardSyncManager.hasHoleInLeases(streamIdentifier, leases).isPresent());
|
||||
}
|
||||
|
|
@ -457,17 +459,9 @@ public class PeriodicShardSyncManagerTest {
|
|||
for (int i = 0; i < 1000; i++) {
|
||||
int maxInitialLeaseCount = 100;
|
||||
List<Lease> leases = generateInitialLeases(maxInitialLeaseCount);
|
||||
reshard(leases, 5, ReshardType.ANY, maxInitialLeaseCount, true);
|
||||
reshard(leases, MAX_DEPTH_WITH_IN_PROGRESS_PARENTS, ReshardType.ANY, maxInitialLeaseCount, true);
|
||||
Collections.shuffle(leases);
|
||||
boolean isHoleInHashRanges = periodicShardSyncManager.hasHoleInLeases(streamIdentifier, leases).isPresent();
|
||||
if (isHoleInHashRanges) {
|
||||
// In-progress parents may result in a lease having the highest startingHashKey value while not having
|
||||
// an endingHashKey value of MAX_HASH_KEY. This is detected as a "hole" in the hash key range,
|
||||
// so mark the in-progress parents as finished (SHARD_END) and recheck for holes.
|
||||
finishInProgressParents(leases);
|
||||
isHoleInHashRanges = periodicShardSyncManager.hasHoleInLeases(streamIdentifier, leases).isPresent();
|
||||
}
|
||||
Assert.assertFalse(isHoleInHashRanges);
|
||||
Assert.assertFalse(periodicShardSyncManager.hasHoleInLeases(streamIdentifier, leases).isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -577,13 +571,6 @@ public class PeriodicShardSyncManagerTest {
|
|||
return leaseCounter;
|
||||
}
|
||||
|
||||
private void finishInProgressParents(List<Lease> leases) {
|
||||
leases.stream()
|
||||
.filter(l -> l.checkpoint() != null && !l.checkpoint().equals(ExtendedSequenceNumber.SHARD_END) &&
|
||||
l.childShardIds() != null && !l.childShardIds().isEmpty())
|
||||
.forEach(l -> l.checkpoint(ExtendedSequenceNumber.SHARD_END));
|
||||
}
|
||||
|
||||
private boolean isHeads() {
|
||||
return Math.random() <= 0.5;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue