From 4bd2acb7b3905a0e2f92162abbe9352c35da5448 Mon Sep 17 00:00:00 2001 From: Shubh Sahu Date: Wed, 8 Jan 2025 16:11:33 +0530 Subject: [PATCH] Modifying IT to restore snapshot Signed-off-by: Shubh Sahu --- .../org/opensearch/remotestore/RemoteStoreIT.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java index 27893986a411b..1c4585e38ee90 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java @@ -1084,7 +1084,7 @@ public void testCloseIndexWithNoOpSyncAndFlushForAsyncTranslog() throws Interrup public void testSuccessfulShallowV1SnapshotPostIndexClose() throws Exception { internalCluster().startClusterManagerOnlyNode(); - internalCluster().startDataOnlyNodes(1); + String dataNode = internalCluster().startDataOnlyNodes(1).get(0); createIndex(INDEX_NAME, remoteStoreIndexSettings(0, 10000L, -1)); ensureGreen(INDEX_NAME); @@ -1143,5 +1143,17 @@ public void testSuccessfulShallowV1SnapshotPostIndexClose() throws Exception { assertEquals(SnapshotState.SUCCESS, snapshotInfo2.state()); assertTrue(snapshotInfo2.successfulShards() > 0); assertEquals(0, snapshotInfo2.failedShards()); + + // delete the index + cluster().wipeIndices(INDEX_NAME); + // try restoring the snapshot + RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(shallowSnapshotRepoName, snapshot2) + .setWaitForCompletion(true) + .execute() + .actionGet(); + assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0)); + ensureGreen(INDEX_NAME); + flushAndRefresh(INDEX_NAME); + assertBusy(() -> { assertHitCount(client(dataNode).prepareSearch(INDEX_NAME).setSize(0).get(), 20); }); } }