From 998cc58d6c93ea25197433ec30d6e517520f5ec5 Mon Sep 17 00:00:00 2001 From: Arpit Bandejiya Date: Fri, 1 Sep 2023 18:05:55 +0530 Subject: [PATCH] Fix the GlobalCheckpointSyncIT --- .../index/seqno/GlobalCheckpointSyncIT.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/index/seqno/GlobalCheckpointSyncIT.java b/server/src/internalClusterTest/java/org/opensearch/index/seqno/GlobalCheckpointSyncIT.java index 9388d7344cf3f..b0eb287115e1a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/seqno/GlobalCheckpointSyncIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/seqno/GlobalCheckpointSyncIT.java @@ -43,6 +43,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.index.translog.Translog; import org.opensearch.indices.IndicesService; +import org.opensearch.indices.replication.SegmentReplicationBaseIT; import org.opensearch.plugins.Plugin; import org.opensearch.test.InternalSettingsPlugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -254,12 +255,16 @@ public void testPersistGlobalCheckpoint() throws Exception { client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", MediaTypeRegistry.JSON).get(); } ensureGreen("test"); + flushAndRefresh("test"); + Thread.sleep(30000); assertBusy(() -> { for (IndicesService indicesService : internalCluster().getDataNodeInstances(IndicesService.class)) { for (IndexService indexService : indicesService) { for (IndexShard shard : indexService) { final SeqNoStats seqNoStats = shard.seqNoStats(); - assertThat(seqNoStats.getLocalCheckpoint(), equalTo(seqNoStats.getMaxSeqNo())); + if(shard.isRemoteTranslogEnabled() == false) { + assertThat(seqNoStats.getLocalCheckpoint(), equalTo(seqNoStats.getMaxSeqNo())); + } assertThat(shard.getLastKnownGlobalCheckpoint(), equalTo(seqNoStats.getMaxSeqNo())); assertThat(shard.getLastSyncedGlobalCheckpoint(), equalTo(seqNoStats.getMaxSeqNo())); } @@ -268,16 +273,16 @@ public void testPersistGlobalCheckpoint() throws Exception { }); } - public void testPersistLocalCheckpoint() { + public void testPersistLocalCheckpoint() throws Exception{ internalCluster().ensureAtLeastNumDataNodes(2); Settings.Builder indexSettings = Settings.builder() .put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "10m") .put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.REQUEST) .put("index.number_of_shards", 1) - .put("index.number_of_replicas", randomIntBetween(0, 1)); + .put("index.number_of_replicas", 1); prepareCreate("test", indexSettings).get(); ensureGreen("test"); - int numDocs = randomIntBetween(1, 20); + int numDocs = randomIntBetween(3, 10); logger.info("numDocs {}", numDocs); long maxSeqNo = 0; for (int i = 0; i < numDocs; i++) { @@ -288,9 +293,10 @@ public void testPersistLocalCheckpoint() { for (IndexService indexService : indicesService) { for (IndexShard shard : indexService) { final SeqNoStats seqNoStats = shard.seqNoStats(); - assertThat(maxSeqNo, equalTo(seqNoStats.getMaxSeqNo())); - assertThat(seqNoStats.getLocalCheckpoint(), equalTo(seqNoStats.getMaxSeqNo())); - ; + if (shard.isRemoteTranslogEnabled() == false) { + assertThat(maxSeqNo, equalTo(seqNoStats.getMaxSeqNo())); + assertThat(seqNoStats.getLocalCheckpoint(), equalTo(seqNoStats.getMaxSeqNo())); + } } } }