iwasakims commented on a change in pull request #2581:
URL: https://github.com/apache/hadoop/pull/2581#discussion_r553140343



##########
File path: 
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDSTimelineV20.java
##########
@@ -0,0 +1,487 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.applications.distributedshell;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.ContainerReport;
+import org.apache.hadoop.yarn.api.records.ExecutionType;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity;
+import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType;
+import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent;
+import 
org.apache.hadoop.yarn.applications.distributedshell.ApplicationMaster.DSEvent;
+import org.apache.hadoop.yarn.client.api.YarnClient;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.server.metrics.AppAttemptMetricsConstants;
+import org.apache.hadoop.yarn.server.metrics.ApplicationMetricsConstants;
+import org.apache.hadoop.yarn.server.metrics.ContainerMetricsConstants;
+import 
org.apache.hadoop.yarn.server.timelineservice.collector.PerNodeTimelineCollectorsAuxService;
+import 
org.apache.hadoop.yarn.server.timelineservice.storage.FileSystemTimelineReaderImpl;
+import 
org.apache.hadoop.yarn.server.timelineservice.storage.FileSystemTimelineWriterImpl;
+import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
+
+/**
+ * Unit tests implementations for distributed shell on TimeLineV2.
+ */
+public class TestDSTimelineV20 extends DistributedShellBaseTest {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestDSTimelineV20.class);
+  private static final String TIMELINE_AUX_SERVICE_NAME = "timeline_collector";
+
+  @Override
+  protected float getTimelineVersion() {
+    return 2.0f;
+  }
+
+  @Override
+  protected void customizeConfiguration(
+      YarnConfiguration config) throws Exception {
+    // set version to 2
+    config.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION,
+        getTimelineVersion());
+    // disable v1 timeline server since we no longer have a server here
+    // enable aux-service based timeline aggregators
+    config.set(YarnConfiguration.NM_AUX_SERVICES, TIMELINE_AUX_SERVICE_NAME);
+    config.set(YarnConfiguration.NM_AUX_SERVICES + "." +
+            TIMELINE_AUX_SERVICE_NAME + ".class",
+        PerNodeTimelineCollectorsAuxService.class.getName());
+    config.setClass(YarnConfiguration.TIMELINE_SERVICE_WRITER_CLASS,
+        FileSystemTimelineWriterImpl.class,
+        org.apache.hadoop.yarn.server.timelineservice.storage.
+            TimelineWriter.class);
+    setTimelineV2StorageDir();
+    // set the file system timeline writer storage directory
+    config.set(FileSystemTimelineWriterImpl.TIMELINE_SERVICE_STORAGE_DIR_ROOT,
+        getTimelineV2StorageDir());
+  }
+
+  @Test
+  public void testDSShellWithEnforceExecutionType() throws Exception {
+    YarnClient yarnClient = null;
+    AtomicReference<Throwable> thrownError = new AtomicReference<>(null);
+    AtomicReference<List<ContainerReport>> containersListRef =
+        new AtomicReference<>(null);
+    AtomicReference<ApplicationAttemptId> appAttemptIdRef =
+        new AtomicReference<>(null);
+    AtomicReference<ApplicationAttemptReport> appAttemptReportRef =
+        new AtomicReference<>(null);
+
+    setAndGetDSClient(new Configuration(getYarnClusterConfiguration()));
+    try {
+      String[] args = createArgumentsWithAppName(
+          "--num_containers",
+          "2",
+          "--master_memory",
+          "512",
+          "--master_vcores",
+          "2",
+          "--container_memory",
+          "128",
+          "--container_vcores",
+          "1",
+          "--shell_command",
+          getListCommand(),
+          "--container_type",
+          "OPPORTUNISTIC",
+          "--enforce_execution_type"
+      );
+      getDSClient().init(args);
+      Thread dsClientRunner = new Thread(() -> {
+        try {
+          getDSClient().run();
+        } catch (Exception e) {
+          throw new RuntimeException(e);
+        }
+      });
+      dsClientRunner.start();
+
+      yarnClient = YarnClient.createYarnClient();
+      yarnClient.init(new Configuration(getYarnClusterConfiguration()));
+      yarnClient.start();
+
+      waitForContainersLaunch(yarnClient, 2, appAttemptReportRef,

Review comment:
       nContainers should be 3 if need to take AM container into account?




----------------------------------------------------------------
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.

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

Reply via email to