From 15bf4f40f1691dc2cabbfc0aab906c6ddd7c19ca Mon Sep 17 00:00:00 2001 From: Kunal Kotwani Date: Wed, 22 Mar 2023 15:52:41 -0700 Subject: [PATCH] Fix document creation process for testCacheFilesAreClosedAfterUse IT Signed-off-by: Kunal Kotwani --- .../opensearch/snapshots/SearchableSnapshotIT.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/SearchableSnapshotIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SearchableSnapshotIT.java index 5f5e0a0912140..efb2615cd086a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SearchableSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SearchableSnapshotIT.java @@ -15,7 +15,6 @@ import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; import org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequestBuilder; import org.opensearch.action.index.IndexRequestBuilder; -import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.client.Client; import org.opensearch.cluster.ClusterState; @@ -31,7 +30,6 @@ import org.opensearch.env.NodeEnvironment; import org.opensearch.index.Index; import org.opensearch.index.IndexNotFoundException; -import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.store.remote.file.CleanerDaemonThreadLeakFilter; import org.opensearch.index.store.remote.filecache.FileCacheStats; import org.opensearch.monitor.fs.FsInfo; @@ -53,7 +51,6 @@ import static org.hamcrest.Matchers.notNullValue; import static org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest.Metric.FS; import static org.opensearch.common.util.CollectionUtils.iterableAsArrayList; -import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; @ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class) public final class SearchableSnapshotIT extends AbstractSnapshotIntegTestCase { @@ -545,27 +542,20 @@ public void testPruneFileCacheOnIndexDeletion() throws Exception { assertAllNodesFileCacheEmpty(); } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/6686") public void testCacheFilesAreClosedAfterUse() throws Exception { final int numReplicasIndex = randomIntBetween(1, 4); final String indexName = "test-idx"; final String restoredIndexName = indexName + "-copy"; final String repoName = "test-repo"; final String snapshotName = "test-snap"; - final String id = randomAlphaOfLength(5); final Client client = client(); internalCluster().ensureAtLeastNumSearchAndDataNodes(numReplicasIndex + 1); - createIndex(indexName); - client().prepareIndex(indexName).setId(id).setSource("field", "test").get(); - ensureGreen(); + createIndexWithDocsAndEnsureGreen(1, 100, indexName); createRepositoryWithSettings(null, repoName); takeSnapshot(client, snapshotName, repoName, indexName); restoreSnapshotAndEnsureGreen(client, snapshotName, repoName); - - // Search document to make the index fetch data from the remote snapshot to local storage - SearchResponse searchResponse = client().prepareSearch(restoredIndexName).setQuery(QueryBuilders.termQuery("field", "test")).get(); - assertHitCount(searchResponse, 1); + assertDocCount(restoredIndexName, 100L); // The local cache files should be closed by deleting the restored index deleteIndicesAndEnsureGreen(client, restoredIndexName);