|
43 | 43 | import java.util.Map.Entry;
|
44 | 44 | import java.util.Set;
|
45 | 45 |
|
46 |
| -import static org.hamcrest.Matchers.containsString; |
47 |
| - |
48 | 46 | public class TransformsCheckpointServiceTests extends ESTestCase {
|
49 | 47 |
|
50 | 48 | public void testExtractIndexCheckpoints() {
|
@@ -104,11 +102,15 @@ public void testExtractIndexCheckpointsInconsistentGlobalCheckpoints() {
|
104 | 102 |
|
105 | 103 | ShardStats[] shardStatsArray = createRandomShardStats(expectedCheckpoints, indices, randomBoolean(), true, false);
|
106 | 104 |
|
107 |
| - // fail |
108 |
| - CheckpointException e = expectThrows(CheckpointException.class, |
109 |
| - () -> DefaultCheckpointProvider.extractIndexCheckPoints(shardStatsArray, indices)); |
| 105 | + Map<String, long[]> checkpoints = DefaultCheckpointProvider.extractIndexCheckPoints(shardStatsArray, indices); |
| 106 | + |
| 107 | + assertEquals(expectedCheckpoints.size(), checkpoints.size()); |
| 108 | + assertEquals(expectedCheckpoints.keySet(), checkpoints.keySet()); |
110 | 109 |
|
111 |
| - assertThat(e.getMessage(), containsString("Global checkpoints mismatch")); |
| 110 | + // global checkpoints should be max() of all global checkpoints |
| 111 | + for (Entry<String, long[]> entry : expectedCheckpoints.entrySet()) { |
| 112 | + assertArrayEquals(entry.getValue(), checkpoints.get(entry.getKey())); |
| 113 | + } |
112 | 114 | }
|
113 | 115 |
|
114 | 116 | /**
|
@@ -176,8 +178,8 @@ private static ShardStats[] createRandomShardStats(Map<String, long[]> expectedC
|
176 | 178 | }
|
177 | 179 |
|
178 | 180 | // SeqNoStats asserts that checkpoints are logical
|
179 |
| - long localCheckpoint = randomLongBetween(0L, 100000000L); |
180 |
| - long globalCheckpoint = randomBoolean() ? localCheckpoint : randomLongBetween(0L, 100000000L); |
| 181 | + long localCheckpoint = randomLongBetween(100L, 100000000L); |
| 182 | + long globalCheckpoint = randomBoolean() ? localCheckpoint : randomLongBetween(100L, 100000000L); |
181 | 183 | long maxSeqNo = Math.max(localCheckpoint, globalCheckpoint);
|
182 | 184 |
|
183 | 185 | SeqNoStats validSeqNoStats = null;
|
@@ -221,7 +223,7 @@ private static ShardStats[] createRandomShardStats(Map<String, long[]> expectedC
|
221 | 223 | if (inconsistentReplica == replica) {
|
222 | 224 | // overwrite
|
223 | 225 | SeqNoStats invalidSeqNoStats =
|
224 |
| - new SeqNoStats(maxSeqNo, localCheckpoint, globalCheckpoint + randomLongBetween(10L, 100L)); |
| 226 | + new SeqNoStats(maxSeqNo, localCheckpoint, globalCheckpoint - randomLongBetween(10L, 100L)); |
225 | 227 | shardStats.add(
|
226 | 228 | new ShardStats(shardRouting,
|
227 | 229 | new ShardPath(false, path, path, shardId), stats, null, invalidSeqNoStats, null));
|
|
0 commit comments