code:     public void testSnapshotMoreThanOnce() throws ExecutionException, InterruptedException, IOException {
          Client client = client();
          final File tempDir = newTempDir(LifecycleScope.SUITE).getAbsoluteFile();
          logger.info("-->  creating repository");
          assertAcked(client.admin().cluster().preparePutRepository("test-repo")
                  .setType("fs").setSettings(ImmutableSettings.settingsBuilder()
                          .put("location", tempDir)
                          .put("compress", randomBoolean())
                          .put("chunk_size", randomIntBetween(100, 1000))));
  
          // only one shard
          assertAcked(prepareCreate("test").setSettings(ImmutableSettings.builder()
                  .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
                  .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
          ));
          ensureYellow();
          logger.info("-->  indexing");
  
          final int numDocs = randomIntBetween(10, 100);
          IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
          for (int i = 0; i < builders.length; i++) {
              builders[i] = client().prepareIndex("test", "doc", Integer.toString(i)).setSource("foo", "bar" + i);
          }
          indexRandom(true, builders);
          flushAndRefresh();
          assertNoFailures(client().admin().indices().prepareOptimize("test").setFlush(true).setMaxNumSegments(1).get());
  
          CreateSnapshotResponse createSnapshotResponseFirst = client.admin().cluster().prepareCreateSnapshot("test-repo", "test").setWaitForCompletion(true).setIndices("test").get();
          assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(), greaterThan(0));
          assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponseFirst.getSnapshotInfo().totalShards()));
          assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
          {
              SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test").get().getSnapshots().get(0);
              List<SnapshotIndexShardStatus> shards = snapshotStatus.getShards();
              for (SnapshotIndexShardStatus status : shards) {
                  assertThat(status.getStats().getProcessedFiles(), greaterThan(1));
              }
          }
          if (frequently()) {
              logger.info("-->  upgrade");
              client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder().put(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE, "none")).get();
              backwardsCluster().allowOnAllNodes("test");
              logClusterState();
              boolean upgraded;
              do {
                  logClusterState();
                  CountResponse countResponse = client().prepareCount().get();
                  assertHitCount(countResponse, numDocs);
                  upgraded = backwardsCluster().upgradeOneNode();
                  ensureYellow();
                  countResponse = client().prepareCount().get();
                  assertHitCount(countResponse, numDocs);
              } while (upgraded);
              client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder().put(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE, "all")).get();
          }
          if (cluster().numDataNodes() > 1 && randomBoolean()) { // only bump the replicas if we have enough nodes
              logger.info("--> move from 0 to 1 replica");
              client().admin().indices().prepareUpdateSettings("test").setSettings(ImmutableSettings.builder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)).get();
          }
          logger.debug("---> repo exists: " + new File(tempDir, "indices/test/0").exists() + " files: " + Arrays.toString(new File(tempDir, "indices/test/0").list())); // it's only one shard!
          CreateSnapshotResponse createSnapshotResponseSecond = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-1").setWaitForCompletion(true).setIndices("test").get();
          assertThat(createSnapshotResponseSecond.getSnapshotInfo().successfulShards(), greaterThan(0));
          assertThat(createSnapshotResponseSecond.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponseSecond.getSnapshotInfo().totalShards()));
          assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-1").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
          {
              SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test-1").get().getSnapshots().get(0);
              List<SnapshotIndexShardStatus> shards = snapshotStatus.getShards();
              for (SnapshotIndexShardStatus status : shards) {
  
                  assertThat(status.getStats().getProcessedFiles(), equalTo(1)); // we flush before the snapshot such that we have to process the segments_N files
              }
          }
  
          client().prepareDelete("test", "doc", "1").get();
          CreateSnapshotResponse createSnapshotResponseThird = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-2").setWaitForCompletion(true).setIndices("test").get();
          assertThat(createSnapshotResponseThird.getSnapshotInfo().successfulShards(), greaterThan(0));
          assertThat(createSnapshotResponseThird.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponseThird.getSnapshotInfo().totalShards()));
          assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-2").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
          {
              SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test-2").get().getSnapshots().get(0);
              List<SnapshotIndexShardStatus> shards = snapshotStatus.getShards();
              for (SnapshotIndexShardStatus status : shards) {
                  assertThat(status.getStats().getProcessedFiles(), equalTo(2)); // we flush before the snapshot such that we have to process the segments_N files plus the .del file
              }
          }
      }
  