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