From 9b039a5004685d61375a7c0d40de95e4c15ae1d6 Mon Sep 17 00:00:00 2001 From: cnauroth Date: Tue, 22 Dec 2015 10:29:35 -0800 Subject: [PATCH] HDFS-9458. TestBackupNode always binds to port 50070, which can cause bind failures. Contributed by Xiao Chen. (cherry picked from commit 5c0ff69618fa303078c0f9afef4c93a864ab6cb7) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/namenode/TestBackupNode.java | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 83be6e40f38..856d21255f7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1667,6 +1667,9 @@ Release 2.8.0 - UNRELEASED HDFS-9589. Block files which have been hardlinked should be duplicated before the DataNode appends to the them (cmccabe) + HDFS-9458. TestBackupNode always binds to port 50070, which can cause bind + failures. (Xiao Chen via cnauroth) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java index 77df4f0e516..1a707956c74 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java @@ -48,6 +48,7 @@ import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory; import org.apache.hadoop.hdfs.server.namenode.FileJournalManager.EditLogFile; import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols; import org.apache.hadoop.net.NetUtils; +import org.apache.hadoop.net.ServerSocketUtil; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.test.GenericTestUtils; @@ -143,8 +144,9 @@ public class TestBackupNode { Configuration c = new HdfsConfiguration(); StartupOption startupOpt = StartupOption.CHECKPOINT; String dirs = getBackupNodeDir(startupOpt, 1); - c.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://127.0.0.1:1234"); - c.set(DFSConfigKeys.DFS_NAMENODE_BACKUP_HTTP_ADDRESS_KEY, "localhost:0"); + c.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, + "hdfs://127.0.0.1:" + ServerSocketUtil.getPort(0, 100)); + c.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "127.0.0.1:0"); c.set(DFSConfigKeys.DFS_BLOCKREPORT_INITIAL_DELAY_KEY, "0"); c.setInt(DFSConfigKeys.DFS_DATANODE_SCAN_PERIOD_HOURS_KEY, -1); // disable block scanner @@ -179,7 +181,8 @@ public class TestBackupNode { bn.getNamesystem() == null); fail("Incorrect authentication setting should throw IOException"); } catch (IOException e) { - LOG.info("IOException thrown as expected", e); + LOG.info("IOException thrown.", e); + assertTrue(e.getMessage().contains("Running in secure mode")); } finally { if (nn != null) { nn.stop();