Fix flaky HashRangesAreAlwaysComplete test
Adds mechanism to allow in-progress parents to finish (marked as SHARD_END) if testFor1000DifferentValidReshardHierarchyTreeWithSomeInProgressParentsTheHashRangesAreAlwaysComplete detects hole due to merged parent shards still holding an active lease.
This commit is contained in:
parent
04a121a811
commit
d3a4fd5569
1 changed files with 13 additions and 1 deletions
|
|
@ -459,7 +459,12 @@ public class PeriodicShardSyncManagerTest {
|
|||
List<Lease> leases = generateInitialLeases(maxInitialLeaseCount);
|
||||
reshard(leases, 5, ReshardType.ANY, maxInitialLeaseCount, true);
|
||||
Collections.shuffle(leases);
|
||||
Assert.assertFalse(periodicShardSyncManager.hasHoleInLeases(streamIdentifier, leases).isPresent());
|
||||
boolean isHoleInHashRanges = periodicShardSyncManager.hasHoleInLeases(streamIdentifier, leases).isPresent();
|
||||
if (isHoleInHashRanges) {
|
||||
finishInProgressParents(leases);
|
||||
isHoleInHashRanges = periodicShardSyncManager.hasHoleInLeases(streamIdentifier, leases).isPresent();
|
||||
}
|
||||
Assert.assertFalse(isHoleInHashRanges);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -569,6 +574,13 @@ 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