HDFS-4018. TestDataNodeMultipleRegistrations#testMiniDFSClusterWithMultipleNN is missing some cluster cleanup. Contributed by Eli Collins
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1395822 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b099a7cbf
commit
2715385c4e
|
@ -83,6 +83,9 @@ Release 2.0.3-alpha - Unreleased
|
||||||
HDFS-4006. TestCheckpoint#testSecondaryHasVeryOutOfDateImage
|
HDFS-4006. TestCheckpoint#testSecondaryHasVeryOutOfDateImage
|
||||||
occasionally fails due to unexpected exit. (todd via eli)
|
occasionally fails due to unexpected exit. (todd via eli)
|
||||||
|
|
||||||
|
HDFS-4018. testMiniDFSClusterWithMultipleNN is missing some
|
||||||
|
cluster cleanup. (eli)
|
||||||
|
|
||||||
Release 2.0.2-alpha - 2012-09-07
|
Release 2.0.2-alpha - 2012-09-07
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.hadoop.hdfs.MiniDFSNNTopology;
|
||||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil;
|
import org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -216,48 +217,62 @@ public class TestDataNodeMultipleRegistrations {
|
||||||
LOG.info("dn bpos len (still should be 3):" + bposs.length);
|
LOG.info("dn bpos len (still should be 3):" + bposs.length);
|
||||||
Assert.assertEquals("should've registered with three namenodes", 3, bposs.length);
|
Assert.assertEquals("should've registered with three namenodes", 3, bposs.length);
|
||||||
} finally {
|
} finally {
|
||||||
if(cluster != null)
|
|
||||||
cluster.shutdown();
|
cluster.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMiniDFSClusterWithMultipleNN() throws IOException {
|
public void testMiniDFSClusterWithMultipleNN() throws IOException {
|
||||||
|
|
||||||
Configuration conf = new HdfsConfiguration();
|
Configuration conf = new HdfsConfiguration();
|
||||||
// start Federated cluster and add a node.
|
// start Federated cluster and add a node.
|
||||||
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
|
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
|
||||||
.nnTopology(MiniDFSNNTopology.simpleFederatedTopology(2))
|
.nnTopology(MiniDFSNNTopology.simpleFederatedTopology(2))
|
||||||
.build();
|
.build();
|
||||||
Assert.assertNotNull(cluster);
|
|
||||||
Assert.assertEquals("(1)Should be 2 namenodes", 2, cluster.getNumNameNodes());
|
|
||||||
|
|
||||||
// add a node
|
// add a node
|
||||||
|
try {
|
||||||
|
Assert.assertNotNull(cluster);
|
||||||
|
cluster.waitActive();
|
||||||
|
Assert.assertEquals("(1)Should be 2 namenodes", 2, cluster.getNumNameNodes());
|
||||||
|
|
||||||
cluster.addNameNode(conf, 0);
|
cluster.addNameNode(conf, 0);
|
||||||
Assert.assertEquals("(1)Should be 3 namenodes", 3, cluster.getNumNameNodes());
|
Assert.assertEquals("(1)Should be 3 namenodes", 3, cluster.getNumNameNodes());
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
Assert.fail("Failed to add NN to cluster:" + StringUtils.stringifyException(ioe));
|
||||||
|
} finally {
|
||||||
cluster.shutdown();
|
cluster.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
// 2. start with Federation flag set
|
// 2. start with Federation flag set
|
||||||
conf = new HdfsConfiguration();
|
conf = new HdfsConfiguration();
|
||||||
cluster = new MiniDFSCluster.Builder(conf)
|
cluster = new MiniDFSCluster.Builder(conf)
|
||||||
.nnTopology(MiniDFSNNTopology.simpleFederatedTopology(1))
|
.nnTopology(MiniDFSNNTopology.simpleFederatedTopology(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
Assert.assertNotNull(cluster);
|
Assert.assertNotNull(cluster);
|
||||||
|
cluster.waitActive();
|
||||||
Assert.assertEquals("(2)Should be 1 namenodes", 1, cluster.getNumNameNodes());
|
Assert.assertEquals("(2)Should be 1 namenodes", 1, cluster.getNumNameNodes());
|
||||||
|
|
||||||
// add a node
|
// add a node
|
||||||
cluster.addNameNode(conf, 0);
|
cluster.addNameNode(conf, 0);
|
||||||
Assert.assertEquals("(2)Should be 2 namenodes", 2, cluster.getNumNameNodes());
|
Assert.assertEquals("(2)Should be 2 namenodes", 2, cluster.getNumNameNodes());
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
Assert.fail("Failed to add NN to cluster:" + StringUtils.stringifyException(ioe));
|
||||||
|
} finally {
|
||||||
cluster.shutdown();
|
cluster.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
// 3. start non-federated
|
// 3. start non-federated
|
||||||
conf = new HdfsConfiguration();
|
conf = new HdfsConfiguration();
|
||||||
cluster = new MiniDFSCluster.Builder(conf).build();
|
cluster = new MiniDFSCluster.Builder(conf).build();
|
||||||
Assert.assertNotNull(cluster);
|
|
||||||
Assert.assertEquals("(2)Should be 1 namenodes", 1, cluster.getNumNameNodes());
|
|
||||||
|
|
||||||
// add a node
|
// add a node
|
||||||
try {
|
try {
|
||||||
|
cluster.waitActive();
|
||||||
|
Assert.assertNotNull(cluster);
|
||||||
|
Assert.assertEquals("(2)Should be 1 namenodes", 1, cluster.getNumNameNodes());
|
||||||
|
|
||||||
cluster.addNameNode(conf, 9929);
|
cluster.addNameNode(conf, 9929);
|
||||||
Assert.fail("shouldn't be able to add another NN to non federated cluster");
|
Assert.fail("shouldn't be able to add another NN to non federated cluster");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -268,6 +283,4 @@ public class TestDataNodeMultipleRegistrations {
|
||||||
cluster.shutdown();
|
cluster.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue