You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by iw...@apache.org on 2019/07/26 00:54:52 UTC

[hadoop] branch branch-2 updated: HDFS-14135. TestWebHdfsTimeouts Fails intermittently in trunk. Contributed by Ayush Saxena.

This is an automated email from the ASF dual-hosted git repository.

iwasakims pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 3bfae20  HDFS-14135. TestWebHdfsTimeouts Fails intermittently in trunk. Contributed by Ayush Saxena.
3bfae20 is described below

commit 3bfae20e946e40f6936aab54b79fc85df8d3b0b2
Author: Masatake Iwasaki <iw...@apache.org>
AuthorDate: Fri Jun 21 14:33:41 2019 +0900

    HDFS-14135. TestWebHdfsTimeouts Fails intermittently in trunk. Contributed by Ayush Saxena.
    
    Signed-off-by: Masatake Iwasaki <iw...@apache.org>
    (cherry picked from commit 6b8107ad97251267253fa045ba03c4749f95f530)
---
 .../hadoop/hdfs/web/TestWebHdfsTimeouts.java       | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java
index 67c39e1..fe4b91c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java
@@ -35,6 +35,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -47,6 +48,7 @@ import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.authentication.client.ConnectionConfigurator;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.junit.After;
+import org.junit.AssumptionViolatedException;
 import org.junit.Before;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -84,6 +86,7 @@ public class TestWebHdfsTimeouts {
       return conn;
     }
   });
+  private volatile boolean failedToConsumeBacklog;
 
   public enum TimeoutSource { ConnectionFactory, Configuration };
 
@@ -122,6 +125,7 @@ public class TestWebHdfsTimeouts {
 
     clients = new ArrayList<SocketChannel>();
     serverThread = null;
+    failedToConsumeBacklog = false;
   }
 
   @After
@@ -211,6 +215,7 @@ public class TestWebHdfsTimeouts {
       fs.getFileChecksum(new Path("/file"));
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
+      assumeBacklogConsumed();
       GenericTestUtils.assertExceptionContains(
           fs.getUri().getAuthority() + ": connect timed out", e);
     }
@@ -244,6 +249,7 @@ public class TestWebHdfsTimeouts {
       os = fs.create(new Path("/file"));
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
+      assumeBacklogConsumed();
       GenericTestUtils.assertExceptionContains(
           fs.getUri().getAuthority() + ": connect timed out", e);
     } finally {
@@ -357,6 +363,28 @@ public class TestWebHdfsTimeouts {
       client.connect(nnHttpAddress);
       clients.add(client);
     }
+    try {
+      GenericTestUtils.waitFor(() -> {
+        try (SocketChannel c = SocketChannel.open()) {
+          c.socket().connect(nnHttpAddress, 100);
+        } catch (SocketTimeoutException e) {
+          return true;
+        } catch (IOException e) {
+          LOG.debug("unexpected exception: " + e);
+        }
+        return false;
+      }, 100, 10000);
+    } catch (TimeoutException | InterruptedException e) {
+      failedToConsumeBacklog = true;
+      assumeBacklogConsumed();
+    }
+  }
+
+  private void assumeBacklogConsumed() {
+    if (failedToConsumeBacklog) {
+      throw new AssumptionViolatedException(
+          "failed to fill up connection backlog.");
+    }
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org