Skip to content

Commit 4d78bbf

Browse files
authored
Fix document creation process for testCacheFilesAreClosedAfterUse IT (#6797)
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
1 parent f40fa82 commit 4d78bbf

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

server/src/internalClusterTest/java/org/opensearch/snapshots/SearchableSnapshotIT.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
1616
import org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequestBuilder;
1717
import org.opensearch.action.index.IndexRequestBuilder;
18-
import org.opensearch.action.search.SearchResponse;
1918
import org.opensearch.action.support.master.AcknowledgedResponse;
2019
import org.opensearch.client.Client;
2120
import org.opensearch.cluster.ClusterState;
@@ -31,7 +30,6 @@
3130
import org.opensearch.env.NodeEnvironment;
3231
import org.opensearch.index.Index;
3332
import org.opensearch.index.IndexNotFoundException;
34-
import org.opensearch.index.query.QueryBuilders;
3533
import org.opensearch.index.store.remote.file.CleanerDaemonThreadLeakFilter;
3634
import org.opensearch.index.store.remote.filecache.FileCacheStats;
3735
import org.opensearch.monitor.fs.FsInfo;
@@ -53,7 +51,6 @@
5351
import static org.hamcrest.Matchers.notNullValue;
5452
import static org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest.Metric.FS;
5553
import static org.opensearch.common.util.CollectionUtils.iterableAsArrayList;
56-
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;
5754

5855
@ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class)
5956
public final class SearchableSnapshotIT extends AbstractSnapshotIntegTestCase {
@@ -545,27 +542,20 @@ public void testPruneFileCacheOnIndexDeletion() throws Exception {
545542
assertAllNodesFileCacheEmpty();
546543
}
547544

548-
@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/6686")
549545
public void testCacheFilesAreClosedAfterUse() throws Exception {
550546
final int numReplicasIndex = randomIntBetween(1, 4);
551547
final String indexName = "test-idx";
552548
final String restoredIndexName = indexName + "-copy";
553549
final String repoName = "test-repo";
554550
final String snapshotName = "test-snap";
555-
final String id = randomAlphaOfLength(5);
556551
final Client client = client();
557552

558553
internalCluster().ensureAtLeastNumSearchAndDataNodes(numReplicasIndex + 1);
559-
createIndex(indexName);
560-
client().prepareIndex(indexName).setId(id).setSource("field", "test").get();
561-
ensureGreen();
554+
createIndexWithDocsAndEnsureGreen(1, 100, indexName);
562555
createRepositoryWithSettings(null, repoName);
563556
takeSnapshot(client, snapshotName, repoName, indexName);
564557
restoreSnapshotAndEnsureGreen(client, snapshotName, repoName);
565-
566-
// Search document to make the index fetch data from the remote snapshot to local storage
567-
SearchResponse searchResponse = client().prepareSearch(restoredIndexName).setQuery(QueryBuilders.termQuery("field", "test")).get();
568-
assertHitCount(searchResponse, 1);
558+
assertDocCount(restoredIndexName, 100L);
569559

570560
// The local cache files should be closed by deleting the restored index
571561
deleteIndicesAndEnsureGreen(client, restoredIndexName);

0 commit comments

Comments
 (0)