You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by dh...@apache.org on 2016/08/25 22:40:24 UTC

[1/2] incubator-beam git commit: Make WriteTest more resilient to Randomness

Repository: incubator-beam
Updated Branches:
  refs/heads/master edcb5eff3 -> 9c9f4c9c9


Make WriteTest more resilient to Randomness

In the worst case scenario for random key assignment in
Write.ApplyShardingKey, the chance of the number of records per output
shard was too high. This makes the test significantly less likely to
flake.


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

Branch: refs/heads/master
Commit: 81352b4264999a4a26da8be0bb93bf3a218354d4
Parents: edcb5ef
Author: Thomas Groh <tg...@google.com>
Authored: Thu Aug 25 14:58:56 2016 -0700
Committer: Dan Halperin <dh...@google.com>
Committed: Thu Aug 25 15:40:07 2016 -0700

----------------------------------------------------------------------
 .../core/src/test/java/org/apache/beam/sdk/io/WriteTest.java  | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/81352b42/sdks/java/core/src/test/java/org/apache/beam/sdk/io/WriteTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/WriteTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/WriteTest.java
index 2865188..997566a 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/io/WriteTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/io/WriteTest.java
@@ -192,11 +192,12 @@ public class WriteTest {
       inputs.add(String.format("elt%04d", i));
     }
 
+    int numShards = 10;
     runShardedWrite(
         inputs,
         new WindowAndReshuffle<>(
             Window.<String>into(Sessions.withGapDuration(Duration.millis(1)))),
-        Optional.of(10));
+        Optional.of(numShards));
 
     // Check that both the min and max number of results per shard are close to the expected.
     int min = Integer.MAX_VALUE;
@@ -205,7 +206,9 @@ public class WriteTest {
       min = Math.min(min, i);
       max = Math.max(max, i);
     }
-    assertThat((double) min, Matchers.greaterThanOrEqualTo(max * 0.9));
+    double expected = numElements / (double) numShards;
+    assertThat((double) min, Matchers.greaterThanOrEqualTo(expected * 0.6));
+    assertThat((double) max, Matchers.lessThanOrEqualTo(expected * 1.4));
   }
 
   /**


[2/2] incubator-beam git commit: Closes #886

Posted by dh...@apache.org.
Closes #886


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

Branch: refs/heads/master
Commit: 9c9f4c9c96e45a6dc60af62a01aec10a0433f5f2
Parents: edcb5ef 81352b4
Author: Dan Halperin <dh...@google.com>
Authored: Thu Aug 25 15:40:08 2016 -0700
Committer: Dan Halperin <dh...@google.com>
Committed: Thu Aug 25 15:40:08 2016 -0700

----------------------------------------------------------------------
 .../core/src/test/java/org/apache/beam/sdk/io/WriteTest.java  | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------