Repository: flink
Updated Branches:
  refs/heads/master bec9c4dae -> f577c9ef4


[FLINK-1455] [runtime] Improve robustness of external sorting test errors


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/f577c9ef
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/f577c9ef
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/f577c9ef

Branch: refs/heads/master
Commit: f577c9ef42899479231304a033c4784c413be112
Parents: bec9c4d
Author: Stephan Ewen <se...@apache.org>
Authored: Wed Feb 11 15:54:50 2015 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Wed Feb 11 15:59:38 2015 +0100

----------------------------------------------------------------------
 .../operators/sort/ExternalSortITCase.java      | 18 +++++------
 .../sort/ExternalSortLargeRecordsITCase.java    | 34 +++++++++-----------
 2 files changed, 24 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/f577c9ef/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortITCase.java
----------------------------------------------------------------------
diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortITCase.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortITCase.java
index 6a1eba7..46a1632 100644
--- 
a/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortITCase.java
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortITCase.java
@@ -75,7 +75,7 @@ public class ExternalSortITCase {
        
        private TypeComparator<Record> pactRecordComparator;
        
-       private boolean failed;
+       private boolean testSuccess;
 
        // 
--------------------------------------------------------------------------------------------
 
@@ -96,9 +96,9 @@ public class ExternalSortITCase {
                        Assert.fail("I/O Manager was not properly shut down.");
                }
                
-               if (this.memoryManager != null) {
-                       Assert.assertTrue("Memory leak: not all segments have 
been returned to the memory manager.", 
-                               failed || this.memoryManager.verifyEmpty());
+               if (this.memoryManager != null && testSuccess) {
+                       Assert.assertTrue("Memory leak: not all segments have 
been returned to the memory manager.",
+                                       this.memoryManager.verifyEmpty());
                        this.memoryManager.shutdown();
                        this.memoryManager = null;
                }
@@ -151,9 +151,9 @@ public class ExternalSortITCase {
                        Assert.assertTrue(NUM_PAIRS == pairsEmitted);
                        
                        merger.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       failed = true;
                        e.printStackTrace();
                        Assert.fail(e.getMessage());
                }
@@ -204,9 +204,9 @@ public class ExternalSortITCase {
                        Assert.assertTrue(NUM_PAIRS == pairsEmitted);
                        
                        merger.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       failed = true;
                        e.printStackTrace();
                        Assert.fail(e.getMessage());
                }
@@ -257,9 +257,9 @@ public class ExternalSortITCase {
                        Assert.assertTrue(NUM_PAIRS == pairsEmitted);
                        
                        merger.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       failed = true;
                        e.printStackTrace();
                        Assert.fail(e.getMessage());
                }
@@ -318,9 +318,9 @@ public class ExternalSortITCase {
                        }
                        Assert.assertEquals("Not all pairs were read back in.", 
PAIRS, pairsRead);
                        merger.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       failed = true;
                        e.printStackTrace();
                        Assert.fail(e.getMessage());
                }
@@ -377,9 +377,9 @@ public class ExternalSortITCase {
                        }
                        Assert.assertEquals("Not all pairs were read back in.", 
PAIRS, pairsRead);
                        merger.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       failed = true;
                        e.printStackTrace();
                        Assert.fail(e.getMessage());
                }

