You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by li...@apache.org on 2020/03/22 13:58:54 UTC

[submarine] branch master updated: SUBMARINE-74. Add tests to TensorFlowServiceSpec class

This is an automated email from the ASF dual-hosted git repository.

liuxun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new c0917c5  SUBMARINE-74. Add tests to TensorFlowServiceSpec class
c0917c5 is described below

commit c0917c5dcc798181ed0292b0e4b3690f3905386c
Author: cchung100m <cc...@cs.ccu.edu.tw>
AuthorDate: Sat Mar 21 21:35:39 2020 +0800

    SUBMARINE-74. Add tests to TensorFlowServiceSpec class
    
    ### What is this PR for?
    
    Add tests to TensorFlowServiceSpec class
    
    ### What type of PR is it?
    [Improvement]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    
    https://issues.apache.org/jira/browse/SUBMARINE-74
    
    ### How should this be tested?
    
    https://travis-ci.org/github/cchung100m/submarine?utm_medium=notification&utm_source=github_status
    
    ### Screenshots (if appropriate)
    
    <img width="984" alt="螢幕快照 2020-03-21 下午9 40 04" src="https://user-images.githubusercontent.com/6762509/77227672-e3514800-6bbc-11ea-9b4f-58ba09272f1a.png">
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: cchung100m <cc...@cs.ccu.edu.tw>
    
    Closes #243 from cchung100m/SUBMARINE-74 and squashes the following commits:
    
    6973e65 [cchung100m] SUBMARINE-74. Add tests to TensorFlowServiceSpec class
---
 .../tensorflow/TensorFlowServiceSpecTest.java      | 95 ++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/submarine-server/server-submitter/submitter-yarnservice/src/test/java/org/apache/submarine/server/submitter/yarnservice/tensorflow/TensorFlowServiceSpecTest.java b/submarine-server/server-submitter/submitter-yarnservice/src/test/java/org/apache/submarine/server/submitter/yarnservice/tensorflow/TensorFlowServiceSpecTest.java
new file mode 100644
index 0000000..270d4a6
--- /dev/null
+++ b/submarine-server/server-submitter/submitter-yarnservice/src/test/java/org/apache/submarine/server/submitter/yarnservice/tensorflow/TensorFlowServiceSpecTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.submarine.server.submitter.yarnservice.tensorflow;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.service.api.records.Component;
+import org.apache.hadoop.yarn.service.api.records.Service;
+import org.apache.submarine.client.cli.param.runjob.TensorFlowRunJobParameters;
+import org.apache.submarine.commons.runtime.MockClientContext;
+import org.apache.submarine.commons.runtime.api.TensorFlowRole;
+import org.apache.submarine.server.submitter.yarnservice.tensorflow.component.ComponentTestCommons;
+import org.apache.submarine.server.submitter.yarnservice.FileSystemOperations;
+import org.apache.submarine.server.submitter.yarnservice.HadoopEnvironmentSetup;
+import org.apache.submarine.server.submitter.yarnservice.ServiceWrapper;
+import org.apache.submarine.server.submitter.yarnservice.utils.Localizer;
+import org.apache.submarine.server.submitter.yarnservice.command.TensorFlowLaunchCommandFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.apache.submarine.client.cli.yarnservice.YarnServiceRunJobCliCommonsTest.DEFAULT_JOB_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Class to test some functionality of {@link TensorFlowServiceSpec}.
+ */
+
+public class TensorFlowServiceSpecTest {
+
+  private ComponentTestCommons testCommons = 
+      new ComponentTestCommons(TensorFlowRole.PRIMARY_WORKER);
+
+  @Before
+  public void setUp() throws IOException {
+    testCommons.setupTensorFlow();
+  }
+
+  @Test
+  public void testTensorFlowhServiceSpec() throws IOException {
+    testCommons = new ComponentTestCommons(TensorFlowRole.PRIMARY_WORKER);
+    testCommons.setupTensorFlow();
+    
+    TensorFlowRunJobParameters parameters = new TensorFlowRunJobParameters();
+    parameters.setWorkerResource(testCommons.resource);
+    parameters.setName("testJobName");
+    parameters.setNumWorkers(1);
+    parameters.setWorkerLaunchCmd("testWorkerLaunchCommand");
+
+    MockClientContext mockClientContext = new MockClientContext(DEFAULT_JOB_NAME);
+    FileSystemOperations fsOperations = new FileSystemOperations(mockClientContext);
+
+    HadoopEnvironmentSetup hadoopEnv = new HadoopEnvironmentSetup(mockClientContext, fsOperations);
+
+    TensorFlowLaunchCommandFactory launchCommandFactory = 
+        new TensorFlowLaunchCommandFactory(hadoopEnv, parameters, new Configuration());
+
+    Localizer localizer = 
+        new Localizer(fsOperations, mockClientContext.getRemoteDirectoryManager(), parameters);
+
+    TensorFlowServiceSpec tensorFlowhServiceSpec = 
+        new TensorFlowServiceSpec(parameters, mockClientContext, fsOperations, 
+            launchCommandFactory, localizer);
+
+    ServiceWrapper serviceWrapper = tensorFlowhServiceSpec.create();
+    Service service = serviceWrapper.getService();
+
+    assertNotNull("Service must not be null!", service);
+    List<Component> components = service.getComponents();
+    assertEquals("Number of components is not correct!", 1, components.size());
+    
+    Component component = components.get(0);
+    assertEquals(1L, (long) component.getNumberOfContainers());
+    assertEquals("./run-PRIMARY_WORKER.sh", component.getLaunchCommand());
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org