Skip to content

Commit

Permalink
Fix document creation process for testCacheFilesAreClosedAfterUse IT (#…
Browse files Browse the repository at this point in the history
…6797)

Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
  • Loading branch information
kotwanikunal committed Mar 23, 2023
1 parent f40fa82 commit 4d78bbf
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4d78bbf

Please sign in to comment.