HDFS-2764. TestBackupNode is racy. Contributed by Aaron T. Myers.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1242553 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3ca0d208d1
commit
536d5dac48
|
@ -19,6 +19,8 @@ Release 0.23.2 - UNRELEASED
|
|||
HDFS-2923. Namenode IPC handler count uses the wrong configuration key
|
||||
(todd)
|
||||
|
||||
HDFS-2764. TestBackupNode is racy. (atm)
|
||||
|
||||
Release 0.23.1 - 2012-02-08
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||
import org.apache.hadoop.hdfs.server.common.Storage.StorageDirType;
|
||||
import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory;
|
||||
|
@ -59,6 +60,8 @@ import static org.mockito.Mockito.mock;
|
|||
*/
|
||||
public abstract class FSImageTestUtil {
|
||||
|
||||
public static final Log LOG = LogFactory.getLog(FSImageTestUtil.class);
|
||||
|
||||
/**
|
||||
* The position in the fsimage header where the txid is
|
||||
* written.
|
||||
|
@ -369,6 +372,8 @@ public abstract class FSImageTestUtil {
|
|||
List<Integer> txids) {
|
||||
|
||||
for (File nameDir : getNameNodeCurrentDirs(cluster)) {
|
||||
LOG.info("examining name dir with files: " +
|
||||
Joiner.on(",").join(nameDir.listFiles()));
|
||||
// Should have fsimage_N for the three checkpoints
|
||||
for (long checkpointTxId : txids) {
|
||||
File image = new File(nameDir,
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
package org.apache.hadoop.hdfs.server.namenode;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
@ -38,15 +40,15 @@ import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
|
|||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.apache.log4j.Level;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class TestBackupNode extends TestCase {
|
||||
public class TestBackupNode {
|
||||
public static final Log LOG = LogFactory.getLog(TestBackupNode.class);
|
||||
|
||||
|
||||
|
@ -57,8 +59,8 @@ public class TestBackupNode extends TestCase {
|
|||
|
||||
static final String BASE_DIR = MiniDFSCluster.getBaseDirectory();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
File baseDir = new File(BASE_DIR);
|
||||
if(baseDir.exists())
|
||||
if(!(FileUtil.fullyDelete(baseDir)))
|
||||
|
@ -89,8 +91,7 @@ public class TestBackupNode extends TestCase {
|
|||
return (BackupNode)NameNode.createNameNode(new String[]{startupOpt.getName()}, c);
|
||||
}
|
||||
|
||||
void waitCheckpointDone(
|
||||
MiniDFSCluster cluster, BackupNode backup, long txid) {
|
||||
void waitCheckpointDone(MiniDFSCluster cluster, long txid) {
|
||||
long thisCheckpointTxId;
|
||||
do {
|
||||
try {
|
||||
|
@ -98,9 +99,8 @@ public class TestBackupNode extends TestCase {
|
|||
"checkpoint txid should increase above " + txid);
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception e) {}
|
||||
thisCheckpointTxId = backup.getFSImage().getStorage()
|
||||
thisCheckpointTxId = cluster.getNameNode().getFSImage().getStorage()
|
||||
.getMostRecentCheckpointTxId();
|
||||
|
||||
} while (thisCheckpointTxId < txid);
|
||||
|
||||
// Check that the checkpoint got uploaded to NN successfully
|
||||
|
@ -108,6 +108,7 @@ public class TestBackupNode extends TestCase {
|
|||
Collections.singletonList((int)thisCheckpointTxId));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckpointNode() throws Exception {
|
||||
testCheckpoint(StartupOption.CHECKPOINT);
|
||||
}
|
||||
|
@ -117,6 +118,7 @@ public class TestBackupNode extends TestCase {
|
|||
* and keep in sync, even while the NN rolls, checkpoints
|
||||
* occur, etc.
|
||||
*/
|
||||
@Test
|
||||
public void testBackupNodeTailsEdits() throws Exception {
|
||||
Configuration conf = new HdfsConfiguration();
|
||||
MiniDFSCluster cluster = null;
|
||||
|
@ -234,6 +236,7 @@ public class TestBackupNode extends TestCase {
|
|||
FSImageTestUtil.assertParallelFilesAreIdentical(dirs, ImmutableSet.of("VERSION"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackupNode() throws Exception {
|
||||
testCheckpoint(StartupOption.BACKUP);
|
||||
}
|
||||
|
@ -270,7 +273,7 @@ public class TestBackupNode extends TestCase {
|
|||
//
|
||||
long txid = cluster.getNameNodeRpc().getTransactionID();
|
||||
backup = startBackupNode(conf, op, 1);
|
||||
waitCheckpointDone(cluster, backup, txid);
|
||||
waitCheckpointDone(cluster, txid);
|
||||
} catch(IOException e) {
|
||||
LOG.error("Error in TestBackupNode:", e);
|
||||
assertTrue(e.getLocalizedMessage(), false);
|
||||
|
@ -305,7 +308,7 @@ public class TestBackupNode extends TestCase {
|
|||
//
|
||||
backup = startBackupNode(conf, op, 1);
|
||||
long txid = cluster.getNameNodeRpc().getTransactionID();
|
||||
waitCheckpointDone(cluster, backup, txid);
|
||||
waitCheckpointDone(cluster, txid);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
fileSys.mkdirs(new Path("file_" + i));
|
||||
|
@ -313,11 +316,11 @@ public class TestBackupNode extends TestCase {
|
|||
|
||||
txid = cluster.getNameNodeRpc().getTransactionID();
|
||||
backup.doCheckpoint();
|
||||
waitCheckpointDone(cluster, backup, txid);
|
||||
waitCheckpointDone(cluster, txid);
|
||||
|
||||
txid = cluster.getNameNodeRpc().getTransactionID();
|
||||
backup.doCheckpoint();
|
||||
waitCheckpointDone(cluster, backup, txid);
|
||||
waitCheckpointDone(cluster, txid);
|
||||
|
||||
} catch(IOException e) {
|
||||
LOG.error("Error in TestBackupNode:", e);
|
||||
|
|
Loading…
Reference in New Issue