@@ -138,6 +138,13 @@ public static void createOriginalFSImage() throws IOException {
138138 hdfs .mkdirs (new Path ("/snapshot/1" ));
139139 hdfs .delete (snapshot , true );
140140
141+ // Set XAttrs so the fsimage contains XAttr ops
142+ final Path xattr = new Path ("/xattr" );
143+ hdfs .mkdirs (xattr );
144+ hdfs .setXAttr (xattr , "user.a1" , new byte []{ 0x31 , 0x32 , 0x33 });
145+ hdfs .setXAttr (xattr , "user.a2" , new byte []{ 0x37 , 0x38 , 0x39 });
146+ writtenFiles .put (xattr .toString (), hdfs .getFileStatus (xattr ));
147+
141148 // Write results to the fsimage file
142149 hdfs .setSafeMode (SafeModeAction .SAFEMODE_ENTER , false );
143150 hdfs .saveNamespace ();
@@ -210,8 +217,8 @@ public void testFileDistributionCalculator() throws IOException {
210217 matcher = p .matcher (output .getBuffer ());
211218 assertTrue (matcher .find () && matcher .groupCount () == 1 );
212219 int totalDirs = Integer .parseInt (matcher .group (1 ));
213- // totalDirs includes root directory and empty directory
214- assertEquals (NUM_DIRS + 2 , totalDirs );
220+ // totalDirs includes root directory, empty directory, and xattr directory
221+ assertEquals (NUM_DIRS + 3 , totalDirs );
215222
216223 FileStatus maxFile = Collections .max (writtenFiles .values (),
217224 new Comparator <FileStatus >() {
@@ -264,7 +271,7 @@ public void testWebImageViewer() throws IOException, InterruptedException,
264271
265272 // verify the number of directories
266273 FileStatus [] statuses = webhdfs .listStatus (new Path ("/" ));
267- assertEquals (NUM_DIRS + 1 , statuses .length ); // contains empty directory
274+ assertEquals (NUM_DIRS + 2 , statuses .length ); // contains empty and xattr directory
268275
269276 // verify the number of files in the directory
270277 statuses = webhdfs .listStatus (new Path ("/dir0" ));
0 commit comments