File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 8686import org .junit .Test ;
8787
8888import static org .junit .Assert .assertArrayEquals ;
89+ import static org .junit .Assert .fail ;
8990
9091public 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
You can’t perform that action at this time.
0 commit comments