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

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

                Author: ASF GitHub Bot
            Created on: 02/Oct/18 23:09
            Start Date: 02/Oct/18 23:09
    Worklog Time Spent: 10m 
      Work Description: jasonkuster closed pull request #6528: [BEAM-5534] 
Revert "Merge pull request #6411 from huygaa11/revert-6311-twsit"
URL: https://github.com/apache/beam/pull/6528
 
 
   

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/TopWikipediaSessions.java
 
b/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java
index acc083ba0df..b33bbc00732 100644
--- 
a/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java
+++ 
b/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java
@@ -19,6 +19,7 @@
 
 import com.google.api.services.bigquery.model.TableRow;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.List;
 import org.apache.beam.sdk.Pipeline;
 import org.apache.beam.sdk.io.TextIO;
@@ -76,7 +77,13 @@
     @ProcessElement
     public void processElement(ProcessContext c) {
       TableRow row = c.element();
-      int timestamp = (Integer) row.get("timestamp");
+      int timestamp;
+      // TODO(BEAM-5390): Avoid this workaround.
+      try {
+        timestamp = ((BigDecimal) row.get("timestamp")).intValue();
+      } catch (ClassCastException e) {
+        timestamp = ((Integer) row.get("timestamp")).intValue();
+      }
       String userName = (String) row.get("contributor_username");
       if (userName != null) {
         // Sets the implicit timestamp field to be used in windowing.
@@ -180,9 +187,9 @@ public void processElement(ProcessContext c) {
   public interface Options extends PipelineOptions {
     @Description("Input specified as a GCS path containing a BigQuery table 
exported as json")
     @Default.String(EXPORTED_WIKI_TABLE)
-    String getInput();
+    String getWikiInput();
 
-    void setInput(String value);
+    void setWikiInput(String value);
 
     @Description("File to output results to")
     @Validation.Required
@@ -191,18 +198,21 @@ public void processElement(ProcessContext c) {
     void setOutput(String value);
   }
 
-  public static void main(String[] args) {
-    Options options = 
PipelineOptionsFactory.fromArgs(args).withValidation().as(Options.class);
-
+  public static void run(Options options) {
     Pipeline p = Pipeline.create(options);
 
     double samplingThreshold = 0.1;
 
-    p.apply(TextIO.read().from(options.getInput()))
+    p.apply(TextIO.read().from(options.getWikiInput()))
         .apply(MapElements.via(new ParseTableRowJson()))
         .apply(new ComputeTopSessions(samplingThreshold))
-        .apply("Write", 
TextIO.write().withoutSharding().to(options.getOutput()));
+        .apply("Write", TextIO.write().to(options.getOutput()));
 
     p.run().waitUntilFinish();
   }
+
+  public static void main(String[] args) {
+    Options options = 
PipelineOptionsFactory.fromArgs(args).withValidation().as(Options.class);
+    run(options);
+  }
 }
diff --git 
a/examples/java/src/test/java/org/apache/beam/examples/complete/TopWikipediaSessionsIT.java
 
b/examples/java/src/test/java/org/apache/beam/examples/complete/TopWikipediaSessionsIT.java
new file mode 100644
index 00000000000..1f278e7f7a7
--- /dev/null
+++ 
b/examples/java/src/test/java/org/apache/beam/examples/complete/TopWikipediaSessionsIT.java
@@ -0,0 +1,69 @@
+/*
+ * 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 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;
+
+/** End-to-end tests of TopWikipediaSessions. */
+@RunWith(JUnit4.class)
+public class TopWikipediaSessionsIT {
+
+  private static final String DEFAULT_INPUT_10_FILES =
+      "gs://apache-beam-samples/wikipedia_edits/wiki_data-00000000000*.json";
+  private static final String DEFAULT_OUTPUT_CHECKSUM = 
"a7f0c50b895d0a2e37b78c3f94eadcfb11a647a6";
+
+  /** PipelineOptions for the TopWikipediaSessions integration test. */
+  public interface TopWikipediaSessionsITOptions
+      extends TestPipelineOptions, TopWikipediaSessions.Options {}
+
+  @BeforeClass
+  public static void setUp() {
+    PipelineOptionsFactory.register(TestPipelineOptions.class);
+  }
+
+  @Test
+  public void testE2ETopWikiPages() throws Exception {
+    TopWikipediaSessionsITOptions options =
+        
TestPipeline.testingPipelineOptions().as(TopWikipediaSessionsITOptions.class);
+
+    options.setWikiInput(DEFAULT_INPUT_10_FILES);
+    options.setOutput(
+        FileSystems.matchNewResource(options.getTempRoot(), true)
+            .resolve(
+                String.format("topwikisessions-it-%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(DEFAULT_OUTPUT_CHECKSUM, options.getOutput() + 
"*-of-*"));
+
+    TopWikipediaSessions.run(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:
[email protected]


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

    Worklog Id:     (was: 150560)
    Time Spent: 1h 20m  (was: 1h 10m)

> AutocompleteIT and WikiTopSessionsIT fail in google testing
> -----------------------------------------------------------
>
>                 Key: BEAM-5534
>                 URL: https://issues.apache.org/jira/browse/BEAM-5534
>             Project: Beam
>          Issue Type: Bug
>          Components: test-failures
>            Reporter: Pablo Estrada
>            Assignee: Pablo Estrada
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>




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

Reply via email to