|
@@ -234,31 +234,47 @@ public class TestLogAggregationService extends BaseContainerManagerTest {
|
|
|
// ensure filesystems were closed
|
|
|
verify(logAggregationService).closeFileSystems(
|
|
|
any(UserGroupInformation.class));
|
|
|
- List<Path> dirList = new ArrayList<>();
|
|
|
- dirList.add(new Path(app1LogDir.toURI()));
|
|
|
- verify(delSrvc, times(2)).delete(argThat(new FileDeletionMatcher(
|
|
|
- delSrvc, user, null, dirList)));
|
|
|
-
|
|
|
- String containerIdStr = container11.toString();
|
|
|
- File containerLogDir = new File(app1LogDir, containerIdStr);
|
|
|
- int count = 0;
|
|
|
- int maxAttempts = 50;
|
|
|
- for (String fileType : new String[] { "stdout", "stderr", "syslog" }) {
|
|
|
- File f = new File(containerLogDir, fileType);
|
|
|
- count = 0;
|
|
|
- while ((f.exists()) && (count < maxAttempts)) {
|
|
|
- count++;
|
|
|
- Thread.sleep(100);
|
|
|
+ boolean filesShouldBeDeleted =
|
|
|
+ this.conf.getBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLE_LOCAL_CLEANUP,
|
|
|
+ YarnConfiguration.DEFAULT_LOG_AGGREGATION_ENABLE_LOCAL_CLEANUP);
|
|
|
+ if (filesShouldBeDeleted) {
|
|
|
+ List<Path> dirList = new ArrayList<>();
|
|
|
+ dirList.add(new Path(app1LogDir.toURI()));
|
|
|
+ verify(delSrvc, times(2)).delete(argThat(new FileDeletionMatcher(
|
|
|
+ delSrvc, user, null, dirList)));
|
|
|
+
|
|
|
+ String containerIdStr = container11.toString();
|
|
|
+ File containerLogDir = new File(app1LogDir, containerIdStr);
|
|
|
+ int count = 0;
|
|
|
+ int maxAttempts = 50;
|
|
|
+ for (String fileType : new String[]{"stdout", "stderr", "syslog"}) {
|
|
|
+ File f = new File(containerLogDir, fileType);
|
|
|
+ count = 0;
|
|
|
+ while ((f.exists()) && (count < maxAttempts)) {
|
|
|
+ count++;
|
|
|
+ Thread.sleep(100);
|
|
|
+ }
|
|
|
+ Assert.assertFalse("File [" + f + "] was not deleted", f.exists());
|
|
|
}
|
|
|
- Assert.assertFalse("File [" + f + "] was not deleted", f.exists());
|
|
|
- }
|
|
|
- count = 0;
|
|
|
- while ((app1LogDir.exists()) && (count < maxAttempts)) {
|
|
|
- count++;
|
|
|
- Thread.sleep(100);
|
|
|
+ Assert.assertFalse("Directory [" + app1LogDir + "] was not deleted",
|
|
|
+ app1LogDir.exists());
|
|
|
+ } else {
|
|
|
+ List<Path> dirList = new ArrayList<>();
|
|
|
+ dirList.add(new Path(app1LogDir.toURI()));
|
|
|
+ verify(delSrvc, never()).delete(argThat(new FileDeletionMatcher(
|
|
|
+ delSrvc, user, null, dirList)));
|
|
|
+
|
|
|
+ String containerIdStr = container11.toString();
|
|
|
+ File containerLogDir = new File(app1LogDir, containerIdStr);
|
|
|
+ Thread.sleep(5000);
|
|
|
+ for (String fileType : new String[]{"stdout", "stderr", "syslog"}) {
|
|
|
+ File f = new File(containerLogDir, fileType);
|
|
|
+ Assert.assertTrue("File [" + f + "] was not deleted", f.exists());
|
|
|
+ }
|
|
|
+ Assert.assertTrue("Directory [" + app1LogDir + "] was not deleted",
|
|
|
+ app1LogDir.exists());
|
|
|
}
|
|
|
- Assert.assertFalse("Directory [" + app1LogDir + "] was not deleted",
|
|
|
- app1LogDir.exists());
|
|
|
+ delSrvc.stop();
|
|
|
|
|
|
Path logFilePath = logAggregationService
|
|
|
.getLogAggregationFileController(conf)
|
|
@@ -297,6 +313,20 @@ public class TestLogAggregationService extends BaseContainerManagerTest {
|
|
|
verifyLocalFileDeletion(logAggregationService);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testLocalFileRemainsAfterUploadOnCleanupDisable() throws Exception {
|
|
|
+ this.delSrvc = new DeletionService(createContainerExecutor());
|
|
|
+ delSrvc = spy(delSrvc);
|
|
|
+ this.delSrvc.init(conf);
|
|
|
+ this.conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLE_LOCAL_CLEANUP, false);
|
|
|
+ this.conf.set(YarnConfiguration.NM_LOG_DIRS, localLogDir.getAbsolutePath());
|
|
|
+ this.conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
|
|
|
+ this.remoteRootLogDir.getAbsolutePath());
|
|
|
+ LogAggregationService logAggregationService = spy(
|
|
|
+ new LogAggregationService(dispatcher, this.context, this.delSrvc, super.dirsHandler));
|
|
|
+ verifyLocalFileDeletion(logAggregationService);
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testLocalFileDeletionOnDiskFull() throws Exception {
|
|
|
this.delSrvc = new DeletionService(createContainerExecutor());
|