bigtop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [2/5] bigtop git commit: ODPI-196. Adding tests to test the doas feature of httpfs.
Date Wed, 22 Mar 2017 06:02:56 GMT
ODPI-196. Adding tests to test the doas feature of httpfs.


Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/fbfb8405
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/fbfb8405
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/fbfb8405

Branch: refs/heads/master
Commit: fbfb8405ac02475da189e66a9201599eb1800757
Parents: fc407ec
Author: Clint Edwards <clint.edwards@sas.com>
Authored: Fri Oct 21 15:05:58 2016 -0400
Committer: Roman Shaposhnik <rvs@apache.org>
Committed: Tue Mar 21 23:01:18 2017 -0700

----------------------------------------------------------------------
 .../bigtop/itest/httpfs/TestHttpFs.groovy       | 118 ++++++++++++++-----
 1 file changed, 87 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/fbfb8405/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
----------------------------------------------------------------------
diff --git a/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
b/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
index bcec657..a4134a2 100644
--- a/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
+++ b/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
@@ -32,6 +32,7 @@ public class TestHttpFs {
   private static Log LOG = LogFactory.getLog(TestHttpFs.class)
 
   private static final String USERNAME = System.getProperty("user.name");
+  private static final String DOASUSER = 'hdfs';
   private static final String HTTPFS_PROXY = System.getenv('HTTPFS_PROXY');
   static {
     assertNotNull("HTTPFS_PROXY has to be set to run this test",
@@ -96,56 +97,59 @@ public class TestHttpFs {
     assertTrue(expected + " NOT found!", exists == true);
   }
 
-  private void createDir(String dirname) {
-    sh.exec("curl -i -X PUT '$HTTPFS_PREFIX$dirname?user.name=$USERNAME&op=MKDIRS'");
-  }
-
-  @Test
-  public void testCreateDir() {
-    createDir(testHttpFsFolder)
+  private void createDir(String dirname, String doasUser='') {
+    def doasStr = ''
+    if(doasUser.length()) {
+        doasStr = "doas=$doasUser&"
+    }
+    sh.exec("curl -i -X PUT '$HTTPFS_PREFIX$dirname?user.name=$USERNAME&${doasStr}op=MKDIRS'");
     assertTrue("curl command to create a dir failed", sh.getRet() == 0);
     assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
   }
 
-  @Test
-  public void testRenameDir() {
-    createDir(testHttpFsFolder);
-    assertTrue("curl command to create a dir failed", sh.getRet() == 0);
-    assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
-    sh.exec("curl -i -X PUT '$HTTPFS_PREFIX$testHttpFsFolder?user.name=$USERNAME&op=RENAME&destination=$testHttpFsFolderRenamed'");
+  private void renameDir(String dirname, String doasUser='') {
+    createDir(dirname, doasUser);
+    def doasStr = ''
+    if(doasUser.length()) {
+        doasStr = "doas=$doasUser&"
+    }
+    sh.exec("curl -i -X PUT '$HTTPFS_PREFIX$testHttpFsFolder?user.name=$USERNAME&${doasStr}op=RENAME&destination=$testHttpFsFolderRenamed'");
     assertTrue("curl command to rename a dir failed", sh.getRet() == 0);
     assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
   }
 
-  @Test
-  public void testDeleteDir() {
-    createDir(testHttpFsFolder);
-    assertTrue("curl command to create a dir failed", sh.getRet() == 0);
-    assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
-    sh.exec("curl -i -X DELETE '$HTTPFS_PREFIX$testHttpFsFolder?user.name=$USERNAME&op=DELETE'");
+  private void deleteDir(String dirname, String doasUser='') {
+    createDir(dirname, doasUser);
+    def doasStr = ''
+    if(doasUser.length()) {
+        doasStr = "doas=$doasUser&"
+    }
+    sh.exec("curl -i -X DELETE '$HTTPFS_PREFIX$testHttpFsFolder?user.name=$USERNAME&${doasStr}op=DELETE'");
     assertTrue("curl command to delete a dir failed", sh.getRet() == 0);
     assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
   }
 
-  @Test
-  public void testStatusDir() {
-    createDir(testHttpFsFolder);
-    assertTrue("curl command to create a dir failed", sh.getRet() == 0);
-    assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
-    sh.exec("curl -i '$HTTPFS_PREFIX$testHttpFsFolder?user.name=$USERNAME&op=GETFILESTATUS'");
+  private void statusDir(String dirname, String doasUser='') {
+    createDir(dirname, doasUser);
+    def doasStr = ''
+    if(doasUser.length()) {
+        doasStr = "doas=$doasUser&"
+    }
+    sh.exec("curl -i '$HTTPFS_PREFIX$testHttpFsFolder?user.name=$USERNAME&${doasStr}op=GETFILESTATUS'");
     assertTrue("curl command to create a dir failed", sh.getRet() == 0);
     assertValueContains(sh.getOut(), "DIRECTORY");
     assertValueExists(sh.getOut(), HTTP_OK);
   }
 
-  @Test
-  public void testCreateFile() {
-    String filename = "helloworld.txt";
+  private void createFile(String filename, String doasUser='') {
     String filenameContent = 'Hello World!';
+    def doasStr = ''
+    if(doasUser.length()) {
+        doasStr = "doas=$doasUser&"
+    }
 
-    createDir(testHttpFsFolder);
-    assertTrue("curl command to create a dir failed", sh.getRet() == 0);
-    sh.exec("curl -i -X PUT '$HTTPFS_PREFIX$testHttpFsFolder/$filename?user.name=$USERNAME&op=CREATE'");
+    createDir(testHttpFsFolder, doasUser);
+    sh.exec("curl -i -X PUT '$HTTPFS_PREFIX$testHttpFsFolder/$filename?user.name=$USERNAME&${doasStr}op=CREATE'");
     assertTrue("curl command to create a file failed", sh.getRet() == 0);
     String datanodeLocation = null;
     sh.getOut().each {
@@ -165,5 +169,57 @@ public class TestHttpFs {
     assertValueExists(sh.getOut(), HTTP_OK);
     assertValueExists(sh.getOut(), filenameContent);
   }
+
+  @Test
+  public void testCreateDir() {
+    createDir(testHttpFsFolder)
+  }
+
+  @Test
+  public void testCreateDirAsUser() {
+    createDir(testHttpFsFolder, DOASUSER)
+  }
+
+  @Test
+  public void testRenameDir() {
+    renameDir(testHttpFsFolder);
+  }
+
+  @Test
+  public void testRenameDirAsUser() {
+    renameDir(testHttpFsFolder, DOASUSER);
+  }
+
+  @Test
+  public void testDeleteDir() {
+    deleteDir(testHttpFsFolder);
+  }
+
+  @Test
+  public void testDeleteDirAsUser() {
+    deleteDir(testHttpFsFolder, DOASUSER);
+  }
+
+  @Test
+  public void testStatusDir() {
+    statusDir(testHttpFsFolder);
+  }
+
+  @Test
+  public void testStatusDirAsUser() {
+    statusDir(testHttpFsFolder, DOASUSER);
+  }
+
+  @Test
+  public void testCreateFile() {
+    String filename = "helloworld.txt";
+    createFile(filename)
+  }
+
+  @Test
+  public void testCreateFileAsUser() {
+    String filename = "helloworld.txt";
+    createFile(filename, DOASUSER)
+  }
 }
 


Mime
View raw message