Repository: incubator-gobblin
Updated Branches:
  refs/heads/master f7a89fb12 -> a35a10f7e


[GOBBLIN-336] Parse cmd options to the single task runner process

Closes #2201 from HappyRay/parse-option-run-helix-
task-in-a-separate-process


Project: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/commit/a35a10f7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/tree/a35a10f7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/diff/a35a10f7

Branch: refs/heads/master
Commit: a35a10f7edf0bfb671e548be5832c995324504ff
Parents: f7a89fb
Author: Ray Yang <[email protected]>
Authored: Tue Dec 12 14:00:19 2017 -0800
Committer: Abhishek Tiwari <[email protected]>
Committed: Tue Dec 12 14:00:19 2017 -0800

----------------------------------------------------------------------
 gobblin-cluster/build.gradle                    |  1 +
 .../GobblinClusterConfigurationKeys.java        |  7 ++
 .../cluster/GobblinClusterException.java        | 24 +++++
 .../gobblin/cluster/SingleTaskRunner.java       | 39 +++++++++
 .../cluster/SingleTaskRunnerBuilder.java        | 43 +++++++++
 .../gobblin/cluster/SingleTaskRunnerMain.java   | 62 +++++++++++++
 .../cluster/SingleTaskRunnerMainOptions.java    | 92 ++++++++++++++++++++
 ...ngleTaskRunnerMainArgumentsDataProvider.java | 29 ++++++
 .../SingleTaskRunnerMainOptionsTest.java        | 66 ++++++++++++++
 .../cluster/SingleTaskRunnerMainTest.java       | 47 ++++++++++
 gradle/scripts/dependencyDefinitions.gradle     |  3 +-
 11 files changed, 412 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/build.gradle
