@Test
public void testTailDirSourceStartFromEnd() throws IOException,
    FlumeSpecException, InterruptedException {

  File tmpdir = FileUtil.mktempdir();
  // generating files: emulating their existence prior to sink opening
  genFiles(tmpdir, "foo", 10, 100);
  TailDirSource src = new TailDirSource(tmpdir, ".*", true);
  AccumulatorSink cnt = new AccumulatorSink("tailcount");
  DirectDriver drv = new DirectDriver(src, cnt);
  drv.start();
  Clock.sleep(1000);
  assertEquals(0, cnt.getCount());
  // adding lines to existing files
  addLinesToExistingFiles(tmpdir, 10);
  Clock.sleep(1000);
  assertEquals(10 * 10, cnt.getCount());
  // generating new files
  genFiles(tmpdir, "bar", 10, 100);
  Clock.sleep(1000);
  assertEquals(10 * 10 + 1000, cnt.getCount());
  drv.stop();
  FileUtil.rmr(tmpdir);
  // in total 20 files were added
  assertEquals(Long.valueOf(20),
      src.getMetrics().getLongMetric(TailDirSource.A_FILESADDED));
}