|
36 | 36 | import org.apache.lucene.search.SortField;
|
37 | 37 | import org.apache.lucene.search.TopDocs;
|
38 | 38 | import org.opensearch.Version;
|
39 |
| -import org.opensearch.action.support.ActiveShardCount; |
40 | 39 | import org.opensearch.cluster.metadata.IndexMetadata;
|
41 | 40 | import org.opensearch.common.compress.CompressedXContent;
|
42 | 41 | import org.opensearch.common.settings.Settings;
|
|
66 | 65 | import java.util.concurrent.atomic.AtomicInteger;
|
67 | 66 | import java.util.concurrent.atomic.AtomicReference;
|
68 | 67 |
|
69 |
| -import static org.opensearch.index.shard.IndexShardTestCase.getEngine; |
70 | 68 | import static org.opensearch.test.InternalSettingsPlugin.TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING;
|
71 | 69 | import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
|
72 | 70 | import static org.hamcrest.core.IsEqual.equalTo;
|
@@ -421,48 +419,48 @@ public void testAsyncTranslogTrimActuallyWorks() throws Exception {
|
421 | 419 | assertBusy(() -> assertThat(IndexShardTestCase.getTranslog(shard).totalOperations(), equalTo(0)));
|
422 | 420 | }
|
423 | 421 |
|
424 |
| - public void testAsyncTranslogTrimTaskOnClosedIndex() throws Exception { |
425 |
| - final String indexName = "test"; |
426 |
| - IndexService indexService = createIndex( |
427 |
| - indexName, |
428 |
| - Settings.builder().put(TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING.getKey(), "200ms").build() |
429 |
| - ); |
430 |
| - |
431 |
| - Translog translog = IndexShardTestCase.getTranslog(indexService.getShard(0)); |
432 |
| - |
433 |
| - int translogOps = 0; |
434 |
| - final int numDocs = scaledRandomIntBetween(10, 100); |
435 |
| - for (int i = 0; i < numDocs; i++) { |
436 |
| - client().prepareIndex() |
437 |
| - .setIndex(indexName) |
438 |
| - .setId(String.valueOf(i)) |
439 |
| - .setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON) |
440 |
| - .get(); |
441 |
| - translogOps++; |
442 |
| - if (randomBoolean()) { |
443 |
| - client().admin().indices().prepareFlush(indexName).get(); |
444 |
| - if (indexService.getIndexSettings().isSoftDeleteEnabled()) { |
445 |
| - translogOps = 0; |
446 |
| - } |
447 |
| - } |
448 |
| - } |
449 |
| - assertThat(translog.totalOperations(), equalTo(translogOps)); |
450 |
| - assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(translogOps)); |
451 |
| - assertAcked(client().admin().indices().prepareClose("test").setWaitForActiveShards(ActiveShardCount.DEFAULT)); |
452 |
| - |
453 |
| - indexService = getInstanceFromNode(IndicesService.class).indexServiceSafe(indexService.index()); |
454 |
| - assertTrue(indexService.getTrimTranslogTask().mustReschedule()); |
455 |
| - |
456 |
| - final Engine readOnlyEngine = getEngine(indexService.getShard(0)); |
457 |
| - assertBusy(() -> assertTrue(isTranslogEmpty(readOnlyEngine))); |
458 |
| - |
459 |
| - assertAcked(client().admin().indices().prepareOpen("test").setWaitForActiveShards(ActiveShardCount.DEFAULT)); |
460 |
| - |
461 |
| - indexService = getInstanceFromNode(IndicesService.class).indexServiceSafe(indexService.index()); |
462 |
| - translog = IndexShardTestCase.getTranslog(indexService.getShard(0)); |
463 |
| - assertThat(translog.totalOperations(), equalTo(0)); |
464 |
| - assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(0)); |
465 |
| - } |
| 422 | + // public void testAsyncTranslogTrimTaskOnClosedIndex() throws Exception { |
| 423 | + // final String indexName = "test"; |
| 424 | + // IndexService indexService = createIndex( |
| 425 | + // indexName, |
| 426 | + // Settings.builder().put(TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING.getKey(), "200ms").build() |
| 427 | + // ); |
| 428 | + // |
| 429 | + // Translog translog = IndexShardTestCase.getTranslog(indexService.getShard(0)); |
| 430 | + // |
| 431 | + // int translogOps = 0; |
| 432 | + // final int numDocs = scaledRandomIntBetween(10, 100); |
| 433 | + // for (int i = 0; i < numDocs; i++) { |
| 434 | + // client().prepareIndex() |
| 435 | + // .setIndex(indexName) |
| 436 | + // .setId(String.valueOf(i)) |
| 437 | + // .setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON) |
| 438 | + // .get(); |
| 439 | + // translogOps++; |
| 440 | + // if (randomBoolean()) { |
| 441 | + // client().admin().indices().prepareFlush(indexName).get(); |
| 442 | + // if (indexService.getIndexSettings().isSoftDeleteEnabled()) { |
| 443 | + // translogOps = 0; |
| 444 | + // } |
| 445 | + // } |
| 446 | + // } |
| 447 | + // assertThat(translog.totalOperations(), equalTo(translogOps)); |
| 448 | + // assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(translogOps)); |
| 449 | + // assertAcked(client().admin().indices().prepareClose("test").setWaitForActiveShards(ActiveShardCount.DEFAULT)); |
| 450 | + // |
| 451 | + // indexService = getInstanceFromNode(IndicesService.class).indexServiceSafe(indexService.index()); |
| 452 | + // assertTrue(indexService.getTrimTranslogTask().mustReschedule()); |
| 453 | + // |
| 454 | + // final Engine readOnlyEngine = getEngine(indexService.getShard(0)); |
| 455 | + // assertBusy(() -> assertTrue(isTranslogEmpty(readOnlyEngine))); |
| 456 | + // |
| 457 | + // assertAcked(client().admin().indices().prepareOpen("test").setWaitForActiveShards(ActiveShardCount.DEFAULT)); |
| 458 | + // |
| 459 | + // indexService = getInstanceFromNode(IndicesService.class).indexServiceSafe(indexService.index()); |
| 460 | + // translog = IndexShardTestCase.getTranslog(indexService.getShard(0)); |
| 461 | + // assertThat(translog.totalOperations(), equalTo(0)); |
| 462 | + // assertThat(translog.stats().estimatedNumberOfOperations(), equalTo(0)); |
| 463 | + // } |
466 | 464 |
|
467 | 465 | boolean isTranslogEmpty(Engine engine) {
|
468 | 466 | long tlogSize = engine.translogManager().getTranslogStats().getTranslogSizeInBytes();
|
|
0 commit comments