commit c81c4d3d1343b0f8ec5dc1536c2639a60eccf7fd Author: Todd Lipcon Date: Wed Jul 28 16:35:59 2010 -0700 HBASE-2884. TestHFileOutputFormat flaky when map tasks generate identical data diff --git src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java index f31a07a..3818892 100644 --- src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java +++ src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java @@ -106,10 +106,15 @@ public class TestHFileOutputFormat { byte keyBytes[] = new byte[keyLength]; byte valBytes[] = new byte[valLength]; - Random random = new Random(System.currentTimeMillis()); + int taskId = context.getTaskAttemptID().getTaskID().getId(); + assert taskId < Byte.MAX_VALUE : "Unit tests dont support > 127 tasks!"; + + Random random = new Random(); for (int i = 0; i < ROWSPERSPLIT; i++) { random.nextBytes(keyBytes); + // Ensure that unique tasks generate unique keys + keyBytes[keyLength - 1] = (byte)(taskId & 0xFF); random.nextBytes(valBytes); ImmutableBytesWritable key = new ImmutableBytesWritable(keyBytes);