Fix missing active IDs prevent advance test
This commit addresses an issue in the missing active IDs prevent advance test from the global checkpoint tracker. The assumptions this test was making about reality were violated when global checkpoints were inlined (specifically, the component of that change where the tracker's knowledge of the global checkpoint was updated inline with updates to the tracker's knowledge of local checkpoints for an allocatio ID). The point of the test was to ensure that a lagging shard prevents the global checkpoint from advancing, so this commit rewrites the test with that in mind.
This commit is contained in:
parent
9953a96143
commit
d9cac191a2
|
@ -145,17 +145,20 @@ public class GlobalCheckpointTrackerTests extends ESTestCase {
|
||||||
final Map<String, Long> assigned = new HashMap<>();
|
final Map<String, Long> assigned = new HashMap<>();
|
||||||
assigned.putAll(active);
|
assigned.putAll(active);
|
||||||
assigned.putAll(initializing);
|
assigned.putAll(initializing);
|
||||||
final String maxActiveID = active.entrySet().stream().max(Comparator.comparing(Map.Entry::getValue)).get().getKey();
|
|
||||||
tracker.updateAllocationIdsFromMaster(
|
tracker.updateAllocationIdsFromMaster(
|
||||||
active.entrySet().stream().filter(e -> !e.getKey().equals(maxActiveID)).map(Map.Entry::getKey).collect(Collectors.toSet()),
|
active.keySet(),
|
||||||
initializing.keySet());
|
initializing.keySet());
|
||||||
randomSubsetOf(initializing.keySet()).forEach(k -> markAllocationIdAsInSyncQuietly(tracker, k, tracker.getGlobalCheckpoint()));
|
randomSubsetOf(initializing.keySet()).forEach(k -> markAllocationIdAsInSyncQuietly(tracker, k, tracker.getGlobalCheckpoint()));
|
||||||
assigned.forEach(tracker::updateLocalCheckpoint);
|
final String missingActiveID = randomFrom(active.keySet());
|
||||||
|
assigned
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.filter(e -> !e.getKey().equals(missingActiveID))
|
||||||
|
.forEach(e -> tracker.updateLocalCheckpoint(e.getKey(), e.getValue()));
|
||||||
|
|
||||||
// now mark all active shards
|
assertThat(tracker.getGlobalCheckpoint(), equalTo(UNASSIGNED_SEQ_NO));
|
||||||
tracker.updateAllocationIdsFromMaster(active.keySet(), initializing.keySet());
|
|
||||||
|
|
||||||
// update again
|
// now update all knowledge of all shards
|
||||||
assigned.forEach(tracker::updateLocalCheckpoint);
|
assigned.forEach(tracker::updateLocalCheckpoint);
|
||||||
assertThat(tracker.getGlobalCheckpoint(), not(equalTo(UNASSIGNED_SEQ_NO)));
|
assertThat(tracker.getGlobalCheckpoint(), not(equalTo(UNASSIGNED_SEQ_NO)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue