Skip to content

Commit d12be5b

Browse files
Sanjay Radiarichkadel
authored andcommitted
HDFS-4633 TestDFSClientExcludedNodes fails sporadically if excluded nodes cache expires too quickly (Chris Nauroth via Sanjay)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1461846 13f79535-47bb-0310-9956-ffa450edef68
1 parent 062871e commit d12be5b

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ Trunk (Unreleased)
181181
HDFS-4346. Add SequentialNumber as a base class for INodeId and
182182
GenerationStamp. (szetszwo)
183183

184+
HDFS-4633 TestDFSClientExcludedNodes fails sporadically if excluded nodes
185+
cache expires too quickly (Chris Nauroth via Sanjay)
186+
184187
OPTIMIZATIONS
185188

186189
BUG FIXES

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientExcludedNodes.java

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.apache.hadoop.hdfs.MiniDFSCluster.DataNodeProperties;
3333
import org.apache.hadoop.util.ThreadUtil;
3434

35+
import org.junit.After;
36+
import org.junit.Before;
3537
import org.junit.Test;
3638

3739

@@ -41,10 +43,25 @@
4143
*/
4244
public class TestDFSClientExcludedNodes {
4345

44-
@Test(timeout=10000)
46+
private MiniDFSCluster cluster;
47+
private Configuration conf;
48+
49+
@Before
50+
public void setUp() {
51+
cluster = null;
52+
conf = new HdfsConfiguration();
53+
}
54+
55+
@After
56+
public void tearDown() {
57+
if (cluster != null) {
58+
cluster.shutdown();
59+
}
60+
}
61+
62+
@Test(timeout=60000)
4563
public void testExcludedNodes() throws IOException {
46-
Configuration conf = new HdfsConfiguration();
47-
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
64+
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
4865
FileSystem fs = cluster.getFileSystem();
4966
Path filePath = new Path("/testExcludedNodes");
5067

@@ -67,17 +84,16 @@ public void testExcludedNodes() throws IOException {
6784
}
6885
}
6986

70-
@Test(timeout=10000)
87+
@Test(timeout=60000)
7188
public void testExcludedNodesForgiveness() throws IOException {
72-
Configuration conf = new HdfsConfiguration();
73-
// Forgive nodes in under 1s for this test case.
89+
// Forgive nodes in under 2.5s for this test case.
7490
conf.setLong(
7591
DFSConfigKeys.DFS_CLIENT_WRITE_EXCLUDE_NODES_CACHE_EXPIRY_INTERVAL,
76-
1000);
92+
2500);
7793
// We'll be using a 512 bytes block size just for tests
7894
// so making sure the checksum bytes too match it.
7995
conf.setInt("io.bytes.per.checksum", 512);
80-
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
96+
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
8197
List<DataNodeProperties> props = cluster.dataNodes;
8298
FileSystem fs = cluster.getFileSystem();
8399
Path filePath = new Path("/testForgivingExcludedNodes");
@@ -112,11 +128,11 @@ public void testExcludedNodesForgiveness() throws IOException {
112128
Assert.assertEquals(true, cluster.restartDataNode(two, true));
113129
cluster.waitActive();
114130

115-
// Sleep for 2s, to let the excluded nodes be expired
131+
// Sleep for 5s, to let the excluded nodes be expired
116132
// from the excludes list (i.e. forgiven after the configured wait period).
117-
// [Sleeping just in case the restart of the DNs completed < 2s cause
133+
// [Sleeping just in case the restart of the DNs completed < 5s cause
118134
// otherwise, we'll end up quickly excluding those again.]
119-
ThreadUtil.sleepAtLeastIgnoreInterrupts(2000);
135+
ThreadUtil.sleepAtLeastIgnoreInterrupts(5000);
120136

121137
// Terminate the last good DN, to assert that there's no
122138
// single-DN-available scenario, caused by not forgiving the other

0 commit comments

Comments
 (0)