@Test
public void testDeleteMissingFlatInterleavedFiles() throws IOException {

  TaskAttemptContext taskAttemptContext = getTaskAttemptContext(config);
  JobContext jobContext = new JobContextImpl(taskAttemptContext.getConfiguration(),
      taskAttemptContext.getTaskAttemptID().getJobID());
  Configuration conf = jobContext.getConfiguration();
  String sourceBase;
  String targetBase;
  FileSystem fs = null;
  try {
    OutputCommitter committer = new CopyCommitter(null, taskAttemptContext);
    fs = FileSystem.get(conf);
    sourceBase = "/tmp1/" + String.valueOf(rand.nextLong());
    targetBase = "/tmp1/" + String.valueOf(rand.nextLong());
    createFile(fs, sourceBase + "/1");
    createFile(fs, sourceBase + "/3");
    createFile(fs, sourceBase + "/4");
    createFile(fs, sourceBase + "/5");
    createFile(fs, sourceBase + "/7");
    createFile(fs, sourceBase + "/8");
    createFile(fs, sourceBase + "/9");
    createFile(fs, targetBase + "/2");
    createFile(fs, targetBase + "/4");
    createFile(fs, targetBase + "/5");
    createFile(fs, targetBase + "/7");
    createFile(fs, targetBase + "/9");
    createFile(fs, targetBase + "/A");
    final DistCpOptions options = new DistCpOptions.Builder(
        Collections.singletonList(new Path(sourceBase)), new Path("/out"))
        .withSyncFolder(true).withDeleteMissing(true).build();
    options.appendToConf(conf);
    final DistCpContext context = new DistCpContext(options);
    CopyListing listing = new GlobbedCopyListing(conf, CREDENTIALS);
    Path listingFile = new Path("/tmp1/" + String.valueOf(rand.nextLong()));
    listing.buildListing(listingFile, context);
    conf.set(CONF_LABEL_TARGET_WORK_PATH, targetBase);
    conf.set(CONF_LABEL_TARGET_FINAL_PATH, targetBase);
    committer.commitJob(jobContext);
    verifyFoldersAreInSync(fs, targetBase, sourceBase);
    Assert.assertEquals(4, fs.listStatus(new Path(targetBase)).length);
    //Test for idempotent commit
    committer.commitJob(jobContext);
    verifyFoldersAreInSync(fs, targetBase, sourceBase);
    Assert.assertEquals(4, fs.listStatus(new Path(targetBase)).length);
  } finally {
    TestDistCpUtils.delete(fs, "/tmp1");
    conf.set(DistCpConstants.CONF_LABEL_DELETE_MISSING, "false");
  }
}