Skip to content

Commit c77a7a6

Browse files
ayushtknKiran Kumar Maturi
authored andcommitted
HDFS-15988. Stabilise HDFS Pre-Commit. (apache#2860). Contributed by Ayush Saxena.
Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
1 parent ad9fedf commit c77a7a6

6 files changed

Lines changed: 44 additions & 31 deletions

File tree

dev-support/bin/hadoop.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ function personality_modules
355355
fi
356356
;;
357357
unit)
358+
extra="-Dsurefire.rerunFailingTestsCount=2"
358359
if [[ "${BUILDMODE}" = full ]]; then
359360
ordering=mvnsrc
360361
elif [[ "${CHANGED_MODULES[*]}" =~ \. ]]; then
@@ -363,7 +364,7 @@ function personality_modules
363364

364365
if [[ ${TEST_PARALLEL} = "true" ]] ; then
365366
if hadoop_test_parallel; then
366-
extra="-Pparallel-tests"
367+
extra="${extra} -Pparallel-tests"
367368
if [[ -n ${TEST_THREADS:-} ]]; then
368369
extra="${extra} -DtestsThreadCount=${TEST_THREADS}"
369370
fi

dev-support/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ RUN mkdir -p /opt/isa-l-src \
179179
###
180180
# Avoid out of memory errors in builds
181181
###
182-
ENV MAVEN_OPTS -Xms256m -Xmx1536m
182+
ENV MAVEN_OPTS -Xms256m -Xmx3072m
183183

