|
12 | 12 | import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreRequest;
|
13 | 13 | import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
14 | 14 | import org.opensearch.action.admin.indices.delete.DeleteIndexRequest;
|
| 15 | +import org.opensearch.action.admin.indices.recovery.RecoveryResponse; |
15 | 16 | import org.opensearch.action.delete.DeleteResponse;
|
16 | 17 | import org.opensearch.action.support.PlainActionFuture;
|
17 | 18 | import org.opensearch.client.Client;
|
18 | 19 | import org.opensearch.client.Requests;
|
19 | 20 | import org.opensearch.cluster.ClusterState;
|
20 | 21 | import org.opensearch.cluster.metadata.IndexMetadata;
|
| 22 | +import org.opensearch.cluster.routing.RecoverySource; |
21 | 23 | import org.opensearch.common.Nullable;
|
22 | 24 | import org.opensearch.common.blobstore.BlobPath;
|
23 | 25 | import org.opensearch.common.io.PathUtils;
|
|
31 | 33 | import org.opensearch.index.remote.RemoteStoreEnums.PathType;
|
32 | 34 | import org.opensearch.index.shard.IndexShard;
|
33 | 35 | import org.opensearch.indices.IndicesService;
|
| 36 | +import org.opensearch.indices.recovery.RecoveryState; |
34 | 37 | import org.opensearch.indices.replication.common.ReplicationType;
|
35 | 38 | import org.opensearch.snapshots.AbstractSnapshotIntegTestCase;
|
36 | 39 | import org.opensearch.snapshots.SnapshotInfo;
|
|
63 | 66 | import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
|
64 | 67 | import static org.hamcrest.Matchers.equalTo;
|
65 | 68 | import static org.hamcrest.Matchers.greaterThan;
|
| 69 | +import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
| 70 | +import static org.hamcrest.Matchers.lessThanOrEqualTo; |
66 | 71 |
|
67 | 72 | @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
|
68 | 73 | public class RemoteRestoreSnapshotIT extends AbstractSnapshotIntegTestCase {
|
@@ -579,6 +584,37 @@ public void testRestoreShallowSnapshotRepository() throws ExecutionException, In
|
579 | 584 | ensureGreen(restoredIndexName1);
|
580 | 585 | assertDocsPresentInIndex(client, restoredIndexName1, numDocsInIndex1);
|
581 | 586 |
|
| 587 | + // ensure recovery details are non-zero |
| 588 | + RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries(restoredIndexName1).execute().actionGet(); |
| 589 | + assertEquals(1, recoveryResponse.getTotalShards()); |
| 590 | + assertEquals(1, recoveryResponse.getSuccessfulShards()); |
| 591 | + assertEquals(0, recoveryResponse.getFailedShards()); |
| 592 | + assertEquals(1, recoveryResponse.shardRecoveryStates().size()); |
| 593 | + assertTrue(recoveryResponse.shardRecoveryStates().containsKey(restoredIndexName1)); |
| 594 | + assertEquals(1, recoveryResponse.shardRecoveryStates().get(restoredIndexName1).size()); |
| 595 | + |
| 596 | + RecoveryState recoveryState = recoveryResponse.shardRecoveryStates().get(restoredIndexName1).get(0); |
| 597 | + assertEquals(RecoveryState.Stage.DONE, recoveryState.getStage()); |
| 598 | + assertEquals(0, recoveryState.getShardId().getId()); |
| 599 | + assertTrue(recoveryState.getPrimary()); |
| 600 | + assertEquals(RecoverySource.Type.SNAPSHOT, recoveryState.getRecoverySource().getType()); |
| 601 | + assertThat(recoveryState.getIndex().time(), greaterThanOrEqualTo(0L)); |
| 602 | + |
| 603 | + // ensure populated file details |
| 604 | + assertTrue(recoveryState.getIndex().totalFileCount() > 0); |
| 605 | + assertTrue(recoveryState.getIndex().totalRecoverFiles() > 0); |
| 606 | + assertTrue(recoveryState.getIndex().recoveredFileCount() > 0); |
| 607 | + assertThat(recoveryState.getIndex().recoveredFilesPercent(), greaterThanOrEqualTo(0.0f)); |
| 608 | + assertThat(recoveryState.getIndex().recoveredFilesPercent(), lessThanOrEqualTo(100.0f)); |
| 609 | + assertFalse(recoveryState.getIndex().fileDetails().isEmpty()); |
| 610 | + |
| 611 | + // ensure populated bytes details |
| 612 | + assertTrue(recoveryState.getIndex().recoveredBytes() > 0L); |
| 613 | + assertTrue(recoveryState.getIndex().totalBytes() > 0L); |
| 614 | + assertTrue(recoveryState.getIndex().totalRecoverBytes() > 0L); |
| 615 | + assertThat(recoveryState.getIndex().recoveredBytesPercent(), greaterThanOrEqualTo(0.0f)); |
| 616 | + assertThat(recoveryState.getIndex().recoveredBytesPercent(), lessThanOrEqualTo(100.0f)); |
| 617 | + |
582 | 618 | // indexing some new docs and validating
|
583 | 619 | indexDocuments(client, restoredIndexName1, numDocsInIndex1, numDocsInIndex1 + 2);
|
584 | 620 | ensureGreen(restoredIndexName1);
|
|
0 commit comments