Skip to content

Commit

Permalink
Commenting flaky test testAsyncTranslogTrimTaskOnClosedIndex.
Browse files Browse the repository at this point in the history
Signed-off-by: Swetha Guptha <[email protected]>
  • Loading branch information
Swetha Guptha committed Oct 21, 2024
1 parent 0d57bc0 commit e45b865
Showing 1 changed file with 44 additions and 44 deletions.
88 changes: 44 additions & 44 deletions server/src/test/java/org/opensearch/index/IndexServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TopDocs;
import org.opensearch.Version;
import org.opensearch.action.support.ActiveShardCount;
//import org.opensearch.action.support.ActiveShardCount;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.compress.CompressedXContent;
import org.opensearch.common.settings.Settings;
Expand Down Expand Up @@ -66,7 +66,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

import static org.opensearch.index.shard.IndexShardTestCase.getEngine;
//import static org.opensearch.index.shard.IndexShardTestCase.getEngine;
import static org.opensearch.test.InternalSettingsPlugin.TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.hamcrest.core.IsEqual.equalTo;
Expand Down Expand Up @@ -421,48 +421,48 @@ public void testAsyncTranslogTrimActuallyWorks() throws Exception {
assertBusy(() -> assertThat(IndexShardTestCase.getTranslog(shard).totalOperations(), equalTo(0)));
}

public void testAsyncTranslogTrimTaskOnClosedIndex() throws Exception {
final String indexName = "test";
IndexService indexService = createIndex(
indexName,
Settings.builder().put(TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING.getKey(), "200ms").build()
);

Translog translog = IndexShardTestCase.getTranslog(indexService.getShard(0));

int translogOps = 0;
final int numDocs = scaledRandomIntBetween(10, 100);
for (int i = 0; i < numDocs; i++) {
client().prepareIndex()
.setIndex(indexName)
.setId(String.valueOf(i))
.setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)
.get();
translogOps++;
if (randomBoolean()) {
client().admin().indices().prepareFlush(indexName).get();
if (indexService.getIndexSettings().isSoftDeleteEnabled()) {
translogOps = 0;
}
}
}
assertThat(translog.totalOperations(), equalTo(translogOps));
assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(translogOps));
assertAcked(client().admin().indices().prepareClose("test").setWaitForActiveShards(ActiveShardCount.DEFAULT));

indexService = getInstanceFromNode(IndicesService.class).indexServiceSafe(indexService.index());
assertTrue(indexService.getTrimTranslogTask().mustReschedule());

final Engine readOnlyEngine = getEngine(indexService.getShard(0));
assertBusy(() -> assertTrue(isTranslogEmpty(readOnlyEngine)));

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

indexService = getInstanceFromNode(IndicesService.class).indexServiceSafe(indexService.index());
translog = IndexShardTestCase.getTranslog(indexService.getShard(0));
assertThat(translog.totalOperations(), equalTo(0));
assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(0));
}
// public void testAsyncTranslogTrimTaskOnClosedIndex() throws Exception {
// final String indexName = "test";
// IndexService indexService = createIndex(
// indexName,
// Settings.builder().put(TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING.getKey(), "200ms").build()
// );
//
// Translog translog = IndexShardTestCase.getTranslog(indexService.getShard(0));
//
// int translogOps = 0;
// final int numDocs = scaledRandomIntBetween(10, 100);
// for (int i = 0; i < numDocs; i++) {
// client().prepareIndex()
// .setIndex(indexName)
// .setId(String.valueOf(i))
// .setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)
// .get();
// translogOps++;
// if (randomBoolean()) {
// client().admin().indices().prepareFlush(indexName).get();
// if (indexService.getIndexSettings().isSoftDeleteEnabled()) {
// translogOps = 0;
// }
// }
// }
// assertThat(translog.totalOperations(), equalTo(translogOps));
// assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(translogOps));
// assertAcked(client().admin().indices().prepareClose("test").setWaitForActiveShards(ActiveShardCount.DEFAULT));
//
// indexService = getInstanceFromNode(IndicesService.class).indexServiceSafe(indexService.index());
// assertTrue(indexService.getTrimTranslogTask().mustReschedule());
//
// final Engine readOnlyEngine = getEngine(indexService.getShard(0));
// assertBusy(() -> assertTrue(isTranslogEmpty(readOnlyEngine)));
//
// assertAcked(client().admin().indices().prepareOpen("test").setWaitForActiveShards(ActiveShardCount.DEFAULT));
//
// indexService = getInstanceFromNode(IndicesService.class).indexServiceSafe(indexService.index());
// translog = IndexShardTestCase.getTranslog(indexService.getShard(0));
// assertThat(translog.totalOperations(), equalTo(0));
// assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(0));
// }

boolean isTranslogEmpty(Engine engine) {
long tlogSize = engine.translogManager().getTranslogStats().getTranslogSizeInBytes();
Expand Down

0 comments on commit e45b865

Please sign in to comment.