HDFS-12671. [READ] Test NameNode restarts when PROVIDED is configured

This commit is contained in:
Virajith Jalaparti 2017-11-07 12:54:27 -08:00 committed by Chris Douglas
parent 71d0a82571
commit c293cc8e9b
1 changed files with 39 additions and 13 deletions

View File

@ -510,13 +510,7 @@ public class TestNameNodeProvidedImplementation {
cluster.getNameNodePort()), cluster.getConfiguration(0)); cluster.getNameNodePort()), cluster.getConfiguration(0));
for (int i= 0; i < numFiles; i++) { for (int i= 0; i < numFiles; i++) {
String filename = "/" + filePrefix + i + fileSuffix; verifyFileLocation(i);
DatanodeInfo[] dnInfos = getAndCheckBlockLocations(client, filename, 1);
// location should be the provided DN.
assertTrue(dnInfos[0].getDatanodeUuid()
.equals(providedDatanode.getDatanodeUuid()));
// NameNode thinks the datanode is down // NameNode thinks the datanode is down
BlockManagerTestUtil.noticeDeadDatanode( BlockManagerTestUtil.noticeDeadDatanode(
cluster.getNameNode(), cluster.getNameNode(),
@ -524,12 +518,44 @@ public class TestNameNodeProvidedImplementation {
cluster.waitActive(); cluster.waitActive();
cluster.triggerHeartbeats(); cluster.triggerHeartbeats();
Thread.sleep(1000); Thread.sleep(1000);
verifyFileLocation(i);
}
}
// should find the block on the 2nd provided datanode. @Test(timeout=30000)
dnInfos = getAndCheckBlockLocations(client, filename, 1); public void testNamenodeRestart() throws Exception {
assertTrue( createImage(new FSTreeWalk(NAMEPATH, conf), NNDIRPATH,
dnInfos[0].getDatanodeUuid() FixedBlockResolver.class);
.equals(providedDatanode.getDatanodeUuid())); // 2 Datanodes, 1 PROVIDED and other DISK
startCluster(NNDIRPATH, 2, null,
new StorageType[][] {
{StorageType.PROVIDED},
{StorageType.DISK}},
false);
verifyFileLocation(numFiles - 1);
cluster.restartNameNodes();
cluster.waitActive();
verifyFileLocation(numFiles - 1);
}
/**
* verify that the specified file has a valid provided location.
* @param fileIndex the index of the file to verify.
* @throws Exception
*/
private void verifyFileLocation(int fileIndex)
throws Exception {
DataNode providedDatanode = cluster.getDataNodes().get(0);
DFSClient client = new DFSClient(
new InetSocketAddress("localhost", cluster.getNameNodePort()),
cluster.getConfiguration(0));
if (fileIndex <= numFiles && fileIndex >= 0) {
String filename = "/" + filePrefix + fileIndex + fileSuffix;
DatanodeInfo[] dnInfos = getAndCheckBlockLocations(client, filename, 1);
// location should be the provided DN
assertEquals(providedDatanode.getDatanodeUuid(),
dnInfos[0].getDatanodeUuid());
} }
} }
} }