HDFS-16345. Fix test case fail in TestBlockStoragePolicy (#3696). Contributed by guophilipse.

Reviewed-by: Akira Ajisaka <aajisaka@apache.org>
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
GuoPhilipse 2021-12-08 19:04:54 +08:00 committed by GitHub
parent 6ed01585eb
commit 25849ff7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1274,6 +1274,7 @@ public void testChooseTargetWithTopology() throws Exception {
DFSTestUtil.formatNameNode(conf); DFSTestUtil.formatNameNode(conf);
NameNode namenode = new NameNode(conf); NameNode namenode = new NameNode(conf);
try {
final BlockManager bm = namenode.getNamesystem().getBlockManager(); final BlockManager bm = namenode.getNamesystem().getBlockManager();
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy(); BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology(); NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
@ -1291,6 +1292,11 @@ public void testChooseTargetWithTopology() throws Exception {
new HashSet<Node>(), 0, policy2, null); new HashSet<Node>(), 0, policy2, null);
System.out.println(Arrays.asList(targets)); System.out.println(Arrays.asList(targets));
Assert.assertEquals(3, targets.length); Assert.assertEquals(3, targets.length);
} finally {
if (namenode != null) {
namenode.stop();
}
}
} }
@Test @Test
@ -1321,6 +1327,7 @@ public void testChooseSsdOverDisk() throws Exception {
DFSTestUtil.formatNameNode(conf); DFSTestUtil.formatNameNode(conf);
NameNode namenode = new NameNode(conf); NameNode namenode = new NameNode(conf);
try {
final BlockManager bm = namenode.getNamesystem().getBlockManager(); final BlockManager bm = namenode.getNamesystem().getBlockManager();
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy(); BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology(); NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
@ -1335,6 +1342,11 @@ public void testChooseSsdOverDisk() throws Exception {
Assert.assertEquals(2, targets.length); Assert.assertEquals(2, targets.length);
Assert.assertEquals(StorageType.SSD, targets[0].getStorageType()); Assert.assertEquals(StorageType.SSD, targets[0].getStorageType());
Assert.assertEquals(StorageType.DISK, targets[1].getStorageType()); Assert.assertEquals(StorageType.DISK, targets[1].getStorageType());
} finally {
if (namenode != null) {
namenode.stop();
}
}
} }
/** /**
@ -1374,6 +1386,7 @@ public void testAddDatanode2ExistingPipelineInSsd() throws Exception {
DFSTestUtil.formatNameNode(conf); DFSTestUtil.formatNameNode(conf);
NameNode namenode = new NameNode(conf); NameNode namenode = new NameNode(conf);
try {
final BlockManager bm = namenode.getNamesystem().getBlockManager(); final BlockManager bm = namenode.getNamesystem().getBlockManager();
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy(); BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology(); NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
@ -1388,6 +1401,11 @@ public void testAddDatanode2ExistingPipelineInSsd() throws Exception {
null, chsenDs, true, null, chsenDs, true,
new HashSet<Node>(), 0, policy, null); new HashSet<Node>(), 0, policy, null);
Assert.assertEquals(3, targets.length); Assert.assertEquals(3, targets.length);
} finally {
if (namenode != null) {
namenode.stop();
}
}
} }
@Test @Test