[GIRAPH-1091] Fix SimpleRangePartitionFactoryTest Summary: SimpleRangePartitionFactoryTest relied on old logic for calculating number of partitions and got broken with GIRAPH-1082.
Test Plan: Ran the test Differential Revision: https://reviews.facebook.net/D60747 Project: http://git-wip-us.apache.org/repos/asf/giraph/repo Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/26509d6a Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/26509d6a Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/26509d6a Branch: refs/heads/release-1.2 Commit: 26509d6ab7aab0920f47e3ba817507bc92e1349b Parents: da11fb3 Author: Maja Kabiljo <[email protected]> Authored: Wed Jul 13 11:05:48 2016 -0700 Committer: Sergey Edunov <[email protected]> Committed: Wed Jul 13 14:31:30 2016 -0700 ---------------------------------------------------------------------- .../partition/SimpleRangePartitionFactoryTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/giraph/blob/26509d6a/giraph-core/src/test/java/org/apache/giraph/partition/SimpleRangePartitionFactoryTest.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/test/java/org/apache/giraph/partition/SimpleRangePartitionFactoryTest.java b/giraph-core/src/test/java/org/apache/giraph/partition/SimpleRangePartitionFactoryTest.java index 4bb132b..67863dc 100644 --- a/giraph-core/src/test/java/org/apache/giraph/partition/SimpleRangePartitionFactoryTest.java +++ b/giraph-core/src/test/java/org/apache/giraph/partition/SimpleRangePartitionFactoryTest.java @@ -38,9 +38,11 @@ import static org.junit.Assert.assertEquals; /** Test {@link org.apache.giraph.partition.SimpleLongRangePartitionerFactory}. */ public class SimpleRangePartitionFactoryTest { - private void testRange(int numWorkers, int keySpaceSize, int allowedWorkerDiff, boolean emptyWorkers) { + private void testRange(int numWorkers, int numPartitions, int keySpaceSize, + int allowedWorkerDiff, boolean emptyWorkers) { Configuration conf = new Configuration(); conf.setLong(GiraphConstants.PARTITION_VERTEX_KEY_SPACE_SIZE, keySpaceSize); + GiraphConstants.USER_PARTITION_COUNT.set(conf, numPartitions); SimpleLongRangePartitionerFactory<Writable, Writable> factory = new SimpleLongRangePartitionerFactory<Writable, Writable>(); factory.setConf(new ImmutableClassesGiraphConfiguration(conf)); @@ -106,14 +108,14 @@ public class SimpleRangePartitionFactoryTest { @Test public void testLongRangePartitionerFactory() { // perfect distribution - testRange(10, 100000, 0, false); - testRange(1000, 100000, 0, false); + testRange(10, 1000, 100000, 0, false); + testRange(1000, 50000, 100000, 0, false); // perfect distribution even when max is hit, and max is not divisible by #workers - testRange(8949, 100023, 0, false); - testRange(1949, 211111, 0, false); + testRange(8949, (50000 / 8949) * 8949, 100023, 0, false); + testRange(1949, (50000 / 1949) * 1949, 211111, 0, false); // imperfect distribution - because there are more workers than max partitions. - testRange(194942, 211111, 1, true); + testRange(194942, 50000, 211111, 1, true); } }
