Skip to content

Commit 5e09825

Browse files
committedMar 24, 2025
add IT test
Signed-off-by: guojialiang <guojialiang.2012@bytedance.com>
1 parent 9b5a236 commit 5e09825

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed
 

‎server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void testPublishCheckPointFail() throws Exception {
143143
.build();
144144

145145
final String primaryNode = internalCluster().startDataOnlyNode(mockNodeSetting);
146-
createIndex(INDEX_NAME);
146+
createIndex(INDEX_NAME, Settings.builder().put(indexSettings()).put("index.refresh_interval", -1).build());
147147
ensureYellowAndNoInitializingShards(INDEX_NAME);
148148
final String replicaNode = internalCluster().startDataOnlyNode(mockNodeSetting);
149149
ensureGreen(INDEX_NAME);
@@ -217,20 +217,20 @@ public void testPrimaryStopped_ReplicaPromoted() throws Exception {
217217
logger.info("ensure publish checkpoint request can be process");
218218
mockReplicaReceivePublishCheckpointException.set(false);
219219

220-
waitForSearchableDocs(1, primary, replica);
221-
replicaTransportService.clearAllRules();
222-
223220
assertAcked(
224221
client().admin()
225222
.indices()
226223
.prepareUpdateSettings(INDEX_NAME)
227224
.setSettings(
228225
Settings.builder()
229-
.put(IndexSettings.INDEX_PUBLISH_CHECKPOINT_INTERVAL_SETTING.getKey(), TimeValue.timeValueSeconds(3))
230-
.put(IndexSettings.INDEX_LAG_TIME_BEFORE_RESEND_CHECKPOINT_SETTING.getKey(), TimeValue.timeValueSeconds(3))
226+
.put(IndexSettings.INDEX_PUBLISH_CHECKPOINT_INTERVAL_SETTING.getKey(), TimeValue.timeValueSeconds(1))
227+
.put(IndexSettings.INDEX_LAG_TIME_BEFORE_RESEND_CHECKPOINT_SETTING.getKey(), TimeValue.timeValueSeconds(1))
231228
)
232229
);
233230

231+
waitForSearchableDocs(1, primary, replica);
232+
replicaTransportService.clearAllRules();
233+
234234
// index another doc but don't refresh, we will ensure this is searchable once replica is promoted.
235235
client().prepareIndex(INDEX_NAME).setId("2").setSource("bar", "baz").setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
236236

‎server/src/main/java/org/opensearch/index/IndexSettings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ public static IndexMergePolicy fromString(String text) {
784784

785785
public static final Setting<TimeValue> INDEX_PUBLISH_CHECKPOINT_INTERVAL_SETTING = Setting.timeSetting(
786786
"index.publish_checkpoint_interval",
787-
TimeValue.timeValueSeconds(1),
787+
TimeValue.timeValueMinutes(10),
788788
TimeValue.timeValueSeconds(1),
789789
Property.Dynamic,
790790
Property.IndexScope

‎server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.opensearch.common.collect.Tuple;
4646
import org.opensearch.common.io.stream.BytesStreamOutput;
4747
import org.opensearch.common.settings.Settings;
48+
import org.opensearch.common.unit.TimeValue;
4849
import org.opensearch.common.util.set.Sets;
4950
import org.opensearch.core.action.ActionListener;
5051
import org.opensearch.core.common.io.stream.StreamInput;
@@ -1813,7 +1814,10 @@ public void testUpdateAllocationIdsFromClusterManagerWithRemoteTranslogEnabled()
18131814
}
18141815

18151816
public void testSegmentReplicationCheckpointTracking() {
1816-
Settings settings = Settings.builder().put(SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT).build();
1817+
Settings settings = Settings.builder()
1818+
.put(SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT)
1819+
.put(IndexSettings.INDEX_LAG_TIME_BEFORE_RESEND_CHECKPOINT_SETTING.getKey(), TimeValue.timeValueSeconds(0))
1820+
.build();
18171821
final long initialClusterStateVersion = randomNonNegativeLong();
18181822
final int numberOfActiveAllocationsIds = randomIntBetween(2, 16);
18191823
final int numberOfInitializingIds = randomIntBetween(2, 16);
@@ -1885,6 +1889,8 @@ public void testSegmentReplicationCheckpointTracking() {
18851889
assertTrue(shardStat.getCurrentReplicationLagMillis() >= shardStat.getCurrentReplicationTimeMillis());
18861890
}
18871891

1892+
assertTrue(tracker.hasLaggingReplicas());
1893+
18881894
// simulate replicas moved up to date.
18891895
final Map<String, ReplicationTracker.CheckpointState> checkpoints = tracker.checkpoints;
18901896
for (String id : expectedIds) {

0 commit comments

Comments
 (0)