[ https://issues.apache.org/jira/browse/BEAM-6747?focusedWorklogId=225085&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-225085 ]
ASF GitHub Bot logged work on BEAM-6747: ---------------------------------------- Author: ASF GitHub Bot Created on: 09/Apr/19 16:04 Start Date: 09/Apr/19 16:04 Worklog Time Spent: 10m Work Description: chamikaramj commented on pull request #7954: [BEAM-6747] Adding ExternalTransform in JavaSDK URL: https://github.com/apache/beam/pull/7954#discussion_r273567713 ########## File path: runners/core-construction-java/src/test/java/org/apache/beam/runners/core/construction/ExternalTest.java ########## @@ -0,0 +1,197 @@ +/* + * 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.core.construction; + +import com.google.auto.service.AutoService; +import java.io.IOException; +import java.io.Serializable; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import org.apache.beam.runners.core.construction.expansion.ExpansionService; +import org.apache.beam.sdk.testing.PAssert; +import org.apache.beam.sdk.testing.TestPipeline; +import org.apache.beam.sdk.testing.UsesCrossLanguageTransforms; +import org.apache.beam.sdk.testing.ValidatesRunner; +import org.apache.beam.sdk.transforms.Create; +import org.apache.beam.sdk.transforms.DoFn; +import org.apache.beam.sdk.transforms.Filter; +import org.apache.beam.sdk.transforms.MapElements; +import org.apache.beam.sdk.transforms.ParDo; +import org.apache.beam.sdk.values.PCollection; +import org.apache.beam.sdk.values.PCollectionTuple; +import org.apache.beam.sdk.values.TupleTag; +import org.apache.beam.sdk.values.TupleTagList; +import org.apache.beam.sdk.values.TypeDescriptor; +import org.apache.beam.sdk.values.TypeDescriptors; +import org.apache.beam.vendor.grpc.v1p13p1.io.grpc.ConnectivityState; +import org.apache.beam.vendor.grpc.v1p13p1.io.grpc.ManagedChannel; +import org.apache.beam.vendor.grpc.v1p13p1.io.grpc.ManagedChannelBuilder; +import org.apache.beam.vendor.grpc.v1p13p1.io.grpc.Server; +import org.apache.beam.vendor.grpc.v1p13p1.io.grpc.ServerBuilder; +import org.apache.beam.vendor.guava.v20_0.com.google.common.collect.ImmutableMap; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Test External transforms. */ +@RunWith(JUnit4.class) +public class ExternalTest implements Serializable { + @Rule public transient TestPipeline testPipeline = TestPipeline.create(); + + private static final String TEST_URN_SIMPLE = "simple"; + private static final String TEST_URN_LE = "le"; + private static final String TEST_URN_MULTI = "multi"; + + private static String pythonServerCommand; + private static Integer expansionPort; + private static String localExpansionAddr; + private static Server localExpansionServer; + + @BeforeClass + public static void setUp() throws IOException { + pythonServerCommand = System.getProperty("pythonTestExpansionCommand"); + expansionPort = Integer.valueOf(System.getProperty("expansionPort")); + int localExpansionPort = expansionPort + 100; + localExpansionAddr = String.format("localhost:%s", localExpansionPort); + + localExpansionServer = + ServerBuilder.forPort(localExpansionPort).addService(new ExpansionService()).build(); + localExpansionServer.start(); + } + + @AfterClass + public static void tearDown() { + localExpansionServer.shutdownNow(); + } + + @Test + @Category({ValidatesRunner.class, UsesCrossLanguageTransforms.class}) + public void expandSingleTest() { + PCollection<Integer> col = + testPipeline + .apply(Create.of(1, 2, 3)) + .apply(External.of(TEST_URN_SIMPLE, new byte[] {}, localExpansionAddr)); + PAssert.that(col).containsInAnyOrder(2, 3, 4); + testPipeline.run(); + } + + @Test + @Category({ValidatesRunner.class, UsesCrossLanguageTransforms.class}) + public void expandMultipleTest() { Review comment: Do we have a test that uses Python transforms from Java ? These tests seems to be using Java transforms defined below, right ? ---------------------------------------------------------------- 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 Issue Time Tracking ------------------- Worklog Id: (was: 225085) Time Spent: 5h 10m (was: 5h) > Adding ExternalTransform in JavaSDK > ----------------------------------- > > Key: BEAM-6747 > URL: https://issues.apache.org/jira/browse/BEAM-6747 > Project: Beam > Issue Type: Improvement > Components: runner-core > Reporter: Heejong Lee > Assignee: Heejong Lee > Priority: Major > Time Spent: 5h 10m > Remaining Estimate: 0h > > Adding Java counterpart of Python ExternalTransform for testing Python > transforms from pipelines in Java SDK. -- This message was sent by Atlassian JIRA (v7.6.3#76005)