Skip to content

Commit 95909ec

Browse files
committed
addtestcase
1 parent ef4d239 commit 95909ec

File tree

1 file changed

+26
-0
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
import org.junit.Test;
8787

8888
import static org.junit.Assert.assertArrayEquals;
89+
import static org.junit.Assert.fail;
8990

9091
public class TestFSImage {
9192

@@ -275,6 +276,31 @@ public void testSaveAndLoadStripedINodeFile() throws IOException{
275276
}
276277
}
277278

279+
@Test
280+
public void testImportCheckpoint() throws IOException{
281+
Configuration conf = new Configuration();
282+
conf.set(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_EDITS_DIR_KEY,"");
283+
MiniDFSCluster cluster = null;
284+
try {
285+
cluster = new MiniDFSCluster.Builder(conf).build();
286+
cluster.waitActive();
287+
FSNamesystem fsn = cluster.getNamesystem();
288+
FSImage fsImage= new FSImage(conf);
289+
try {
290+
fsImage.doImportCheckpoint(fsn);
291+
fail("Expect to throw IOException.");
292+
} catch (IOException e) {
293+
GenericTestUtils.assertExceptionContains(
294+
"Cannot import image from a checkpoint. "
295+
+ "\"dfs.namenode.checkpoint.edits.dir\" is not set.", e);
296+
}
297+
} finally {
298+
if (cluster != null) {
299+
cluster.shutdown();
300+
}
301+
}
302+
}
303+
278304
/**
279305
* Test if a INodeFileUnderConstruction with BlockInfoStriped can be
280306
* saved and loaded by FSImageSerialization

0 commit comments

Comments
 (0)