----------------------------------------------------------------------
diff --git a/gobblin-cluster/build.gradle b/gobblin-cluster/build.gradle
index 0cd8eb8..e52854d 100644
--- a/gobblin-cluster/build.gradle
+++ b/gobblin-cluster/build.gradle
@@ -57,6 +57,7 @@ dependencies {
   testCompile externalDependency.testng
   testCompile externalDependency.curatorFramework
   testCompile externalDependency.curatorTest
+  testCompile externalDependency.assertj
 }
 
 task testJar(type: Jar, dependsOn: testClasses) {

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterConfigurationKeys.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterConfigurationKeys.java
 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterConfigurationKeys.java
index 653babf..46a7311 100644
--- 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterConfigurationKeys.java
+++ 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterConfigurationKeys.java
@@ -80,4 +80,11 @@ public class GobblinClusterConfigurationKeys {
   public static final String STOP_TIMEOUT_SECONDS = GOBBLIN_CLUSTER_PREFIX + 
"stopTimeoutSeconds";
   public static final long DEFAULT_STOP_TIMEOUT_SECONDS = 60;
 
+  // Arguments to the single task runner process
+  public static class SingleTaskRunnerCmdOption {
+    public static final String JOB_ID = "job_id";
+    public static final String WORK_UNIT_FILE_PATH = "work_unit_file_path";
+    public static final String JOB_STATE_FILE_PATH = "job_state_file_path";
+    public static final String CLUSTER_CONFIG_FILE_PATH = 
"cluster_config_file_path";
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterException.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterException.java
 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterException.java
new file mode 100644
index 0000000..06161a3
--- /dev/null
+++ 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterException.java
@@ -0,0 +1,24 @@
+/*
+ * 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.gobblin.cluster;
+
+public class GobblinClusterException extends RuntimeException {
+  public GobblinClusterException(final String message, final Throwable cause) {
+    super(message, cause);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunner.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunner.java
 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunner.java
new file mode 100644
index 0000000..6541c1d
--- /dev/null
+++ 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunner.java
@@ -0,0 +1,39 @@
+/*
+ * 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.gobblin.cluster;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+
+class SingleTaskRunner {
+  private final Path clusterConfigFilePath;
+  private final String jobId;
+  private final Path workUnitFilePath;
+
+  SingleTaskRunner(final String clusterConfigFilePath, final String jobId,
+      final String workUnitFilePath) {
+    this.clusterConfigFilePath = Paths.get(clusterConfigFilePath);
+    this.jobId = jobId;
+    this.workUnitFilePath = Paths.get(workUnitFilePath);
+  }
+
+  void run() {
+    // tbd
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerBuilder.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerBuilder.java
 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerBuilder.java
new file mode 100644
index 0000000..6a1ed32
--- /dev/null
+++ 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerBuilder.java
@@ -0,0 +1,43 @@
+/*
+ * 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.gobblin.cluster;
+
+class SingleTaskRunnerBuilder {
+  private String clusterConfigFilePath;
+  private String jobId;
+  private String workUnitFilePath;
+
+  SingleTaskRunnerBuilder setClusterConfigFilePath(final String 
clusterConfigFilePath) {
+    this.clusterConfigFilePath = clusterConfigFilePath;
+    return this;
+  }
+
+  SingleTaskRunnerBuilder setJobId(final String jobId) {
+    this.jobId = jobId;
+    return this;
+  }
+
+  SingleTaskRunnerBuilder setWorkUnitFilePath(final String workUnitFilePath) {
+    this.workUnitFilePath = workUnitFilePath;
+    return this;
+  }
+
+  SingleTaskRunner createSingleTaskRunner() {
+    return new SingleTaskRunner(this.clusterConfigFilePath, this.jobId, 
this.workUnitFilePath);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerMain.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerMain.java
 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerMain.java
new file mode 100644
index 0000000..1c9dac0
--- /dev/null
+++ 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerMain.java
@@ -0,0 +1,62 @@
+/*
+ * 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.gobblin.cluster;
+
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Charsets;
+
+import org.apache.gobblin.util.JvmUtils;
+
+
+class SingleTaskRunnerMain {
+  private static final Logger logger = 
LoggerFactory.getLogger(SingleTaskRunnerMain.class);
+
+  private final SingleTaskRunnerBuilder builder;
+
+  SingleTaskRunnerMain(final SingleTaskRunnerBuilder builder) {
+    this.builder = builder;
+  }
+
+  public static void main(final String[] args)
+      throws Exception {
+    logger.info(JvmUtils.getJvmInputArguments());
+    final SingleTaskRunnerMain runnerMain = new SingleTaskRunnerMain(new 
SingleTaskRunnerBuilder());
+    try {
+      runnerMain.run(args);
+    } catch (final Exception e) {
+      logger.error("Got an exception running a single task.", e);
+      System.exit(1);
+    }
+  }
+
+  void run(final String[] args) {
+    final OutputStreamWriter streamWriter = new OutputStreamWriter(System.out, 
Charsets.UTF_8);
+    final PrintWriter writer = new PrintWriter(streamWriter, true);
+    final SingleTaskRunnerMainOptions options = new 
SingleTaskRunnerMainOptions(args, writer);
+    final SingleTaskRunner runner =
+        
this.builder.setClusterConfigFilePath(options.getClusterConfigFilePath()).setJobId(options.getJobId())
+            .setWorkUnitFilePath(options.getWorkUnitFilePath())
+            .createSingleTaskRunner();
+    runner.run();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerMainOptions.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerMainOptions.java
 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerMainOptions.java
new file mode 100644
index 0000000..60ac61f
--- /dev/null
+++ 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/SingleTaskRunnerMainOptions.java
@@ -0,0 +1,92 @@
+/*
+ * 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.gobblin.cluster;
+
+import java.io.PrintWriter;
+import java.util.Map;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+import static 
org.apache.gobblin.cluster.GobblinClusterConfigurationKeys.SingleTaskRunnerCmdOption.CLUSTER_CONFIG_FILE_PATH;
+import static 
org.apache.gobblin.cluster.GobblinClusterConfigurationKeys.SingleTaskRunnerCmdOption.JOB_ID;
+import static 
org.apache.gobblin.cluster.GobblinClusterConfigurationKeys.SingleTaskRunnerCmdOption.WORK_UNIT_FILE_PATH;
+
+
+class SingleTaskRunnerMainOptions {
+  private static final Logger logger = 
LoggerFactory.getLogger(SingleTaskRunnerMainOptions.class);
+  private static final ImmutableMap<String, String> OPTIONS_MAP = ImmutableMap
+      .of(JOB_ID, "job id", WORK_UNIT_FILE_PATH, "work unit file path", 
CLUSTER_CONFIG_FILE_PATH,
+          "cluster configuration file path");
+  private static final int CHARACTERS_PER_LINE = 80;
+
+  private final PrintWriter writer;
+  private CommandLine cmd;
+  private Options options;
+
+  SingleTaskRunnerMainOptions(final String[] args, final PrintWriter writer) {
+    this.writer = writer;
+    initCmdLineOptions(args);
+  }
+
+  private void initCmdLineOptions(final String[] args) {
+    this.options = buildExpectedOptions();
+    try {
+      this.cmd = new DefaultParser().parse(this.options, args);
+    } catch (final ParseException e) {
+      logger.error("failed to parse command options.", e);
+      printUsage(this.options);
+      throw new GobblinClusterException("Failed to parse command line 
options", e);
+    }
+  }
+
+  private Options buildExpectedOptions() {
+    final Options options = new Options();
+    for (final Map.Entry<String, String> entry : OPTIONS_MAP.entrySet()) {
+      final Option option =
+          
Option.builder(null).required(true).longOpt(entry.getKey()).desc(entry.getValue()).hasArg().build();
+      options.addOption(option);
+    }
+    return options;
+  }
+
+  private void printUsage(final Options options) {
+    final HelpFormatter formatter = new HelpFormatter();
+    formatter.printUsage(this.writer, CHARACTERS_PER_LINE, 
SingleTaskRunnerMain.class.getSimpleName(), options);
+  }
+
+  String getJobId() {
+    return this.cmd.getOptionValue(JOB_ID);
+  }
+
+  String getWorkUnitFilePath() {
+    return this.cmd.getOptionValue(WORK_UNIT_FILE_PATH);
+  }
+
+  String getClusterConfigFilePath() {
+    return this.cmd.getOptionValue(CLUSTER_CONFIG_FILE_PATH);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainArgumentsDataProvider.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainArgumentsDataProvider.java
 
b/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainArgumentsDataProvider.java
new file mode 100644
index 0000000..a535151
--- /dev/null
+++ 
b/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainArgumentsDataProvider.java
@@ -0,0 +1,29 @@
+/*
+ * 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.gobblin.cluster;
+
+class SingleTaskRunnerMainArgumentsDataProvider {
+  static final String TEST_JOB_ID = "1";
+  static final String TEST_WORKUNIT = "/workunit.wu";
+  static final String TEST_CLUSTER_CONF = "/cluster.conf";
+
+  static String[] getArgs() {
+    return new String[]{"--job_id", TEST_JOB_ID, "--work_unit_file_path", 
TEST_WORKUNIT,
+        "--cluster_config_file_path", TEST_CLUSTER_CONF};
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainOptionsTest.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainOptionsTest.java
 
b/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainOptionsTest.java
new file mode 100644
index 0000000..c601d56
--- /dev/null
+++ 
b/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainOptionsTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.gobblin.cluster;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static 
org.apache.gobblin.cluster.SingleTaskRunnerMainArgumentsDataProvider.TEST_CLUSTER_CONF;
+import static 
org.apache.gobblin.cluster.SingleTaskRunnerMainArgumentsDataProvider.TEST_JOB_ID;
+import static 
org.apache.gobblin.cluster.SingleTaskRunnerMainArgumentsDataProvider.TEST_WORKUNIT;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class SingleTaskRunnerMainOptionsTest {
+
+  private PrintWriter writer;
+  private StringWriter stringWriter;
+
+  @BeforeMethod
+  public void setUp() {
+    this.stringWriter = new StringWriter();
+    this.writer = new PrintWriter(this.stringWriter, true);
+  }
+
+  @Test
+  public void correctCmdLineShouldReturnAllValues() {
+    final String[] args = SingleTaskRunnerMainArgumentsDataProvider.getArgs();
+    final SingleTaskRunnerMainOptions options = new 
SingleTaskRunnerMainOptions(args, this.writer);
+    final String jobId = options.getJobId();
+    final String workUnitFilePath = options.getWorkUnitFilePath();
+    final String clusterConfigFilePath = options.getClusterConfigFilePath();
+
+    assertThat(jobId).isEqualTo(TEST_JOB_ID);
+    assertThat(workUnitFilePath).isEqualTo(TEST_WORKUNIT);
+    assertThat(clusterConfigFilePath).isEqualTo(TEST_CLUSTER_CONF);
+  }
+
+  @Test
+  public void missingOptionShouldThrow() {
+    final String[] args = {};
+
+    assertThatThrownBy(() -> new SingleTaskRunnerMainOptions(args, 
this.writer))
+        .isInstanceOf(GobblinClusterException.class);
+
+    final String output = this.stringWriter.toString();
+    assertThat(output).contains("usage: SingleTaskRunnerMain");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainTest.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainTest.java
 
b/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainTest.java
new file mode 100644
index 0000000..f10b2a5
--- /dev/null
+++ 
b/gobblin-cluster/src/test/java/org/apache/gobblin/cluster/SingleTaskRunnerMainTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.gobblin.cluster;
+
+import org.testng.annotations.Test;
+
+import static 
org.apache.gobblin.cluster.SingleTaskRunnerMainArgumentsDataProvider.TEST_CLUSTER_CONF;
+import static 
org.apache.gobblin.cluster.SingleTaskRunnerMainArgumentsDataProvider.TEST_JOB_ID;
+import static 
org.apache.gobblin.cluster.SingleTaskRunnerMainArgumentsDataProvider.TEST_WORKUNIT;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+
+public class SingleTaskRunnerMainTest {
+
+  @Test
+  public void testRun() {
+    final SingleTaskRunnerBuilder builder = spy(SingleTaskRunnerBuilder.class);
+    final SingleTaskRunner taskRunner = mock(SingleTaskRunner.class);
+    doReturn(taskRunner).when(builder).createSingleTaskRunner();
+
+    final SingleTaskRunnerMain runnerMain = new SingleTaskRunnerMain(builder);
+    runnerMain.run(SingleTaskRunnerMainArgumentsDataProvider.getArgs());
+
+    verify(builder).setClusterConfigFilePath(TEST_CLUSTER_CONF);
+    verify(builder).setJobId(TEST_JOB_ID);
+    verify(builder).setWorkUnitFilePath(TEST_WORKUNIT);
+    verify(taskRunner).run();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a35a10f7/gradle/scripts/dependencyDefinitions.gradle
----------------------------------------------------------------------
diff --git a/gradle/scripts/dependencyDefinitions.gradle 
b/gradle/scripts/dependencyDefinitions.gradle
index 096d107..d138a55 100644
--- a/gradle/scripts/dependencyDefinitions.gradle
+++ b/gradle/scripts/dependencyDefinitions.gradle
@@ -177,7 +177,8 @@ ext.externalDependency = [
         "log4j:log4j:" + log4jVersion,
         "log4j:apache-log4j-extras:" + log4jVersion
     ],
-    "postgresConnector": "org.postgresql:postgresql:42.1.4"
+    "postgresConnector": "org.postgresql:postgresql:42.1.4",
+    "assertj": 'org.assertj:assertj-core:3.8.0',
 ]
 
 if (!isDefaultEnvironment)

Reply via email to