From e29f91bad3d76c8a6171f5855493b057a09a161c Mon Sep 17 00:00:00 2001 From: Kihwal Lee Date: Wed, 18 Sep 2019 15:53:08 -0500 Subject: [PATCH] HDFS-13959. TestUpgradeDomainBlockPlacementPolicy is flaky. Contributed by Ayush Saxena. (cherry picked from commit 1851d06eb3b70f39f3054a7c06f0ad2bc664aaec) --- ...TestUpgradeDomainBlockPlacementPolicy.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestUpgradeDomainBlockPlacementPolicy.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestUpgradeDomainBlockPlacementPolicy.java index 8460b6f5ff8..3383c4ee47b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestUpgradeDomainBlockPlacementPolicy.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestUpgradeDomainBlockPlacementPolicy.java @@ -65,14 +65,8 @@ public class TestUpgradeDomainBlockPlacementPolicy { private static final int DEFAULT_BLOCK_SIZE = 1024; static final String[] racks = { "/RACK1", "/RACK1", "/RACK1", "/RACK2", "/RACK2", "/RACK2" }; - /** - * Use host names that can be resolved ( - * InetSocketAddress#isUnresolved == false). Otherwise, - * CombinedHostFileManager won't allow those hosts. - */ static final String[] hosts = - {"127.0.0.1", "127.0.0.1", "127.0.0.1", "127.0.0.1", - "127.0.0.1", "127.0.0.1"}; + {"host1", "host2", "host3", "host4", "host5", "host6"}; static final String[] upgradeDomains = {"ud5", "ud2", "ud3", "ud1", "ud2", "ud4"}; static final Set expectedDatanodeIDs = new HashSet<>(); @@ -134,7 +128,12 @@ public class TestUpgradeDomainBlockPlacementPolicy { for (int i = 0; i < hosts.length; i++) { datanodes[i] = new DatanodeAdminProperties(); DatanodeID datanodeID = cluster.getDataNodes().get(i).getDatanodeId(); - datanodes[i].setHostName(datanodeID.getHostName()); + /* + * Use host names that can be resolved ( + * InetSocketAddress#isUnresolved == false). Otherwise, + * CombinedHostFileManager won't allow those hosts. + */ + datanodes[i].setHostName(datanodeID.getIpAddr()); datanodes[i].setPort(datanodeID.getXferPort()); datanodes[i].setUpgradeDomain(upgradeDomains[i]); } @@ -168,7 +167,12 @@ public class TestUpgradeDomainBlockPlacementPolicy { for (int i = 0; i < hosts.length; i++) { datanodes[i] = new DatanodeAdminProperties(); DatanodeID datanodeID = cluster.getDataNodes().get(i).getDatanodeId(); - datanodes[i].setHostName(datanodeID.getHostName()); + /* + * Use host names that can be resolved ( + * InetSocketAddress#isUnresolved == false). Otherwise, + * CombinedHostFileManager won't allow those hosts. + */ + datanodes[i].setHostName(datanodeID.getIpAddr()); datanodes[i].setPort(datanodeID.getXferPort()); datanodes[i].setUpgradeDomain(upgradeDomains[i]); }