Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into forcemerge
Browse files Browse the repository at this point in the history
  • Loading branch information
gaobinlong committed Dec 3, 2023
2 parents 2e990e3 + 69cc2a1 commit 9fef912
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions server/src/test/java/org/opensearch/index/IndexServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,7 @@ public void testAsyncTranslogTrimTaskOnClosedIndex() throws Exception {
assertTrue(indexService.getTrimTranslogTask().mustReschedule());

final Engine readOnlyEngine = getEngine(indexService.getShard(0));
assertBusy(
() -> assertThat(
readOnlyEngine.translogManager().getTranslogStats().getTranslogSizeInBytes(),
equalTo((long) Translog.DEFAULT_HEADER_SIZE_IN_BYTES)
)
);
assertBusy(() -> assertTrue(isTranslogEmpty(readOnlyEngine)));

assertAcked(client().admin().indices().prepareOpen("test").setWaitForActiveShards(ActiveShardCount.DEFAULT));

Expand All @@ -467,6 +462,12 @@ public void testAsyncTranslogTrimTaskOnClosedIndex() throws Exception {
assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(0));
}

boolean isTranslogEmpty(Engine engine) {
long tlogSize = engine.translogManager().getTranslogStats().getTranslogSizeInBytes();
// translog contains 1(or 2 in some corner cases) empty readers.
return tlogSize == Translog.DEFAULT_HEADER_SIZE_IN_BYTES || tlogSize == 2 * Translog.DEFAULT_HEADER_SIZE_IN_BYTES;
}

public void testIllegalFsyncInterval() {
Settings settings = Settings.builder()
.put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), "0ms") // disable
Expand Down

0 comments on commit 9fef912

Please sign in to comment.