beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhalp...@apache.org
Subject [1/2] incubator-beam git commit: Make WriteTest more resilient to Randomness
Date Thu, 25 Aug 2016 22:40:24 GMT
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 <tgroh@google.com>
Authored: Thu Aug 25 14:58:56 2016 -0700
Committer: Dan Halperin <dhalperi@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));
   }
 
   /**


Mime
View raw message