@Test
public void testDeleteCgroup() throws Exception {

  final MockClock clock = new MockClock();
  clock.time = System.currentTimeMillis();
  CgroupsLCEResourcesHandler handler = new CgroupsLCEResourcesHandler();
  handler.setConf(new YarnConfiguration());
  handler.initConfig();
  handler.clock = clock;
  
  //file exists
  File file = new File("target", UUID.randomUUID().toString());
  new FileOutputStream(file).close();
  Assert.assertTrue(handler.deleteCgroup(file.getPath()));
  //file does not exists, timing out
  final CountDownLatch latch = new CountDownLatch(1);
  new Thread() {
    @Override
    public void run() {
      latch.countDown();
      try {
        Thread.sleep(200);
      } catch (InterruptedException ex) {
        //NOP
      }
      clock.time += YarnConfiguration.
          DEFAULT_NM_LINUX_CONTAINER_CGROUPS_DELETE_TIMEOUT;
    }
  }.start();
  latch.await();
  file = new File("target", UUID.randomUUID().toString());
  Assert.assertFalse(handler.deleteCgroup(file.getPath()));
}