Fix get operations between test
This test was broken by an upstream change that no longer guarantees we see the operations from the upstream translog in the order they appear in that translog. As such, the assertions in this test were too strong so this commit relaxes them. Relates #3153
This commit is contained in:
parent
abd263fca9
commit
11aa83011c
|
@ -20,6 +20,9 @@ import org.elasticsearch.test.ESSingleNodeTestCase;
|
|||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.LongStream;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -46,12 +49,14 @@ public class ShardChangesActionTests extends ESSingleNodeTestCase {
|
|||
int min = randomIntBetween(0, numWrites - 1);
|
||||
int max = randomIntBetween(min, numWrites - 1);
|
||||
|
||||
int index = 0;
|
||||
List<Translog.Operation> operations = ShardChangesAction.getOperationsBetween(indexShard, min, max);
|
||||
for (long expectedSeqNo = min; expectedSeqNo < max; expectedSeqNo++) {
|
||||
Translog.Operation operation = operations.get(index++);
|
||||
assertThat(operation.seqNo(), equalTo(expectedSeqNo));
|
||||
}
|
||||
final List<Translog.Operation> operations = ShardChangesAction.getOperationsBetween(indexShard, min, max);
|
||||
/*
|
||||
* We are not guaranteed that operations are returned to us in order they are in the translog (if our read crosses multiple
|
||||
* generations) so the best we can assert is that we see the expected operations.
|
||||
*/
|
||||
final Set<Long> seenSeqNos = operations.stream().map(Translog.Operation::seqNo).collect(Collectors.toSet());
|
||||
final Set<Long> expectedSeqNos = LongStream.range(min, max + 1).boxed().collect(Collectors.toSet());
|
||||
assertThat(seenSeqNos, equalTo(expectedSeqNos));
|
||||
}
|
||||
|
||||
// get operations for a range no operations exists:
|
||||
|
|
Loading…
Reference in New Issue