Permalink
Browse files

HDFS-2346. TestHost2NodesMap & TestReplicasMap will fail depending up…

…on execution order of test methods. Contributed by Laxman and Uma Maheswara Rao G.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1177034 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent e262faf commit 50d01048e5e4ae6e2c3f77302a4dba7aaa187e85 @shvachko shvachko committed Sep 28, 2011
View
@@ -693,6 +693,9 @@ Release 0.21.1 - Unreleased
HDFS-1855. TestDatanodeBlockScanner.testBlockCorruptionRecoveryPolicy()
part 2 fails in two different ways. (Matt Foley via eli)
+ HDFS-2346. TestHost2NodesMap & TestReplicasMap will fail depending upon
+ execution order of test methods (Laxman, Uma Maheswara Rao G via shv)
+
Release 0.21.0 - 2010-08-13
INCOMPATIBLE CHANGES
@@ -19,18 +19,19 @@
import org.apache.hadoop.hdfs.protocol.Block;
import static org.junit.Assert.*;
-import org.junit.BeforeClass;
+
+import org.junit.Before;
import org.junit.Test;
/**
* Unit test for ReplicasMap class
*/
public class TestReplicasMap {
- private static final ReplicasMap map = new ReplicasMap();
- private static final Block block = new Block(1234, 1234, 1234);
+ private final ReplicasMap map = new ReplicasMap();
+ private final Block block = new Block(1234, 1234, 1234);
- @BeforeClass
- public static void setup() {
+ @Before
+ public void setup() {
map.add(new FinalizedReplica(block, null, null));
}
@@ -18,29 +18,34 @@
package org.apache.hadoop.hdfs.server.namenode;
-import org.apache.hadoop.hdfs.protocol.DatanodeID;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
-import junit.framework.TestCase;
+import org.apache.hadoop.hdfs.protocol.DatanodeID;
+import org.junit.Before;
+import org.junit.Test;
-public class TestHost2NodesMap extends TestCase {
- static private Host2NodesMap map = new Host2NodesMap();
- private final static DatanodeDescriptor dataNodes[] = new DatanodeDescriptor[] {
+public class TestHost2NodesMap{
+ private Host2NodesMap map = new Host2NodesMap();
+ private final DatanodeDescriptor dataNodes[] = new DatanodeDescriptor[] {
new DatanodeDescriptor(new DatanodeID("h1:5020"), "/d1/r1"),
new DatanodeDescriptor(new DatanodeID("h2:5020"), "/d1/r1"),
new DatanodeDescriptor(new DatanodeID("h3:5020"), "/d1/r2"),
new DatanodeDescriptor(new DatanodeID("h3:5030"), "/d1/r2"),
};
- private final static DatanodeDescriptor NULL_NODE = null;
- private final static DatanodeDescriptor NODE =
+ private final DatanodeDescriptor NULL_NODE = null;
+ private final DatanodeDescriptor NODE =
new DatanodeDescriptor(new DatanodeID("h3:5040"), "/d1/r4");
- static {
+ @Before
+ public void setup() {
for(DatanodeDescriptor node:dataNodes) {
map.add(node);
}
map.add(NULL_NODE);
}
+ @Test
public void testContains() throws Exception {
for(int i=0; i<dataNodes.length; i++) {
assertTrue(map.contains(dataNodes[i]));
@@ -49,6 +54,7 @@ public void testContains() throws Exception {
assertFalse(map.contains(NODE));
}
+ @Test
public void testGetDatanodeByHost() throws Exception {
assertTrue(map.getDatanodeByHost("h1")==dataNodes[0]);
assertTrue(map.getDatanodeByHost("h2")==dataNodes[1]);
@@ -57,6 +63,7 @@ public void testGetDatanodeByHost() throws Exception {
assertTrue(null==map.getDatanodeByHost("h4"));
}
+ @Test
public void testGetDatanodeByName() throws Exception {
assertTrue(map.getDatanodeByName("h1:5020")==dataNodes[0]);
assertTrue(map.getDatanodeByName("h1:5030")==null);
@@ -69,6 +76,7 @@ public void testGetDatanodeByName() throws Exception {
assertTrue(map.getDatanodeByName(null)==null);
}
+ @Test
public void testRemove() throws Exception {
assertFalse(map.remove(NODE));

0 comments on commit 50d0104

Please sign in to comment.