From bf5295b118a24e762f21bb2b9054e5e0c1d1d14a Mon Sep 17 00:00:00 2001 From: Yongjun Zhang Date: Fri, 11 Dec 2015 19:52:38 -0800 Subject: [PATCH] HDFS-9514. TestDistributedFileSystem.testDFSClientPeerWriteTimeout failing; exception being swallowed. (Wei-Chiu Chuang via Yongjun Zhang) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/TestDistributedFileSystem.java | 27 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 767bbcb1ca2..4c1287c4ad5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1745,6 +1745,9 @@ Release 2.8.0 - UNRELEASED HDFS-9519. Some coding improvement in SecondaryNameNode#main. (Xiao Chen via Yongjun Zhang) + HDFS-9514. TestDistributedFileSystem.testDFSClientPeerWriteTimeout failing; + exception being swallowed. (Wei-Chiu Chuang via Yongjun Zhang) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java index 0543e9d093d..e628752330b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java @@ -990,10 +990,14 @@ public class TestDistributedFileSystem { Assert.fail("read should timeout"); } catch (SocketTimeoutException ste) { long delta = Time.now() - start; - Assert.assertTrue("read timedout too soon", delta >= timeout*0.9); - Assert.assertTrue("read timedout too late", delta <= timeout*1.1); - } catch (Throwable t) { - Assert.fail("wrong exception:"+t); + if (delta < timeout*0.9) { + throw new IOException("read timedout too soon in " + delta + " ms.", + ste); + } + if (delta > timeout*1.1) { + throw new IOException("read timedout too late in " + delta + " ms.", + ste); + } } } finally { cluster.shutdown(); @@ -1037,12 +1041,15 @@ public class TestDistributedFileSystem { Assert.fail("write finish in " + delta + " ms" + "but should timedout"); } catch (SocketTimeoutException ste) { long delta = Time.now() - start; - Assert.assertTrue("write timedout too soon in " + delta + " ms", - delta >= timeout * 0.9); - Assert.assertTrue("write timedout too late in " + delta + " ms", - delta <= timeout * 1.2); - } catch (Throwable t) { - Assert.fail("wrong exception:" + t); + + if (delta < timeout * 0.9) { + throw new IOException("write timedout too soon in " + delta + " ms.", + ste); + } + if (delta > timeout * 1.2) { + throw new IOException("write timedout too late in " + delta + " ms.", + ste); + } } } finally { cluster.shutdown();