From ba6bd0981186b4357dddb54e62a8d65c7b4e3559 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Thu, 6 Jun 2013 04:17:04 +0000 Subject: [PATCH] HADOOP-8982. TestSocketIOWithTimeout fails on Windows. Contributed by Chris Nauroth. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1490124 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 3 +++ .../hadoop/net/TestSocketIOWithTimeout.java | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index c7554d4d7a1..e06a273cf2f 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -749,6 +749,9 @@ Release 2.1.0-beta - UNRELEASED HADOOP-9526. TestShellCommandFencer and TestShell fail on Windows. (Arpit Agarwal via suresh) + HADOOP-8982. TestSocketIOWithTimeout fails on Windows. + (Chris Nauroth via suresh) + Release 2.0.5-alpha - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestSocketIOWithTimeout.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestSocketIOWithTimeout.java index 49466879370..476525bee67 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestSocketIOWithTimeout.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestSocketIOWithTimeout.java @@ -32,6 +32,7 @@ import org.apache.hadoop.test.MultithreadedTestUtil.TestContext; import org.apache.hadoop.test.MultithreadedTestUtil.TestingThread; import org.apache.hadoop.util.Time; +import org.apache.hadoop.util.Shell; import org.junit.Test; import static org.junit.Assert.*; @@ -144,12 +145,20 @@ public void doWork() throws Exception { // Nevertheless, the output stream is closed, because // a partial write may have succeeded (see comment in // SocketOutputStream#write(byte[]), int, int) - try { - out.write(1); - fail("Did not throw"); - } catch (IOException ioe) { - GenericTestUtils.assertExceptionContains( - "stream is closed", ioe); + // This portion of the test cannot pass on Windows due to differences in + // behavior of partial writes. Windows appears to buffer large amounts of + // written data and send it all atomically, thus making it impossible to + // simulate a partial write scenario. Attempts were made to switch the + // test from using a pipe to a network socket and also to use larger and + // larger buffers in doIO. Nothing helped the situation though. + if (!Shell.WINDOWS) { + try { + out.write(1); + fail("Did not throw"); + } catch (IOException ioe) { + GenericTestUtils.assertExceptionContains( + "stream is closed", ioe); + } } out.close();