hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umamah...@apache.org
Subject svn commit: r1592694 - in /hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs: CHANGES-HDFS-2006.txt src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java src/test/resources/testXAttrConf.xml
Date Tue, 06 May 2014 09:28:30 GMT
Author: umamahesh
Date: Tue May  6 09:28:29 2014
New Revision: 1592694

URL: http://svn.apache.org/r1592694
Log:
HDFS-6298. XML based End-to-End test for getfattr and setfattr commands. Contributed by Yi
Liu

Added:
    hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java
    hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testXAttrConf.xml
Modified:
    hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-2006.txt

Modified: hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-2006.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-2006.txt?rev=1592694&r1=1592693&r2=1592694&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-2006.txt
(original)
+++ hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-2006.txt
Tue May  6 09:28:29 2014
@@ -23,6 +23,8 @@ HDFS-2006 (Unreleased)
     HDFS-6301. NameNode: persist XAttrs in fsimage and record XAttrs modifications to edit
log.
     (Yi Liu via umamahesh)
 
+    HDFS-6298. XML based End-to-End test for getfattr and setfattr commands. (Yi Liu via
umamahesh)
+
   OPTIMIZATIONS
 
   BUG FIXES

Added: hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java?rev=1592694&view=auto
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java
(added)
+++ hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java
Tue May  6 09:28:29 2014
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.cli;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.hadoop.cli.util.CLICommand;
+import org.apache.hadoop.cli.util.CommandExecutor.Result;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.HDFSPolicyProvider;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.security.authorize.PolicyProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestXAttrCLI  extends CLITestHelperDFS {
+  protected MiniDFSCluster dfsCluster = null;
+  protected FileSystem fs = null;
+  protected String namenode = null;
+  
+  @Before
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_XATTRS_ENABLED_KEY, true);
+    conf.setClass(PolicyProvider.POLICY_PROVIDER_CONFIG,
+        HDFSPolicyProvider.class, PolicyProvider.class);
+    conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 1);
+    
+    dfsCluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
+    dfsCluster.waitClusterUp();
+    namenode = conf.get(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "file:///");
+    
+    username = System.getProperty("user.name");
+
+    fs = dfsCluster.getFileSystem();
+    assertTrue("Not a HDFS: "+fs.getUri(), 
+        fs instanceof DistributedFileSystem);
+  }
+
+  @Override
+  protected String getTestFile() {
+    return "testXAttrConf.xml";
+  }
+  
+  @After
+  @Override
+  public void tearDown() throws Exception {
+    if (fs != null) {
+      fs.close();
+    }
+    if (dfsCluster != null) {
+      dfsCluster.shutdown();
+    }
+    Thread.sleep(2000);
+    super.tearDown();
+  }
+
+  @Override
+  protected String expandCommand(final String cmd) {
+    String expCmd = cmd;
+    expCmd = expCmd.replaceAll("NAMENODE", namenode);
+    expCmd = expCmd.replaceAll("#LF#",
+        System.getProperty("line.separator"));
+    expCmd = super.expandCommand(expCmd);
+    return expCmd;
+  }
+  
+  @Override
+  protected Result execute(CLICommand cmd) throws Exception {
+    return cmd.getExecutor(namenode).executeCommand(cmd.getCmd());
+  }
+  
+  @Test
+  @Override
+  public void testAll () {
+    super.testAll();
+  }
+
+}