http://git-wip-us.apache.org/repos/asf/flink/blob/f577c9ef/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortLargeRecordsITCase.java
----------------------------------------------------------------------
diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortLargeRecordsITCase.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortLargeRecordsITCase.java
index c0083a3..86be614 100644
--- 
a/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortLargeRecordsITCase.java
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/operators/sort/ExternalSortLargeRecordsITCase.java
@@ -52,7 +52,7 @@ import static org.junit.Assert.fail;
 
 public class ExternalSortLargeRecordsITCase {
 
-       private static final int MEMORY_SIZE = 1024 * 1024 * 78;        
+       private static final int MEMORY_SIZE = 1024 * 1024 * 78;
        
        private final AbstractInvokable parentTask = new DummyInvokable();
 
@@ -60,7 +60,7 @@ public class ExternalSortLargeRecordsITCase {
 
        private MemoryManager memoryManager;
        
-       private boolean errored;
+       private boolean testSuccess;
 
        // 
--------------------------------------------------------------------------------------------
 
@@ -77,9 +77,9 @@ public class ExternalSortLargeRecordsITCase {
                        Assert.fail("I/O Manager was not properly shut down.");
                }
                
-               if (this.memoryManager != null) {
+               if (this.memoryManager != null && testSuccess) {
                        Assert.assertTrue("Memory leak: not all segments have 
been returned to the memory manager.", 
-                               errored || this.memoryManager.verifyEmpty());
+                               this.memoryManager.verifyEmpty());
                        this.memoryManager.shutdown();
                        this.memoryManager = null;
                }
@@ -104,7 +104,7 @@ public class ExternalSortLargeRecordsITCase {
 
                        MutableObjectIterator<Tuple2<Long, SomeMaybeLongValue>> 
source =
                                        new MutableObjectIterator<Tuple2<Long, 
SomeMaybeLongValue>>() {
-                                               private final Random rnd = new 
Random();
+                                               private final Random rnd = new 
Random(457821643089756298L);
                                                private int num = 0;
 
                                                @Override
@@ -148,9 +148,9 @@ public class ExternalSortLargeRecordsITCase {
                        assertNull(iterator.next(val));
                        
                        sorter.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       errored = true;
                        e.printStackTrace();
                        fail(e.getMessage());
                }
@@ -174,7 +174,7 @@ public class ExternalSortLargeRecordsITCase {
 
                        MutableObjectIterator<Tuple2<Long, SomeMaybeLongValue>> 
source =
                                        new MutableObjectIterator<Tuple2<Long, 
SomeMaybeLongValue>>() {
-                                               private final Random rnd = new 
Random();
+                                               private final Random rnd = new 
Random(145610843608763871L);
                                                private int num = -1;
 
                                                @Override
@@ -211,16 +211,16 @@ public class ExternalSortLargeRecordsITCase {
                        for (int i = 0; i < NUM_RECORDS; i++) {
                                val = iterator.next(val);
                                
-                               assertTrue(val.f0 <= prevKey);
-                               assertTrue(val.f0.intValue() == val.f1.val());
+                               assertTrue("Sort order violated", val.f0 <= 
prevKey);
+                               assertEquals("Serialization of test data type 
incorrect", val.f0.intValue(), val.f1.val());
                        }
                        
                        assertNull(iterator.next(val));
                        
                        sorter.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       errored = true;
                        e.printStackTrace();
                        fail(e.getMessage());
                }
@@ -246,7 +246,7 @@ public class ExternalSortLargeRecordsITCase {
 
                        MutableObjectIterator<Tuple2<Long, 
SmallOrMediumOrLargeValue>> source =
                                        new MutableObjectIterator<Tuple2<Long, 
SmallOrMediumOrLargeValue>>() {
-                                               private final Random rnd = new 
Random();
+                                               private final Random rnd = new 
Random(1456108743687167086L);
                                                private int num = -1;
 
                                                @Override
@@ -303,9 +303,9 @@ public class ExternalSortLargeRecordsITCase {
                        assertNull(iterator.next(val));
                        
                        sorter.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       errored = true;
                        e.printStackTrace();
                        fail(e.getMessage());
                }
@@ -329,7 +329,7 @@ public class ExternalSortLargeRecordsITCase {
 
                        MutableObjectIterator<Tuple2<Long, 
SmallOrMediumOrLargeValue>> source =
                                        new MutableObjectIterator<Tuple2<Long, 
SmallOrMediumOrLargeValue>>() {
-                                               private final Random rnd = new 
Random();
+                                               private final Random rnd = new 
Random(62360187263087678L);
                                                private int num = -1;
 
                                                @Override
@@ -374,9 +374,9 @@ public class ExternalSortLargeRecordsITCase {
                        assertNull(iterator.next(val));
                        
                        sorter.close();
+                       testSuccess = true;
                }
                catch (Exception e) {
-                       errored = true;
                        e.printStackTrace();
                        fail(e.getMessage());
                }
@@ -444,7 +444,7 @@ public class ExternalSortLargeRecordsITCase {
                                out.write(BUFFER);
                        }
                }
-               
+
                @Override
                public int hashCode() {
                        return val;
@@ -465,10 +465,6 @@ public class ExternalSortLargeRecordsITCase {
                
                private static final long serialVersionUID = 1L;
                
-               public static final int TYPE_SMALL = 0;
-               public static final int TYPE_MEDIUM = 1;
-               public static final int TYPE_LARGE = 2;
-               
                public static final int SMALL_SIZE = 0;
                public static final int MEDIUM_SIZE = 12 * 1024 * 1024;
                public static final int LARGE_SIZE = 100 * 1024 * 1024;

Reply via email to