瀏覽代碼

TEST: Skip assertSeqNos for closed shards (#33130)

If a shard was closed, we return null for SeqNoStats. Therefore the
assertion assertSeqNos will hit NPE when it verifies a closed shard.

This commit skips closed shards in assertSeqNos and enables this
assertion in AbstractDisruptionTestCase.
Nhat Nguyen 7 年之前
父節點
當前提交
9dad82ece8

+ 1 - 0
server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java

@@ -109,6 +109,7 @@ public abstract class AbstractDisruptionTestCase extends ESIntegTestCase {
     protected void beforeIndexDeletion() throws Exception {
         if (disableBeforeIndexDeletion == false) {
             super.beforeIndexDeletion();
+            assertSeqNos();
         }
     }
 

+ 3 - 0
test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

@@ -2349,6 +2349,9 @@ public abstract class ESIntegTestCase extends ESTestCase {
                     final ObjectLongMap<String> globalCheckpoints = indexShard.getInSyncGlobalCheckpoints();
                     for (ShardStats shardStats : indexShardStats) {
                         final SeqNoStats seqNoStats = shardStats.getSeqNoStats();
+                        if (seqNoStats == null) {
+                            continue; // this shard was closed
+                        }
                         assertThat(shardStats.getShardRouting() + " local checkpoint mismatch",
                                 seqNoStats.getLocalCheckpoint(), equalTo(primarySeqNoStats.getLocalCheckpoint()));
                         assertThat(shardStats.getShardRouting() + " global checkpoint mismatch",