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

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

                Author: ASF GitHub Bot
            Created on: 12/Sep/18 16:24
            Start Date: 12/Sep/18 16:24
    Worklog Time Spent: 10m 
      Work Description: pabloem closed pull request #6371: [BEAM-5341] create 
IT test for TfIdf example
URL: https://github.com/apache/beam/pull/6371
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/examples/java/src/main/java/org/apache/beam/examples/complete/TfIdf.java 
b/examples/java/src/main/java/org/apache/beam/examples/complete/TfIdf.java
index e153d9d8f7a..a5d2c7e8a29 100644
--- a/examples/java/src/main/java/org/apache/beam/examples/complete/TfIdf.java
+++ b/examples/java/src/main/java/org/apache/beam/examples/complete/TfIdf.java
@@ -415,8 +415,7 @@ public void processElement(ProcessContext c) {
     }
   }
 
-  public static void main(String[] args) throws Exception {
-    Options options = 
PipelineOptionsFactory.fromArgs(args).withValidation().as(Options.class);
+  static void runTfIdf(Options options) throws Exception {
     Pipeline pipeline = Pipeline.create(options);
     pipeline.getCoderRegistry().registerCoderForClass(URI.class, 
StringDelegateCoder.of(URI.class));
 
@@ -427,4 +426,10 @@ public static void main(String[] args) throws Exception {
 
     pipeline.run().waitUntilFinish();
   }
+
+  public static void main(String[] args) throws Exception {
+    Options options = 
PipelineOptionsFactory.fromArgs(args).withValidation().as(Options.class);
+
+    runTfIdf(options);
+  }
 }
diff --git 
a/examples/java/src/test/java/org/apache/beam/examples/complete/TfIdfIT.java 
b/examples/java/src/test/java/org/apache/beam/examples/complete/TfIdfIT.java
new file mode 100644
index 00000000000..21ec6b22cc9
--- /dev/null
+++ b/examples/java/src/test/java/org/apache/beam/examples/complete/TfIdfIT.java
@@ -0,0 +1,74 @@
+/*
+ * 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.examples.complete;
+
+import java.util.Date;
+import java.util.regex.Pattern;
+import org.apache.beam.examples.complete.TfIdf.Options;
+import org.apache.beam.sdk.io.FileSystems;
+import org.apache.beam.sdk.io.fs.ResolveOptions.StandardResolveOptions;
+import org.apache.beam.sdk.options.PipelineOptionsFactory;
+import org.apache.beam.sdk.testing.FileChecksumMatcher;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.apache.beam.sdk.testing.TestPipelineOptions;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Integration test for TfIdf example. */
+@RunWith(JUnit4.class)
+public class TfIdfIT {
+
+  private static final String DEFAULT_INPUT = 
"gs://apache-beam-samples/shakespeare/";
+  private static final String EXPECTED_OUTPUT_CHECKSUM = 
"f072786dde51dc09fc74bf38ffbfc27dcfdf0b96";
+  private static final Pattern DEFAULT_SHARD_TEMPLATE =
+      Pattern.compile("(?x) \\S* (?<shardnum> \\d+) -of- (?<numshards> 
\\d+)\\.csv");
+
+  /**
+   * Options for the TfIdf Integration Test.
+   *
+   * <p>Define expected output file checksum to verify TfIdf pipeline result 
with customized input.
+   */
+  public interface TfIdfITOptions extends TestPipelineOptions, Options {}
+
+  @BeforeClass
+  public static void setUp() {
+    PipelineOptionsFactory.register(TfIdfITOptions.class);
+  }
+
+  @Test
+  public void testE2ETfIdf() throws Exception {
+    TfIdfITOptions options = 
TestPipeline.testingPipelineOptions().as(TfIdfITOptions.class);
+    options.setInput(DEFAULT_INPUT);
+    options.setOutput(
+        FileSystems.matchNewResource(options.getTempRoot(), true)
+            .resolve(
+                String.format("TfIdfIT-%tF-%<tH-%<tM-%<tS-%<tL", new Date()),
+                StandardResolveOptions.RESOLVE_DIRECTORY)
+            .resolve("output", StandardResolveOptions.RESOLVE_DIRECTORY)
+            .resolve("results", StandardResolveOptions.RESOLVE_FILE)
+            .toString());
+    options.setOnSuccessMatcher(
+        new FileChecksumMatcher(
+            EXPECTED_OUTPUT_CHECKSUM, options.getOutput() + "*-of-*.csv", 
DEFAULT_SHARD_TEMPLATE));
+
+    TfIdf.runTfIdf(options);
+  }
+}


 

----------------------------------------------------------------
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: 143609)
    Time Spent: 1h 40m  (was: 1.5h)

> Migrate integration tests for TfIdf
> -----------------------------------
>
>                 Key: BEAM-5341
>                 URL: https://issues.apache.org/jira/browse/BEAM-5341
>             Project: Beam
>          Issue Type: Bug
>          Components: testing
>            Reporter: yifan zou
>            Assignee: yifan zou
>            Priority: Major
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>




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

Reply via email to