|
41 | 41 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
42 | 42 | import static org.hamcrest.Matchers.equalTo;
|
43 | 43 | import static org.hamcrest.Matchers.greaterThan;
|
| 44 | +import static org.hamcrest.Matchers.hasSize; |
| 45 | +import static org.hamcrest.Matchers.is; |
44 | 46 |
|
45 | 47 | public class SnapshotStatusApisIT extends AbstractSnapshotIntegTestCase {
|
46 | 48 |
|
@@ -167,4 +169,26 @@ public void testExceptionOnMissingShardLevelSnapBlob() throws IOException {
|
167 | 169 | expectThrows(SnapshotMissingException.class, () -> client().admin().cluster()
|
168 | 170 | .prepareSnapshotStatus("test-repo").setSnapshots("test-snap").execute().actionGet());
|
169 | 171 | }
|
| 172 | + |
| 173 | + public void testGetSnapshotsWithoutIndices() { |
| 174 | + logger.info("--> creating repository"); |
| 175 | + assertAcked(client().admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings( |
| 176 | + Settings.builder().put("location", randomRepoPath()).build())); |
| 177 | + |
| 178 | + logger.info("--> snapshot"); |
| 179 | + final SnapshotInfo snapshotInfo = |
| 180 | + client().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap") |
| 181 | + .setIndices().setWaitForCompletion(true).get().getSnapshotInfo(); |
| 182 | + |
| 183 | + assertThat(snapshotInfo.state(), is(SnapshotState.SUCCESS)); |
| 184 | + assertThat(snapshotInfo.totalShards(), is(0)); |
| 185 | + |
| 186 | + logger.info("--> verify that snapshot without index shows up in non-verbose listing"); |
| 187 | + final List<SnapshotInfo> snapshotInfos = |
| 188 | + client().admin().cluster().prepareGetSnapshots("test-repo").setVerbose(false).get().getSnapshots(); |
| 189 | + assertThat(snapshotInfos, hasSize(1)); |
| 190 | + final SnapshotInfo found = snapshotInfos.get(0); |
| 191 | + assertThat(found.snapshotId(), is(snapshotInfo.snapshotId())); |
| 192 | + assertThat(found.state(), is(SnapshotState.SUCCESS)); |
| 193 | + } |
170 | 194 | }
|
0 commit comments