@Test
public void testCGroups() throws Exception {

  Assume.assumeTrue(shouldRun());
  String cgroupsMount = System.getProperty("cgroups.mount");
  Assume.assumeTrue((cgroupsMount != null) && !cgroupsMount.isEmpty());
  assertTrue("Cgroups mount point does not exist", new File(
      cgroupsMount).exists());
  List<String> cgroupKVs = new ArrayList<>();
  String hierarchy = "hadoop-yarn";
  String[] controllers = { "cpu", "net_cls" };
  for (String controller : controllers) {
    cgroupKVs.add(controller + "=" + cgroupsMount + "/" + controller);
    assertTrue(new File(cgroupsMount, controller).exists());
  }
  try {
    exec.mountCgroups(cgroupKVs, hierarchy);
    for (String controller : controllers) {
      assertTrue(controller + " cgroup not mounted", new File(
          cgroupsMount + "/" + controller + "/tasks").exists());
      assertTrue(controller + " cgroup hierarchy not created",
          new File(cgroupsMount + "/" + controller + "/" + hierarchy).exists());
      assertTrue(controller + " cgroup hierarchy created incorrectly",
          new File(cgroupsMount + "/" + controller + "/" + hierarchy
              + "/tasks").exists());
    }
  } catch (IOException ie) {
    fail("Couldn't mount cgroups " + ie.toString());
    throw ie;
  }
}