184184
# Skip gpg verification when downloading Yetus via yetus-wrapper
185185
ENV HADOOP_SKIP_YETUS_VERIFICATION true

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.apache.hadoop.fs.FileSystem;
3535
import org.apache.hadoop.fs.FileUtil;
3636
import org.apache.hadoop.fs.Path;
37+
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
3738
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
3839
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
3940
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
@@ -97,12 +98,14 @@ void testRestartDfs(boolean useFlush) throws Exception {
9798
conf.setInt(
9899
CommonConfigurationKeysPublic.IPC_CLIENT_CONNECTION_MAXIDLETIME_KEY,
99100
0);
101+
conf.setBoolean(HdfsClientConfigKeys.Retry.POLICY_ENABLED_KEY, true);
100102
MiniDFSCluster cluster = null;
101103

102104
long len = 0;
103105
FSDataOutputStream stream;
104106
try {
105107
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
108+
cluster.waitActive();
106109
FileSystem fs = cluster.getFileSystem();
107110
// Creating a file with 4096 blockSize to write multiple blocks
108111
stream = fs.create(FILE_PATH, true, BLOCK_SIZE, (short) 1, BLOCK_SIZE);

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDirectoryScanner.java

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
public class TestDirectoryScanner {
9292
private static final Logger LOG =
9393
LoggerFactory.getLogger(TestDirectoryScanner.class);
94-
private static final Configuration CONF = new HdfsConfiguration();
9594
private static final int DEFAULT_GEN_STAMP = 9999;
9695

9796
private MiniDFSCluster cluster;
@@ -103,12 +102,14 @@ public class TestDirectoryScanner {
103102
private final Random r = new Random();
104103
private static final int BLOCK_LENGTH = 100;
105104

106-
static {
107-
CONF.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_LENGTH);
108-
CONF.setInt(DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_KEY, 1);
109-
CONF.setLong(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1L);
110-
CONF.setLong(DFSConfigKeys.DFS_DATANODE_MAX_LOCKED_MEMORY_KEY,
105+
public Configuration getConfiguration() {
106+
Configuration configuration = new HdfsConfiguration();
107+
configuration.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_LENGTH);
108+
configuration.setInt(DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_KEY, 1);
109+
configuration.setLong(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1L);
110+
configuration.setLong(DFSConfigKeys.DFS_DATANODE_MAX_LOCKED_MEMORY_KEY,
111111
getMemlockLimit(Long.MAX_VALUE));
112+
return configuration;
112113
}
113114

114115
@Before
@@ -361,7 +362,8 @@ private void verifyStats(long totalBlocks, int diffsize, long missingMetaFile,
361362

362363
@Test(timeout = 300000)
363364
public void testRetainBlockOnPersistentStorage() throws Exception {
364-
cluster = new MiniDFSCluster.Builder(CONF)
365+
Configuration conf = getConfiguration();
366+
cluster = new MiniDFSCluster.Builder(conf)
365367
.storageTypes(
366368
new StorageType[] { StorageType.RAM_DISK, StorageType.DEFAULT })
367369
.numDataNodes(1).build();
@@ -370,7 +372,7 @@ public void testRetainBlockOnPersistentStorage() throws Exception {
370372
bpid = cluster.getNamesystem().getBlockPoolId();
371373
fds = DataNodeTestUtils.getFSDataset(cluster.getDataNodes().get(0));
372374
client = cluster.getFileSystem().getClient();
373-
scanner = new DirectoryScanner(fds, CONF);
375+
scanner = new DirectoryScanner(fds, conf);
374376
scanner.setRetainDiffs(true);
375377
FsDatasetTestUtil.stopLazyWriter(cluster.getDataNodes().get(0));
376378

@@ -413,8 +415,9 @@ public void testScanDirectoryStructureWarn() throws Exception {
413415
new WriterAppender(new SimpleLayout(), loggerStream);
414416
rootLogger.addAppender(writerAppender);
415417

418+
Configuration conf = getConfiguration();
416419
cluster = new MiniDFSCluster
417-
.Builder(CONF)
420+
.Builder(conf)
418421
.storageTypes(new StorageType[] {
419422
StorageType.RAM_DISK, StorageType.DEFAULT })
420423
.numDataNodes(1)
@@ -424,7 +427,7 @@ public void testScanDirectoryStructureWarn() throws Exception {
424427
bpid = cluster.getNamesystem().getBlockPoolId();
425428
fds = DataNodeTestUtils.getFSDataset(cluster.getDataNodes().get(0));
426429
client = cluster.getFileSystem().getClient();
427-
scanner = new DirectoryScanner(fds, CONF);
430+
scanner = new DirectoryScanner(fds, conf);
428431
scanner.setRetainDiffs(true);
429432
FsDatasetTestUtil.stopLazyWriter(cluster.getDataNodes().get(0));
430433

@@ -464,7 +467,8 @@ public void testScanDirectoryStructureWarn() throws Exception {
464467

465468
@Test(timeout = 300000)
466469
public void testDeleteBlockOnTransientStorage() throws Exception {
467-
cluster = new MiniDFSCluster.Builder(CONF)
470+
Configuration conf = getConfiguration();
471+
cluster = new MiniDFSCluster.Builder(conf)
468472
.storageTypes(
469473
new StorageType[] { StorageType.RAM_DISK, StorageType.DEFAULT })
470474
.numDataNodes(1).build();
@@ -473,7 +477,7 @@ public void testDeleteBlockOnTransientStorage() throws Exception {
473477
bpid = cluster.getNamesystem().getBlockPoolId();
474478
fds = DataNodeTestUtils.getFSDataset(cluster.getDataNodes().get(0));
475479
client = cluster.getFileSystem().getClient();
476-
scanner = new DirectoryScanner(fds, CONF);
480+
scanner = new DirectoryScanner(fds, conf);
477481
scanner.setRetainDiffs(true);
478482
FsDatasetTestUtil.stopLazyWriter(cluster.getDataNodes().get(0));
479483

@@ -512,16 +516,17 @@ public void testDirectoryScanner() throws Exception {
512516
}
513517

514518
public void runTest(int parallelism) throws Exception {
515-
cluster = new MiniDFSCluster.Builder(CONF).build();
519+
Configuration conf = getConfiguration();
520+
cluster = new MiniDFSCluster.Builder(conf).build();
516521
try {
517522
cluster.waitActive();
518523
bpid = cluster.getNamesystem().getBlockPoolId();
519524
fds = DataNodeTestUtils.getFSDataset(cluster.getDataNodes().get(0));
520525
client = cluster.getFileSystem().getClient();
521-
CONF.setInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_KEY,
526+
conf.setInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_KEY,
522527
parallelism);
523528

524-
scanner = new DirectoryScanner(fds, CONF);
529+
scanner = new DirectoryScanner(fds, conf);
525530
scanner.setRetainDiffs(true);
526531

527532
// Add files with 100 blocks
@@ -672,9 +677,9 @@ public void runTest(int parallelism) throws Exception {
672677
*
673678
* @throws Exception thrown on unexpected failure
674679
*/
675-
@Test(timeout = 600000)
680+
@Test
676681
public void testThrottling() throws Exception {
677-
Configuration conf = new Configuration(CONF);
682+
Configuration conf = new Configuration(getConfiguration());
678683

679684
// We need lots of blocks so the report compiler threads have enough to
680685
// keep them busy while we watch them.
@@ -714,7 +719,7 @@ public void testThrottling() throws Exception {
714719
// Waiting should be about 9x running.
715720
LOG.info("RATIO: " + ratio);
716721
assertTrue("Throttle is too restrictive", ratio <= 10f);
717-
assertTrue("Throttle is too permissive", ratio >= 7f);
722+
assertTrue("Throttle is too permissive" + ratio, ratio >= 7f);
718723

719724
// Test with a different limit
720725
conf.setInt(
@@ -754,7 +759,7 @@ public void testThrottling() throws Exception {
754759
assertTrue("Throttle is too permissive", ratio >= 7f);
755760

756761
// Test with no limit
757-
scanner = new DirectoryScanner(fds, CONF);
762+
scanner = new DirectoryScanner(fds, getConfiguration());
758763
scanner.setRetainDiffs(true);
759764
scan(blocks, 0, 0, 0, 0, 0);
760765
scanner.shutdown();
@@ -1095,13 +1100,14 @@ public void TestScanInfo() throws Exception {
10951100
*/
10961101
@Test(timeout = 60000)
10971102
public void testExceptionHandlingWhileDirectoryScan() throws Exception {
1098-
cluster = new MiniDFSCluster.Builder(CONF).build();
1103+
Configuration conf = getConfiguration();
1104+
cluster = new MiniDFSCluster.Builder(conf).build();
10991105
try {
11001106
cluster.waitActive();
11011107
bpid = cluster.getNamesystem().getBlockPoolId();
11021108
fds = DataNodeTestUtils.getFSDataset(cluster.getDataNodes().get(0));
11031109
client = cluster.getFileSystem().getClient();
1104-
CONF.setInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_KEY, 1);
1110+
conf.setInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_KEY, 1);
11051111

11061112
// Add files with 2 blocks
11071113
createFile(GenericTestUtils.getMethodName(), BLOCK_LENGTH * 2, false);
@@ -1121,7 +1127,7 @@ public void testExceptionHandlingWhileDirectoryScan() throws Exception {
11211127
FsDatasetSpi<? extends FsVolumeSpi> spyFds = Mockito.spy(fds);
11221128
Mockito.doReturn(volReferences).when(spyFds).getFsVolumeReferences();
11231129

1124-
scanner = new DirectoryScanner(spyFds, CONF);
1130+
scanner = new DirectoryScanner(spyFds, conf);
11251131
scanner.setRetainDiffs(true);
11261132
scanner.reconcile();
11271133
} finally {
@@ -1135,7 +1141,7 @@ public void testExceptionHandlingWhileDirectoryScan() throws Exception {
11351141

11361142
@Test
11371143
public void testDirectoryScannerInFederatedCluster() throws Exception {
1138-
HdfsConfiguration conf = new HdfsConfiguration(CONF);
1144+
HdfsConfiguration conf = new HdfsConfiguration(getConfiguration());
11391145
// Create Federated cluster with two nameservices and one DN
11401146
try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
11411147
.nnTopology(MiniDFSNNTopology.simpleHAFederatedTopology(2))

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestPipelinesFailover.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public void testLeaseRecoveryAfterFailover() throws Exception {
324324
* DN running the recovery should then fail to commit the synchronization
325325
* and a later retry will succeed.
326326
*/
327-
@Test(timeout=30000)
327+
@Test(timeout=60000)
328328
public void testFailoverRightBeforeCommitSynchronization() throws Exception {
329329
final Configuration conf = new Configuration();
330330
// Disable permissions so that another user can recover the lease.

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestNestedSnapshots.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
package org.apache.hadoop.hdfs.server.namenode.snapshot;
1919

20-
import static org.apache.hadoop.hdfs.server.namenode.snapshot.DirectorySnapshottableFeature.SNAPSHOT_QUOTA_DEFAULT;
20+
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SNAPSHOT_MAX_LIMIT;
2121
import static org.junit.Assert.assertTrue;
2222

2323
import java.io.IOException;
@@ -61,13 +61,15 @@ public class TestNestedSnapshots {
6161

6262
private static final short REPLICATION = 3;
6363
private static final long BLOCKSIZE = 1024;
64+
private static final int SNAPSHOTLIMIT = 100;
6465

6566
private static final Configuration conf = new Configuration();
6667
private static MiniDFSCluster cluster;
6768
private static DistributedFileSystem hdfs;
6869

6970
@Before
7071
public void setUp() throws Exception {
72+
conf.setInt(DFS_NAMENODE_SNAPSHOT_MAX_LIMIT, SNAPSHOTLIMIT);
7173
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(REPLICATION)
7274
.build();
7375
cluster.waitActive();
@@ -199,7 +201,7 @@ private static void assertFile(Path s1, Path s2, Path file,
199201
* Test the snapshot limit of a single snapshottable directory.
200202
* @throws Exception
201203
*/
202-
@Test (timeout=300000)
204+
@Test (timeout=600000)
203205
public void testSnapshotLimit() throws Exception {
204206
final int step = 1000;
205207
final String dirStr = "/testSnapshotLimit/dir";
@@ -208,7 +210,8 @@ public void testSnapshotLimit() throws Exception {
208210
hdfs.allowSnapshot(dir);
209211

210212
int s = 0;
211-
for(; s < SNAPSHOT_QUOTA_DEFAULT; s++) {
213+
for(; s < SNAPSHOTLIMIT; s++) {
214+
SnapshotTestHelper.LOG.info("Creating snapshot number: {}", s);
212215
final String snapshotName = "s" + s;
213216
hdfs.createSnapshot(dir, snapshotName);
214217

@@ -226,10 +229,10 @@ public void testSnapshotLimit() throws Exception {
226229
SnapshotTestHelper.LOG.info("The exception is expected.", ioe);
227230
}
228231

229-
for(int f = 0; f < SNAPSHOT_QUOTA_DEFAULT; f += step) {
232+
for(int f = 0; f < SNAPSHOTLIMIT; f += step) {
230233
final String file = "f" + f;
231234
s = RANDOM.nextInt(step);
232-
for(; s < SNAPSHOT_QUOTA_DEFAULT; s += RANDOM.nextInt(step)) {
235+
for(; s < SNAPSHOTLIMIT; s += RANDOM.nextInt(step)) {
233236
final Path p = SnapshotTestHelper.getSnapshotPath(dir, "s" + s, file);
234237
//the file #f exists in snapshot #s iff s > f.
235238
Assert.assertEquals(s > f, hdfs.exists(p));

0 commit comments

Comments
 (0)