Skip to content

Commit d740a9d

Browse files
committed
HDFS-6528. Add XAttrs to TestOfflineImageViewer. Contributed by Stephen Chu.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1603020 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9938663 commit d740a9d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ Release 2.5.0 - UNRELEASED
447447
take FSN read lock when accessing pendingCached list.
448448
(wang)
449449

450+
HDFS-6528. Add XAttrs to TestOfflineImageViewer. (Stephen Chu via wang)
451+
450452
OPTIMIZATIONS
451453

452454
HDFS-6214. Webhdfs has poor throughput for files >2GB (daryn)

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)