[GitHub] [hadoop] szilard-nemeth commented on a diff in pull request #4439: YARN-11182. Refactor TestAggregatedLogDeletionService: 2nd phase

2022-06-19 Thread GitBox


szilard-nemeth commented on code in PR #4439:
URL: https://github.com/apache/hadoop/pull/4439#discussion_r901137867


##
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/LogAggregationTestcase.java:
##
@@ -0,0 +1,416 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.logaggregation.testutils;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FilterFileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.util.Sets;
+import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService;
+import 
org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.AppDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.*;

Review Comment:
   fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] szilard-nemeth commented on a diff in pull request #4439: YARN-11182. Refactor TestAggregatedLogDeletionService: 2nd phase

2022-06-19 Thread GitBox


szilard-nemeth commented on code in PR #4439:
URL: https://github.com/apache/hadoop/pull/4439#discussion_r901137746


##
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/LogAggregationTestUtils.java:
##
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.logaggregation;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import 
org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController;
+
+import java.util.List;
+
+import static org.apache.hadoop.yarn.conf.YarnConfiguration.*;
+
+public class LogAggregationTestUtils {
+  public static final String REMOTE_LOG_ROOT = "target/app-logs/";
+
+  public static void enableFileControllers(Configuration conf,
+  List> fileControllers,
+  List fileControllerNames) {
+enableFcs(conf, REMOTE_LOG_ROOT, fileControllers, fileControllerNames);
+  }
+
+  public static void enableFileControllers(Configuration conf,
+   String remoteLogRoot,
+   List> fileControllers,
+   List fileControllerNames) {
+enableFcs(conf, remoteLogRoot, fileControllers, fileControllerNames);
+  }
+
+
+  private static void enableFcs(Configuration conf,
+String remoteLogRoot,
+List> fileControllers,
+List fileControllerNames) {
+conf.set(YarnConfiguration.LOG_AGGREGATION_FILE_FORMATS,

Review Comment:
   fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] szilard-nemeth commented on a diff in pull request #4439: YARN-11182. Refactor TestAggregatedLogDeletionService: 2nd phase

2022-06-15 Thread GitBox


szilard-nemeth commented on code in PR #4439:
URL: https://github.com/apache/hadoop/pull/4439#discussion_r897929690


##
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogDeletionService.java:
##
@@ -138,82 +97,35 @@ public void testDeletion() throws Exception {
 long toKeepTime = now - (1500 * 1000);
 
 Configuration conf = setupConfiguration(1800, -1);
-
-Path rootPath = new Path(ROOT);
-FileSystem rootFs = rootPath.getFileSystem(conf);
-FileSystem mockFs = ((FilterFileSystem)rootFs).getRawFileSystem();
-
-Path remoteRootLogPath = new Path(REMOTE_ROOT_LOG_DIR);
-PathWithFileStatus userDir = 
createDirLogPathWithFileStatus(remoteRootLogPath, USER_ME,
-toKeepTime);
-
-when(mockFs.listStatus(remoteRootLogPath)).thenReturn(new 
FileStatus[]{userDir.fileStatus});
-
-ApplicationId appId1 = ApplicationId.newInstance(now, 1);
-ApplicationId appId2 = ApplicationId.newInstance(now, 2);
-ApplicationId appId3 = ApplicationId.newInstance(now, 3);
-ApplicationId appId4 = ApplicationId.newInstance(now, 4);
-
-PathWithFileStatus suffixDir = 
createDirLogPathWithFileStatus(userDir.path, NEW_SUFFIX,
-toDeleteTime);
-PathWithFileStatus bucketDir = 
createDirLogPathWithFileStatus(remoteRootLogPath, SUFFIX,
-toDeleteTime);
-
-PathWithFileStatus app1 = 
createPathWithFileStatusForAppId(remoteRootLogPath, appId1,
-USER_ME, SUFFIX, toDeleteTime);
-PathWithFileStatus app2 = 
createPathWithFileStatusForAppId(remoteRootLogPath, appId2,
-USER_ME, SUFFIX, toDeleteTime);
-PathWithFileStatus app3 = 
createPathWithFileStatusForAppId(remoteRootLogPath, appId3,
-USER_ME, SUFFIX, toDeleteTime);
-PathWithFileStatus app4 = 
createPathWithFileStatusForAppId(remoteRootLogPath, appId4,
-USER_ME, SUFFIX, toDeleteTime);
-
-when(mockFs.listStatus(userDir.path)).thenReturn(new FileStatus[] 
{suffixDir.fileStatus});
-when(mockFs.listStatus(suffixDir.path)).thenReturn(new FileStatus[] 
{bucketDir.fileStatus});
-when(mockFs.listStatus(bucketDir.path)).thenReturn(new FileStatus[] {
-app1.fileStatus, app2.fileStatus, app3.fileStatus, app4.fileStatus});
-
-PathWithFileStatus app2Log1 = createFileLogPathWithFileStatus(app2.path, 
DIR_HOST1,
-toDeleteTime);
-PathWithFileStatus app2Log2 = createFileLogPathWithFileStatus(app2.path, 
DIR_HOST2, toKeepTime);
-PathWithFileStatus app3Log1 = createFileLogPathWithFileStatus(app3.path, 
DIR_HOST1,
-toDeleteTime);
-PathWithFileStatus app3Log2 = createFileLogPathWithFileStatus(app3.path, 
DIR_HOST2,
-toDeleteTime);
-PathWithFileStatus app4Log1 = createFileLogPathWithFileStatus(app4.path, 
DIR_HOST1,
-toDeleteTime);
-PathWithFileStatus app4Log2 = createFileLogPathWithFileStatus(app4.path, 
DIR_HOST2, toKeepTime);
-
-when(mockFs.listStatus(app1.path)).thenReturn(new FileStatus[]{});
-when(mockFs.listStatus(app2.path)).thenReturn(new 
FileStatus[]{app2Log1.fileStatus,
-app2Log2.fileStatus});
-when(mockFs.listStatus(app3.path)).thenReturn(new 
FileStatus[]{app3Log1.fileStatus,
-app3Log2.fileStatus});
-when(mockFs.listStatus(app4.path)).thenReturn(new 
FileStatus[]{app4Log1.fileStatus,
-app4Log2.fileStatus});
-when(mockFs.delete(app3.path, true)).thenThrow(
-new AccessControlException("Injected Error\nStack Trace :("));
-
-final List finishedApplications = 
Collections.unmodifiableList(
-Arrays.asList(appId1, appId2, appId3));
-final List runningApplications = 
Collections.singletonList(appId4);
-
-AggregatedLogDeletionService deletionService =
-new AggregatedLogDeletionServiceForTest(runningApplications, 
finishedApplications);
-deletionService.init(conf);
-deletionService.start();
-
-int timeout = 2000;
-verify(mockFs, timeout(timeout)).delete(app1.path, true);
-verify(mockFs, timeout(timeout).times(0)).delete(app2.path, true);
-verify(mockFs, timeout(timeout)).delete(app3.path, true);
-verify(mockFs, timeout(timeout).times(0)).delete(app4.path, true);
-verify(mockFs, timeout(timeout)).delete(app4Log1.path, true);
-verify(mockFs, timeout(timeout).times(0)).delete(app4Log2.path, true);
-
-deletionService.stop();
+long timeout = 2000L;
+LogAggregationFilesBuilder.create(conf)
+.withRootPath(ROOT)
+.withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
+.withUserDir(USER_ME, toKeepTime)
+.withSuffixDir(SUFFIX, toDeleteTime)
+.withBucketDir(toDeleteTime)
+.withApps(new 
LogAggregationFilesBuilder.AppDescriptor(toDeleteTime, new Pair[] {}),
+new LogAggregationFilesBuilder.AppDescriptor(toDeleteTime,
+Pair.of(DIR_HOST1, toDeleteTime),
+