Added: hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testXAttrConf.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testXAttrConf.xml?rev=1592694&view=auto
==============================================================================
--- hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testXAttrConf.xml
(added)
+++ hadoop/common/branches/HDFS-2006/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testXAttrConf.xml
Tue May  6 09:28:29 2014
@@ -0,0 +1,409 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="testConf.xsl"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<configuration>
+  <!-- Normal mode is test. To run just the commands and dump the output
+       to the log, set it to nocompare -->
+  <mode>test</mode>
+  
+  <!--  Comparator types:
+           ExactComparator
+           SubstringComparator
+           RegexpComparator
+           TokenComparator
+           -->
+  <tests>
+    <test>
+      <description>setfattr : Add an xattr</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -getfattr -d /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1="123456"</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Add an xattr which has wrong prefix</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n uuu.a1 -v 123456 /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>name must be prefixed with user/trusted/security/system,
followed by a '.'</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Add an xattr of trusted namespace</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n trusted.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -getfattr -d /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>trusted.a1="123456"</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Add an xattr of system namespace</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n system.a1 -v 123456 /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>setfattr: User doesn't have permission for xattr: system.a1</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Add an xattr of security namespace</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n security.a1 -v 123456 /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>setfattr: User doesn't have permission for xattr: security.a1</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Add an xattr, and encode is text</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v "123456" /file1</command>
+        <command>-fs NAMENODE -getfattr -d /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1="123456"</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Add an xattr, and encode is hex</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 0x313233343536 /file1</command>
+        <command>-fs NAMENODE -getfattr -d /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1="123456"</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Add an xattr, and encode is base64</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 0sMTIzNDU2 /file1</command>
+        <command>-fs NAMENODE -getfattr -d /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1="123456"</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Add multiple xattrs</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a2 -v abc /file1</command>
+        <command>-fs NAMENODE -getfattr -d /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1="123456"</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a2="abc"</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Remove an xattr</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a2 -v abc /file1</command>
+        <command>-fs NAMENODE -setfattr -x user.a1 /file1</command>
+        <command>-fs NAMENODE -getfattr -d /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+      	<comparator>
+          <type>ExactComparator</type>
+          <expected-output># file: /file1#LF#user.a2="abc"#LF#</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>setfattr : Remove an xattr which doesn't exist</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -setfattr -x user.a2 /file1</command>
+        <command>-fs NAMENODE -getfattr -d /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+      	<comparator>
+          <type>ExactComparator</type>
+          <expected-output># file: /file1#LF#user.a1="123456"#LF#</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>getfattr : Get an xattr</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a2 -v abc /file1</command>
+        <command>-fs NAMENODE -getfattr -n user.a1 /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1="123456"</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>getfattr : Get an xattr which doesn't exist</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -getfattr -n user.a1 /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+      	<comparator>
+          <type>ExactComparator</type>
+          <expected-output># file: /file1#LF#</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>getfattr : Get an xattr, and encode is text</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a2 -v abc /file1</command>
+        <command>-fs NAMENODE -getfattr -n user.a1 -e text /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1="123456"</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>getfattr : Get an xattr, and encode is hex</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a2 -v abc /file1</command>
+        <command>-fs NAMENODE -getfattr -n user.a1 -e hex /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1=0x313233343536</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>getfattr : Get an xattr, and encode is base64</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a2 -v abc /file1</command>
+        <command>-fs NAMENODE -getfattr -n user.a1 -e base64 /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output># file: /file1</expected-output>
+        </comparator>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>user.a1=0sMTIzNDU2</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>getfattr : Get an xattr, and encode is invalid</description>
+      <test-commands>
+        <command>-fs NAMENODE -touchz /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /file1</command>
+        <command>-fs NAMENODE -setfattr -n user.a2 -v abc /file1</command>
+        <command>-fs NAMENODE -getfattr -n user.a1 -e invalid /file1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm /file1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>SubstringComparator</type>
+          <expected-output>Invalid/unsupported encoding option specified: invalid</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+    <test>
+      <description>getfattr -R : recursive</description>
+      <test-commands>
+        <command>-fs NAMENODE -mkdir /dir1</command>
+        <command>-fs NAMENODE -setfattr -n user.a1 -v 123456 /dir1</command>
+        <command>-fs NAMENODE -mkdir /dir1/dir2</command>
+        <command>-fs NAMENODE -setfattr -n user.a2 -v abc /dir1/dir2</command>
+        <command>-fs NAMENODE -getfattr -R -d /dir1</command>
+      </test-commands>
+      <cleanup-commands>
+        <command>-fs NAMENODE -rm -R /dir1</command>
+      </cleanup-commands>
+      <comparators>
+        <comparator>
+          <type>ExactComparator</type>
+          <expected-output># file: /dir1#LF#user.a1="123456"#LF## file: /dir1/dir2#LF#user.a2="abc"#LF#</expected-output>
+        </comparator>
+      </comparators>
+    </test>
+    
+  </tests>
+</configuration>
\ No newline at end of file



Mime
View raw message