### Question:
LinuxContainerExecutor extends ContainerExecutor { public void mountCgroups(List<String> cgroupKVs, String hierarchy) throws IOException { try { PrivilegedOperation mountCGroupsOp = new PrivilegedOperation( PrivilegedOperation.OperationType.MOUNT_CGROUPS, hierarchy); Configuration conf = super.getConf(); mountCGroupsOp.appendArgs(cgroupKVs); PrivilegedOperationExecutor privilegedOperationExecutor = PrivilegedOperationExecutor.getInstance(conf); privilegedOperationExecutor.executePrivilegedOperation(mountCGroupsOp, false); } catch (PrivilegedOperationException e) { int exitCode = e.getExitCode(); LOG.warn("Exception in LinuxContainerExecutor mountCgroups ", e); throw new IOException("Problem mounting cgroups " + cgroupKVs + "; exit code = " + exitCode + " and output: " + e.getOutput(), e); } } LinuxContainerExecutor(); @VisibleForTesting  LinuxContainerExecutor(LinuxContainerRuntime linuxContainerRuntime); @Override void setConf(Configuration conf); @Override void init(); @Override void startLocalizer(LocalizerStartContext ctx); @Override int prepareContainer(ContainerStartContext ctx); @VisibleForTesting void buildMainArgs(List<String> command, String user, String appId,
      String locId, InetSocketAddress nmAddr, List<String> localDirs); @Override int launchContainer(ContainerStartContext ctx); @Override int reacquireContainer(ContainerReacquisitionContext ctx); @Override boolean signalContainer(ContainerSignalContext ctx); @Override void deleteAsUser(DeletionAsUserContext ctx); @Override boolean isContainerAlive(ContainerLivenessContext ctx); void mountCgroups(List<String> cgroupKVs, String hierarchy);  }### Answer:
@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; } }