hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject svn commit: r1609393 - in /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestXAttrWithSnapshot.java
Date Thu, 10 Jul 2014 05:14:08 GMT
Author: jing9
Date: Thu Jul 10 05:14:08 2014
New Revision: 1609393

URL: http://svn.apache.org/r1609393
Log:
HDFS-6645. Merge change r1609388 from trunk.

Modified:
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestXAttrWithSnapshot.java

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1609393&r1=1609392&r2=1609393&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Thu Jul 10
05:14:08 2014
@@ -18,6 +18,9 @@ Release 2.6.0 - UNRELEASED
     HDFS-6627. Rename DataNode#checkWriteAccess to checkReadAccess.
     (Liang Xie via cnauroth)
 
+    HDFS-6645. Add test for successive Snapshots between XAttr modifications.
+    (Stephen Chu via jing9)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestXAttrWithSnapshot.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestXAttrWithSnapshot.java?rev=1609393&r1=1609392&r2=1609393&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestXAttrWithSnapshot.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestXAttrWithSnapshot.java
Thu Jul 10 05:14:08 2014
@@ -57,8 +57,8 @@ public class TestXAttrWithSnapshot {
   private static Configuration conf;
   private static DistributedFileSystem hdfs;
   private static int pathCount = 0;
-  private static Path path, snapshotPath;
-  private static String snapshotName;
+  private static Path path, snapshotPath, snapshotPath2, snapshotPath3;
+  private static String snapshotName, snapshotName2, snapshotName3;
   private final int SUCCESS = 0;
   // XAttrs
   private static final String name1 = "user.a1";
@@ -90,7 +90,11 @@ public class TestXAttrWithSnapshot {
     ++pathCount;
     path = new Path("/p" + pathCount);
     snapshotName = "snapshot" + pathCount;
+    snapshotName2 = snapshotName + "-2";
+    snapshotName3 = snapshotName + "-3";
     snapshotPath = new Path(path, new Path(".snapshot", snapshotName));
+    snapshotPath2 = new Path(path, new Path(".snapshot", snapshotName2));
+    snapshotPath3 = new Path(path, new Path(".snapshot", snapshotName3));
   }
 
   /**
@@ -261,6 +265,62 @@ public class TestXAttrWithSnapshot {
   }
 
   /**
+   * Test successive snapshots in between modifications of XAttrs.
+   * Also verify that snapshot XAttrs are not altered when a
+   * snapshot is deleted.
+   */
+  @Test
+  public void testSuccessiveSnapshotXAttrChanges() throws Exception {
+    // First snapshot
+    FileSystem.mkdirs(hdfs, path, FsPermission.createImmutable((short) 0700));
+    hdfs.setXAttr(path, name1, value1);
+    SnapshotTestHelper.createSnapshot(hdfs, path, snapshotName);
+    Map<String, byte[]> xattrs = hdfs.getXAttrs(snapshotPath);
+    Assert.assertEquals(1, xattrs.size());
+    Assert.assertArrayEquals(value1, xattrs.get(name1));
+
+    // Second snapshot
+    hdfs.setXAttr(path, name1, newValue1);
+    hdfs.setXAttr(path, name2, value2);
+    SnapshotTestHelper.createSnapshot(hdfs, path, snapshotName2);
+    xattrs = hdfs.getXAttrs(snapshotPath2);
+    Assert.assertEquals(2, xattrs.size());
+    Assert.assertArrayEquals(newValue1, xattrs.get(name1));
+    Assert.assertArrayEquals(value2, xattrs.get(name2));
+
+    // Third snapshot
+    hdfs.setXAttr(path, name1, value1);
+    hdfs.removeXAttr(path, name2);
+    SnapshotTestHelper.createSnapshot(hdfs, path, snapshotName3);
+    xattrs = hdfs.getXAttrs(snapshotPath3);
+    Assert.assertEquals(1, xattrs.size());
+    Assert.assertArrayEquals(value1, xattrs.get(name1));
+
+    // Check that the first and second snapshots'
+    // XAttrs have stayed constant
+    xattrs = hdfs.getXAttrs(snapshotPath);
+    Assert.assertEquals(1, xattrs.size());
+    Assert.assertArrayEquals(value1, xattrs.get(name1));
+    xattrs = hdfs.getXAttrs(snapshotPath2);
+    Assert.assertEquals(2, xattrs.size());
+    Assert.assertArrayEquals(newValue1, xattrs.get(name1));
+    Assert.assertArrayEquals(value2, xattrs.get(name2));
+
+    // Remove the second snapshot and verify the first and
+    // third snapshots' XAttrs have stayed constant
+    hdfs.deleteSnapshot(path, snapshotName2);
+    xattrs = hdfs.getXAttrs(snapshotPath);
+    Assert.assertEquals(1, xattrs.size());
+    Assert.assertArrayEquals(value1, xattrs.get(name1));
+    xattrs = hdfs.getXAttrs(snapshotPath3);
+    Assert.assertEquals(1, xattrs.size());
+    Assert.assertArrayEquals(value1, xattrs.get(name1));
+
+    hdfs.deleteSnapshot(path, snapshotName);
+    hdfs.deleteSnapshot(path, snapshotName3);
+  }
+
+  /**
    * Assert exception of setting xattr on read-only snapshot.
    */
   @Test



Mime
View raw message