|  | @@ -90,40 +90,45 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void doTestSortOrder(String repoName, Collection<String> allSnapshotNames, SortOrder order) throws IOException {
 | 
	
		
			
				|  |  | -        final List<SnapshotInfo> defaultSorting = clusterAdmin().prepareGetSnapshots(repoName).setOrder(order).get().getSnapshots();
 | 
	
		
			
				|  |  | +        final boolean includeIndexNames = randomBoolean();
 | 
	
		
			
				|  |  | +        final List<SnapshotInfo> defaultSorting = clusterAdmin().prepareGetSnapshots(repoName)
 | 
	
		
			
				|  |  | +            .setOrder(order)
 | 
	
		
			
				|  |  | +            .setIncludeIndexNames(includeIndexNames)
 | 
	
		
			
				|  |  | +            .get()
 | 
	
		
			
				|  |  | +            .getSnapshots();
 | 
	
		
			
				|  |  |          assertSnapshotListSorted(defaultSorting, null, order);
 | 
	
		
			
				|  |  |          assertSnapshotListSorted(
 | 
	
		
			
				|  |  | -            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.NAME, order),
 | 
	
		
			
				|  |  | +            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.NAME, order, includeIndexNames),
 | 
	
		
			
				|  |  |              GetSnapshotsRequest.SortBy.NAME,
 | 
	
		
			
				|  |  |              order
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          assertSnapshotListSorted(
 | 
	
		
			
				|  |  | -            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.DURATION, order),
 | 
	
		
			
				|  |  | +            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.DURATION, order, includeIndexNames),
 | 
	
		
			
				|  |  |              GetSnapshotsRequest.SortBy.DURATION,
 | 
	
		
			
				|  |  |              order
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          assertSnapshotListSorted(
 | 
	
		
			
				|  |  | -            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.INDICES, order),
 | 
	
		
			
				|  |  | +            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.INDICES, order, includeIndexNames),
 | 
	
		
			
				|  |  |              GetSnapshotsRequest.SortBy.INDICES,
 | 
	
		
			
				|  |  |              order
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          assertSnapshotListSorted(
 | 
	
		
			
				|  |  | -            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.START_TIME, order),
 | 
	
		
			
				|  |  | +            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.START_TIME, order, includeIndexNames),
 | 
	
		
			
				|  |  |              GetSnapshotsRequest.SortBy.START_TIME,
 | 
	
		
			
				|  |  |              order
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          assertSnapshotListSorted(
 | 
	
		
			
				|  |  | -            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.SHARDS, order),
 | 
	
		
			
				|  |  | +            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.SHARDS, order, includeIndexNames),
 | 
	
		
			
				|  |  |              GetSnapshotsRequest.SortBy.SHARDS,
 | 
	
		
			
				|  |  |              order
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          assertSnapshotListSorted(
 | 
	
		
			
				|  |  | -            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.FAILED_SHARDS, order),
 | 
	
		
			
				|  |  | +            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.FAILED_SHARDS, order, includeIndexNames),
 | 
	
		
			
				|  |  |              GetSnapshotsRequest.SortBy.FAILED_SHARDS,
 | 
	
		
			
				|  |  |              order
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          assertSnapshotListSorted(
 | 
	
		
			
				|  |  | -            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.REPOSITORY, order),
 | 
	
		
			
				|  |  | +            allSnapshotsSorted(allSnapshotNames, repoName, GetSnapshotsRequest.SortBy.REPOSITORY, order, includeIndexNames),
 | 
	
		
			
				|  |  |              GetSnapshotsRequest.SortBy.REPOSITORY,
 | 
	
		
			
				|  |  |              order
 | 
	
		
			
				|  |  |          );
 | 
	
	
		
			
				|  | @@ -143,18 +148,26 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void doTestPagination(String repoName, List<String> names, GetSnapshotsRequest.SortBy sort, SortOrder order)
 | 
	
		
			
				|  |  |          throws IOException {
 | 
	
		
			
				|  |  | -        final List<SnapshotInfo> allSnapshotsSorted = allSnapshotsSorted(names, repoName, sort, order);
 | 
	
		
			
				|  |  | -        final GetSnapshotsResponse batch1 = sortedWithLimit(repoName, sort, null, 2, order);
 | 
	
		
			
				|  |  | +        final boolean includeIndexNames = randomBoolean();
 | 
	
		
			
				|  |  | +        final List<SnapshotInfo> allSnapshotsSorted = allSnapshotsSorted(names, repoName, sort, order, includeIndexNames);
 | 
	
		
			
				|  |  | +        final GetSnapshotsResponse batch1 = sortedWithLimit(repoName, sort, null, 2, order, includeIndexNames);
 | 
	
		
			
				|  |  |          assertEquals(allSnapshotsSorted.subList(0, 2), batch1.getSnapshots());
 | 
	
		
			
				|  |  | -        final GetSnapshotsResponse batch2 = sortedWithLimit(repoName, sort, batch1.next(), 2, order);
 | 
	
		
			
				|  |  | +        final GetSnapshotsResponse batch2 = sortedWithLimit(repoName, sort, batch1.next(), 2, order, includeIndexNames);
 | 
	
		
			
				|  |  |          assertEquals(allSnapshotsSorted.subList(2, 4), batch2.getSnapshots());
 | 
	
		
			
				|  |  |          final int lastBatch = names.size() - batch1.getSnapshots().size() - batch2.getSnapshots().size();
 | 
	
		
			
				|  |  | -        final GetSnapshotsResponse batch3 = sortedWithLimit(repoName, sort, batch2.next(), lastBatch, order);
 | 
	
		
			
				|  |  | +        final GetSnapshotsResponse batch3 = sortedWithLimit(repoName, sort, batch2.next(), lastBatch, order, includeIndexNames);
 | 
	
		
			
				|  |  |          assertEquals(
 | 
	
		
			
				|  |  |              batch3.getSnapshots(),
 | 
	
		
			
				|  |  |              allSnapshotsSorted.subList(batch1.getSnapshots().size() + batch2.getSnapshots().size(), names.size())
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  | -        final GetSnapshotsResponse batch3NoLimit = sortedWithLimit(repoName, sort, batch2.next(), GetSnapshotsRequest.NO_LIMIT, order);
 | 
	
		
			
				|  |  | +        final GetSnapshotsResponse batch3NoLimit = sortedWithLimit(
 | 
	
		
			
				|  |  | +            repoName,
 | 
	
		
			
				|  |  | +            sort,
 | 
	
		
			
				|  |  | +            batch2.next(),
 | 
	
		
			
				|  |  | +            GetSnapshotsRequest.NO_LIMIT,
 | 
	
		
			
				|  |  | +            order,
 | 
	
		
			
				|  |  | +            includeIndexNames
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  |          assertNull(batch3NoLimit.next());
 | 
	
		
			
				|  |  |          assertEquals(batch3.getSnapshots(), batch3NoLimit.getSnapshots());
 | 
	
		
			
				|  |  |          final GetSnapshotsResponse batch3LargeLimit = sortedWithLimit(
 | 
	
	
		
			
				|  | @@ -162,7 +175,8 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |              sort,
 | 
	
		
			
				|  |  |              batch2.next(),
 | 
	
		
			
				|  |  |              lastBatch + randomIntBetween(1, 100),
 | 
	
		
			
				|  |  | -            order
 | 
	
		
			
				|  |  | +            order,
 | 
	
		
			
				|  |  | +            includeIndexNames
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          assertEquals(batch3.getSnapshots(), batch3LargeLimit.getSnapshots());
 | 
	
		
			
				|  |  |          assertNull(batch3LargeLimit.next());
 | 
	
	
		
			
				|  | @@ -356,10 +370,11 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |      private static void assertStablePagination(String repoName, Collection<String> allSnapshotNames, GetSnapshotsRequest.SortBy sort)
 | 
	
		
			
				|  |  |          throws IOException {
 | 
	
		
			
				|  |  |          final SortOrder order = randomFrom(SortOrder.values());
 | 
	
		
			
				|  |  | -        final List<SnapshotInfo> allSorted = allSnapshotsSorted(allSnapshotNames, repoName, sort, order);
 | 
	
		
			
				|  |  | +        final boolean includeIndexNames = sort == GetSnapshotsRequest.SortBy.INDICES || randomBoolean();
 | 
	
		
			
				|  |  | +        final List<SnapshotInfo> allSorted = allSnapshotsSorted(allSnapshotNames, repoName, sort, order, includeIndexNames);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          for (int i = 1; i <= allSnapshotNames.size(); i++) {
 | 
	
		
			
				|  |  | -            final List<SnapshotInfo> subsetSorted = sortedWithLimit(repoName, sort, null, i, order).getSnapshots();
 | 
	
		
			
				|  |  | +            final List<SnapshotInfo> subsetSorted = sortedWithLimit(repoName, sort, null, i, order, includeIndexNames).getSnapshots();
 | 
	
		
			
				|  |  |              assertEquals(subsetSorted, allSorted.subList(0, i));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -371,9 +386,17 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |                      sort,
 | 
	
		
			
				|  |  |                      GetSnapshotsRequest.After.from(after, sort).asQueryParam(),
 | 
	
		
			
				|  |  |                      i,
 | 
	
		
			
				|  |  | -                    order
 | 
	
		
			
				|  |  | +                    order,
 | 
	
		
			
				|  |  | +                    includeIndexNames
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +                final GetSnapshotsResponse getSnapshotsResponseNumeric = sortedWithLimit(
 | 
	
		
			
				|  |  | +                    repoName,
 | 
	
		
			
				|  |  | +                    sort,
 | 
	
		
			
				|  |  | +                    j + 1,
 | 
	
		
			
				|  |  | +                    i,
 | 
	
		
			
				|  |  | +                    order,
 | 
	
		
			
				|  |  | +                    includeIndexNames
 | 
	
		
			
				|  |  |                  );
 | 
	
		
			
				|  |  | -                final GetSnapshotsResponse getSnapshotsResponseNumeric = sortedWithLimit(repoName, sort, j + 1, i, order);
 | 
	
		
			
				|  |  |                  final List<SnapshotInfo> subsetSorted = getSnapshotsResponse.getSnapshots();
 | 
	
		
			
				|  |  |                  assertEquals(subsetSorted, getSnapshotsResponseNumeric.getSnapshots());
 | 
	
		
			
				|  |  |                  assertEquals(subsetSorted, allSorted.subList(j + 1, j + i + 1));
 | 
	
	
		
			
				|  | @@ -389,15 +412,22 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |          Collection<String> allSnapshotNames,
 | 
	
		
			
				|  |  |          String repoName,
 | 
	
		
			
				|  |  |          GetSnapshotsRequest.SortBy sortBy,
 | 
	
		
			
				|  |  | -        SortOrder order
 | 
	
		
			
				|  |  | +        SortOrder order,
 | 
	
		
			
				|  |  | +        boolean includeIndices
 | 
	
		
			
				|  |  |      ) throws IOException {
 | 
	
		
			
				|  |  |          final Request request = baseGetSnapshotsRequest(repoName);
 | 
	
		
			
				|  |  |          request.addParameter("sort", sortBy.toString());
 | 
	
		
			
				|  |  |          if (order == SortOrder.DESC || randomBoolean()) {
 | 
	
		
			
				|  |  |              request.addParameter("order", order.toString());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        addIndexNamesParameter(includeIndices, request);
 | 
	
		
			
				|  |  |          final GetSnapshotsResponse getSnapshotsResponse = readSnapshotInfos(getRestClient().performRequest(request));
 | 
	
		
			
				|  |  |          final List<SnapshotInfo> snapshotInfos = getSnapshotsResponse.getSnapshots();
 | 
	
		
			
				|  |  | +        if (includeIndices == false) {
 | 
	
		
			
				|  |  | +            for (SnapshotInfo snapshotInfo : snapshotInfos) {
 | 
	
		
			
				|  |  | +                assertThat(snapshotInfo.indices(), empty());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          assertEquals(snapshotInfos.size(), allSnapshotNames.size());
 | 
	
		
			
				|  |  |          assertEquals(getSnapshotsResponse.totalCount(), allSnapshotNames.size());
 | 
	
		
			
				|  |  |          assertEquals(0, getSnapshotsResponse.remaining());
 | 
	
	
		
			
				|  | @@ -429,7 +459,8 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |          GetSnapshotsRequest.SortBy sortBy,
 | 
	
		
			
				|  |  |          String after,
 | 
	
		
			
				|  |  |          int size,
 | 
	
		
			
				|  |  | -        SortOrder order
 | 
	
		
			
				|  |  | +        SortOrder order,
 | 
	
		
			
				|  |  | +        boolean includeIndices
 | 
	
		
			
				|  |  |      ) throws IOException {
 | 
	
		
			
				|  |  |          final Request request = baseGetSnapshotsRequest(repoName);
 | 
	
		
			
				|  |  |          request.addParameter("sort", sortBy.toString());
 | 
	
	
		
			
				|  | @@ -442,16 +473,26 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |          if (order == SortOrder.DESC || randomBoolean()) {
 | 
	
		
			
				|  |  |              request.addParameter("order", order.toString());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        addIndexNamesParameter(includeIndices, request);
 | 
	
		
			
				|  |  |          final Response response = getRestClient().performRequest(request);
 | 
	
		
			
				|  |  |          return readSnapshotInfos(response);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private static void addIndexNamesParameter(boolean includeIndices, Request request) {
 | 
	
		
			
				|  |  | +        if (includeIndices == false) {
 | 
	
		
			
				|  |  | +            request.addParameter(SnapshotInfo.INDEX_NAMES_XCONTENT_PARAM, "false");
 | 
	
		
			
				|  |  | +        } else if (randomBoolean()) {
 | 
	
		
			
				|  |  | +            request.addParameter(SnapshotInfo.INDEX_NAMES_XCONTENT_PARAM, "true");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private static GetSnapshotsResponse sortedWithLimit(
 | 
	
		
			
				|  |  |          String repoName,
 | 
	
		
			
				|  |  |          GetSnapshotsRequest.SortBy sortBy,
 | 
	
		
			
				|  |  |          int offset,
 | 
	
		
			
				|  |  |          int size,
 | 
	
		
			
				|  |  | -        SortOrder order
 | 
	
		
			
				|  |  | +        SortOrder order,
 | 
	
		
			
				|  |  | +        boolean includeIndices
 | 
	
		
			
				|  |  |      ) throws IOException {
 | 
	
		
			
				|  |  |          final Request request = baseGetSnapshotsRequest(repoName);
 | 
	
		
			
				|  |  |          request.addParameter("sort", sortBy.toString());
 | 
	
	
		
			
				|  | @@ -462,6 +503,7 @@ public class RestGetSnapshotsIT extends AbstractSnapshotRestTestCase {
 | 
	
		
			
				|  |  |          if (order == SortOrder.DESC || randomBoolean()) {
 | 
	
		
			
				|  |  |              request.addParameter("order", order.toString());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        addIndexNamesParameter(includeIndices, request);
 | 
	
		
			
				|  |  |          final Response response = getRestClient().performRequest(request);
 | 
	
		
			
				|  |  |          return readSnapshotInfos(response);
 | 
	
		
			
				|  |  |      }
 |