@Test
public void testRemoteRootLogDirIsCreatedWithCorrectGroupOwner()
    throws IOException {

  this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
  Path aNewFile = new Path(String.valueOf("tmp"+System.currentTimeMillis()));
  this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, aNewFile.getName());
  LogAggregationService logAggregationService = new LogAggregationService(
      dispatcher, this.context, this.delSrvc, super.dirsHandler);
  logAggregationService.init(this.conf);
  logAggregationService.start();
  ApplicationId appId = ApplicationId.newInstance(
      System.currentTimeMillis(), 1);
  LogAggregationContext contextWithAMAndFailed =
      Records.newRecord(LogAggregationContext.class);
  contextWithAMAndFailed.setLogAggregationPolicyClassName(
      AMOrFailedContainerLogAggregationPolicy.class.getName());
  logAggregationService.handle(new LogHandlerAppStartedEvent(appId,
      this.user, null, this.acls, contextWithAMAndFailed));
  dispatcher.await();
  String targetGroup =
      UserGroupInformation.getLoginUser().getPrimaryGroupName();
  FileSystem fs = FileSystem.get(this.conf);
  FileStatus fileStatus = fs.getFileStatus(aNewFile);
  Assert.assertEquals("The new aggregate file is not successfully created",
      fileStatus.getGroup(), targetGroup);
  fs.delete(aNewFile, true);
  logAggregationService.stop();
}