[ 
https://issues.apache.org/jira/browse/BEAM-4176?focusedWorklogId=126801&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-126801
 ]

ASF GitHub Bot logged work on BEAM-4176:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Jul/18 19:03
            Start Date: 24/Jul/18 19:03
    Worklog Time Spent: 10m 
      Work Description: angoenka commented on a change in pull request #5935: 
[BEAM-4176] Initial implementation for running portable runner tests
URL: https://github.com/apache/beam/pull/5935#discussion_r204862716
 
 

 ##########
 File path: 
runners/reference/java/src/main/java/org/apache/beam/runners/reference/testing/TestPortableRunner.java
 ##########
 @@ -0,0 +1,126 @@
+/*
+ * 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.beam.runners.reference.testing;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import org.apache.beam.runners.reference.PortableRunner;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.PipelineResult;
+import org.apache.beam.sdk.PipelineResult.State;
+import org.apache.beam.sdk.PipelineRunner;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.sdk.options.PortablePipelineOptions;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.apache.beam.sdk.util.common.ReflectHelpers;
+import org.hamcrest.Matchers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link TestPortableRunner} is a pipeline runner that wraps a {@link 
PortableRunner} when running
+ * tests against the {@link TestPipeline}.
+ *
+ * <p>This runner requires a JobServerDriver with following methods.
+ *
+ * <ul>
+ *   <li>public static Object fromParams(String... params)
+ *   <li>public String start() // Start JobServer and returns the JobServer 
host and port.
+ *   <li>public void start() // Stop the JobServer and free all resources.
+ * </ul>
+ *
+ * @see TestPipeline
+ */
+public class TestPortableRunner extends PipelineRunner<PipelineResult> {
+  private static final Logger LOG = 
LoggerFactory.getLogger(TestPortableRunner.class);
+  private static final ObjectMapper MAPPER =
+      new ObjectMapper()
+          
.registerModules(ObjectMapper.findModules(ReflectHelpers.findClassLoader()));
+  private final PortablePipelineOptions options;
+
+  private TestPortableRunner(PortablePipelineOptions options) {
+    this.options = options;
+  }
+
+  public static TestPortableRunner fromOptions(PipelineOptions options) {
+    return new TestPortableRunner(options.as(PortablePipelineOptions.class));
+  }
+
+  @Override
+  public PipelineResult run(Pipeline pipeline) {
+    TestPortablePipelineOptions testPortablePipelineOptions =
+        options.as(TestPortablePipelineOptions.class);
+    String jobServerHostPort;
+    Object jobServerDriver;
+    Class<?> jobServerDriverClass;
+    try {
+      jobServerDriverClass =
+          Class.forName(
+              testPortablePipelineOptions.getJobServerDriver(),
+              true,
+              ReflectHelpers.findClassLoader());
+      String[] parameters;
+      try {
+        parameters =
+            MAPPER.readValue(testPortablePipelineOptions.getJobServerConfig(), 
String[].class);
+      } catch (IOException e) {
+        throw new IllegalArgumentException(
+            String.format(
+                "Arguments to jobServers should be a comma separated list of 
strings. Provided %s",
+                testPortablePipelineOptions.getJobServerDriver()));
+      }
+      try {
+        jobServerDriver =
+            jobServerDriverClass
+                .getMethod("fromParams", String[].class)
 
 Review comment:
   SG

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 126801)

> Java: Portable batch runner passes all ValidatesRunner tests that 
> non-portable runner passes
> --------------------------------------------------------------------------------------------
>
>                 Key: BEAM-4176
>                 URL: https://issues.apache.org/jira/browse/BEAM-4176
>             Project: Beam
>          Issue Type: Bug
>          Components: runner-flink
>            Reporter: Ben Sidhom
>            Priority: Major
>          Time Spent: 3h 40m
>  Remaining Estimate: 0h
>
> We need this as a sanity check that runner execution is correct.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to