sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shreepa...@apache.org
Subject git commit: SENTRY-10: Change the inheritance model of Abstract FileSystem classes to composition along with a Factory class, which allows us to use different FS implementations (Sravya Tirukkovalur via Shreepadma Venugopalan)
Date Tue, 08 Oct 2013 01:28:17 GMT
Updated Branches:
  refs/heads/master ef54e1327 -> 5950ba8b1


SENTRY-10: Change the inheritance model of Abstract FileSystem classes to composition along with a Factory class, which allows us to use different FS implementations (Sravya Tirukkovalur via Shreepadma Venugopalan)


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/5950ba8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/5950ba8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/5950ba8b

Branch: refs/heads/master
Commit: 5950ba8b1ff79c0baa2cdf883d4b3005117dc01b
Parents: ef54e13
Author: Shreepadma Venugopalan <shreepadma@apache.org>
Authored: Mon Oct 7 18:27:42 2013 -0700
Committer: Shreepadma Venugopalan <shreepadma@apache.org>
Committed: Mon Oct 7 18:27:42 2013 -0700

----------------------------------------------------------------------
 .../e2e/hive/AbstractTestWithHiveServer.java    |  1 +
 .../AbstractTestWithStaticConfiguration.java    | 26 ++++++--
 .../e2e/hive/AbstractTestWithStaticDFS.java     | 69 --------------------
 .../e2e/hive/AbstractTestWithStaticLocalFS.java | 37 -----------
 .../sentry/tests/e2e/hive/TestCrossDbOps.java   |  2 +-
 .../sentry/tests/e2e/hive/TestEndToEnd.java     |  2 +-
 .../e2e/hive/TestExportImportPrivileges.java    |  2 +-
 .../e2e/hive/TestMetadataObjectRetrieval.java   |  2 +-
 .../tests/e2e/hive/TestMetadataPermissions.java |  3 +-
 .../tests/e2e/hive/TestMovingToProduction.java  |  6 +-
 .../tests/e2e/hive/TestPerDBConfiguration.java  |  2 +-
 .../e2e/hive/TestPerDatabasePolicyFile.java     |  2 +-
 .../e2e/hive/TestPrivilegeAtTransform.java      |  2 +-
 .../e2e/hive/TestPrivilegesAtDatabaseScope.java | 58 +---------------
 .../e2e/hive/TestPrivilegesAtFunctionScope.java |  6 +-
 .../e2e/hive/TestPrivilegesAtTableScope.java    |  2 +-
 .../e2e/hive/TestRuntimeMetadataRetrieval.java  |  2 +-
 .../sentry/tests/e2e/hive/TestSandboxOps.java   | 10 +--
 .../tests/e2e/hive/TestServerConfiguration.java | 51 +++++++++++++++
 .../tests/e2e/hive/TestUriPermissions.java      |  4 +-
 .../tests/e2e/hive/TestUserManagement.java      |  2 +-
 .../sentry/tests/e2e/hive/fs/AbstractDFS.java   | 66 +++++++++++++++++++
 .../apache/sentry/tests/e2e/hive/fs/DFS.java    | 30 +++++++++
 .../sentry/tests/e2e/hive/fs/DFSFactory.java    | 45 +++++++++++++
 .../sentry/tests/e2e/hive/fs/MiniDFS.java       | 54 +++++++++++++++
 .../e2e/hive/hiveserver/HiveServerFactory.java  |  2 +-
 26 files changed, 295 insertions(+), 193 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithHiveServer.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithHiveServer.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithHiveServer.java
index cae15ae..0258c2d 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithHiveServer.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithHiveServer.java
@@ -42,6 +42,7 @@ public abstract class AbstractTestWithHiveServer {
   protected File policyFile;
   protected HiveServer hiveServer;
   protected FileSystem fileSystem;
+
   protected static final String ADMIN1 = StaticUserGroup.ADMIN1,
       ADMINGROUP = StaticUserGroup.ADMINGROUP,
       USER1_1 = StaticUserGroup.USER1_1,

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
index ba05044..8e46905 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
@@ -26,9 +26,12 @@ import junit.framework.Assert;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.sentry.tests.e2e.hive.fs.DFSFactory;
+import org.apache.sentry.tests.e2e.hive.fs.DFS;
 import org.apache.sentry.tests.e2e.hive.hiveserver.HiveServer;
 import org.apache.sentry.tests.e2e.hive.hiveserver.HiveServerFactory;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -79,15 +82,16 @@ public abstract class AbstractTestWithStaticConfiguration {
   protected static File logDir;
   protected static File confDir;
   protected static File dataDir;
-  protected static File policyFile;
+  protected static File policyFileLocation;
   protected static HiveServer hiveServer;
   protected static FileSystem fileSystem;
+  protected static DFS dfs;
   protected static Map<String, String> properties;
   protected Context context;
 
   public Context createContext() throws Exception {
     return new Context(hiveServer, fileSystem,
-        baseDir, confDir, dataDir, policyFile);
+        baseDir, confDir, dataDir, policyFileLocation);
   }
   protected void dropDb(String user, String...dbs) throws Exception {
     Connection connection = context.createConnection(user, "password");
@@ -133,9 +137,6 @@ public abstract class AbstractTestWithStaticConfiguration {
     return dir;
   }
 
-  protected FileSystem getFileSystem() {
-    return fileSystem;
-  }
   @BeforeClass
   public static void setupTestStaticConfiguration()
       throws Exception {
@@ -145,7 +146,19 @@ public abstract class AbstractTestWithStaticConfiguration {
     logDir = assertCreateDir(new File(baseDir, "log"));
     confDir = assertCreateDir(new File(baseDir, "etc"));
     dataDir = assertCreateDir(new File(baseDir, "data"));
-    policyFile = new File(confDir, HiveServerFactory.AUTHZ_PROVIDER_FILENAME);
+    policyFileLocation = new File(confDir, HiveServerFactory.AUTHZ_PROVIDER_FILENAME);
+
+    String dfsType = System.getProperty(DFSFactory.FS_TYPE);
+    dfs = DFSFactory.create(dfsType, baseDir);
+
+    fileSystem = dfs.getFileSystem();
+    hiveServer = HiveServerFactory.create(properties, baseDir, confDir, logDir, policyFileLocation, fileSystem);
+    hiveServer.start();
+  }
+
+  @Before
+  public void setup() throws Exception{
+    dfs.createBaseDir();
   }
 
   @AfterClass
@@ -160,5 +173,6 @@ public abstract class AbstractTestWithStaticConfiguration {
       }
       baseDir = null;
     }
+    dfs.tearDown();
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticDFS.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticDFS.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticDFS.java
deleted file mode 100644
index f670f89..0000000
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticDFS.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.sentry.tests.e2e.hive;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.Assert;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.sentry.tests.e2e.hive.hiveserver.HiveServerFactory;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-public abstract class AbstractTestWithStaticDFS extends AbstractTestWithStaticConfiguration {
-
-  protected static MiniDFSCluster dfsCluster;
-  protected static Path dfsBaseDir;
-
-  @Before
-  public void setupTestWithDFS() throws IOException {
-    Assert.assertTrue(dfsBaseDir.toString(), fileSystem.delete(dfsBaseDir, true));
-    Assert.assertTrue(dfsBaseDir.toString(), fileSystem.mkdirs(dfsBaseDir));
-  }
-
-  protected static Path assertCreateDfsDir(Path dir) throws IOException {
-    if(!fileSystem.isDirectory(dir)) {
-      Assert.assertTrue("Failed creating " + dir, fileSystem.mkdirs(dir));
-    }
-    return dir;
-  }
-  @BeforeClass
-  public static void setupTestWithStaticDFS()
-      throws Exception {
-    Configuration conf = new Configuration();
-    File dfsDir = assertCreateDir(new File(baseDir, "dfs"));
-    conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, dfsDir.getPath());
-    dfsCluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
-    fileSystem = dfsCluster.getFileSystem();
-    dfsBaseDir = assertCreateDfsDir(new Path(new Path(fileSystem.getUri()), "/base"));
-    hiveServer = HiveServerFactory.create(properties, baseDir, confDir, logDir, policyFile, fileSystem);
-    hiveServer.start();
-  }
-
-  @AfterClass
-  public static void tearDownTestWithStaticDFS() throws Exception {
-    if(dfsCluster != null) {
-      dfsCluster.shutdown();
-      dfsCluster = null;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticLocalFS.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticLocalFS.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticLocalFS.java
deleted file mode 100644
index 3954b9a..0000000
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticLocalFS.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.sentry.tests.e2e.hive;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.sentry.tests.e2e.hive.hiveserver.HiveServerFactory;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractTestWithStaticLocalFS extends AbstractTestWithStaticConfiguration {
-  @SuppressWarnings("unused")
-  private static final Logger LOGGER = LoggerFactory
-      .getLogger(AbstractTestWithStaticLocalFS.class);
-  @BeforeClass
-  public static void setupTestWithStaticHiveServer()
-      throws Exception {
-    fileSystem = FileSystem.get(new Configuration());
-    hiveServer = HiveServerFactory.create(properties, baseDir, confDir, logDir, policyFile, fileSystem);
-    hiveServer.start();
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java
index 85ddc67..6290aaa 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java
@@ -41,7 +41,7 @@ import com.google.common.io.Resources;
 
 /* Tests privileges at table scope with cross database access */
 
-public class TestCrossDbOps extends AbstractTestWithStaticLocalFS {
+public class TestCrossDbOps extends AbstractTestWithStaticConfiguration {
   private File dataFile;
   private PolicyFile policyFile;
   private String loadData;

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestEndToEnd.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestEndToEnd.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestEndToEnd.java
index ff8fd9c..b31a135 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestEndToEnd.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestEndToEnd.java
@@ -29,7 +29,7 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class TestEndToEnd extends AbstractTestWithStaticLocalFS {
+public class TestEndToEnd extends AbstractTestWithStaticConfiguration {
   private Context context;
   private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";
   private File dataFile;

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestExportImportPrivileges.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestExportImportPrivileges.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestExportImportPrivileges.java
index 304b2af..3cef55e 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestExportImportPrivileges.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestExportImportPrivileges.java
@@ -31,7 +31,7 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class TestExportImportPrivileges extends AbstractTestWithStaticDFS {
+public class TestExportImportPrivileges extends AbstractTestWithStaticConfiguration {
   private File dataFile;
   private PolicyFile policyFile;
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataObjectRetrieval.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataObjectRetrieval.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataObjectRetrieval.java
index cd8daf2..9f639b2 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataObjectRetrieval.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataObjectRetrieval.java
@@ -34,7 +34,7 @@ import org.junit.Test;
 import com.google.common.io.Resources;
 
 public class TestMetadataObjectRetrieval extends
-AbstractTestWithStaticLocalFS {
+AbstractTestWithStaticConfiguration {
   private PolicyFile policyFile;
   private File dataFile;
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataPermissions.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataPermissions.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataPermissions.java
index 57b9532..8d1f4ac 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataPermissions.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMetadataPermissions.java
@@ -27,7 +27,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 
-public class TestMetadataPermissions extends AbstractTestWithStaticLocalFS {
+public class TestMetadataPermissions extends AbstractTestWithStaticConfiguration {
   private Context context;
   private PolicyFile policyFile;
 
@@ -55,7 +55,6 @@ public class TestMetadataPermissions extends AbstractTestWithStaticLocalFS {
         adminStmt.execute("CREATE TABLE " + tabName + " (id int)");
       }
     }
-    context.close();
   }
 
   @After

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMovingToProduction.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMovingToProduction.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMovingToProduction.java
index 5d53154..f6e8d26 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMovingToProduction.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestMovingToProduction.java
@@ -33,7 +33,7 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class TestMovingToProduction extends AbstractTestWithStaticLocalFS {
+public class TestMovingToProduction extends AbstractTestWithStaticConfiguration {
   private Context context;
   private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";
   private PolicyFile policyFile;
@@ -104,7 +104,7 @@ public class TestMovingToProduction extends AbstractTestWithStaticLocalFS {
     statement.execute("DROP TABLE IF EXISTS " + tableName1);
     statement.execute("create table " + tableName1
         + " (under_col int comment 'the under column', value string)");
-    statement.execute("LOAD DATA INPATH 'file://" + dataDir.getPath()
+    statement.execute("LOAD DATA LOCAL INPATH 'file://" + dataDir.getPath()
         + "' INTO TABLE " + tableName1);
 
     policyFile
@@ -183,7 +183,7 @@ public class TestMovingToProduction extends AbstractTestWithStaticLocalFS {
     statement.execute("DROP TABLE IF EXISTS " + dbName1 + "." + tableName1);
     statement.execute("create table " + dbName1 + "." + tableName1
         + " (under_col int comment 'the under column', value string)");
-    statement.execute("LOAD DATA INPATH 'file://" + dataDir.getPath()
+    statement.execute("LOAD DATA LOCAL INPATH 'file://" + dataDir.getPath()
         + "' INTO TABLE " + dbName1 + "." + tableName1);
 
     policyFile

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java
index dbe1928..cc1243c 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDBConfiguration.java
@@ -37,7 +37,7 @@ import com.google.common.io.Resources;
 /**
  * Test privileges per database policy files
  */
-public class TestPerDBConfiguration extends AbstractTestWithStaticLocalFS {
+public class TestPerDBConfiguration extends AbstractTestWithStaticConfiguration {
   private static final String MULTI_TYPE_DATA_FILE_NAME = "emp.dat";
   private static final String DB2_POLICY_FILE = "db2-policy-file.ini";
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java
index 9a03728..7c79912 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPerDatabasePolicyFile.java
@@ -31,7 +31,7 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class TestPerDatabasePolicyFile extends AbstractTestWithStaticLocalFS {
+public class TestPerDatabasePolicyFile extends AbstractTestWithStaticConfiguration {
   private static final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";
   private Context context;
   private PolicyFile policyFile;

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java
index 2b309d8..92b4485 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegeAtTransform.java
@@ -31,7 +31,7 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class TestPrivilegeAtTransform extends AbstractTestWithStaticLocalFS {
+public class TestPrivilegeAtTransform extends AbstractTestWithStaticConfiguration {
   private Context context;
   private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";
   private File dataDir;

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java
index ae0688a..d5c4611 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtDatabaseScope.java
@@ -42,7 +42,7 @@ import com.google.common.io.Resources;
 /* Tests privileges at table scope within a single database.
  */
 
-public class TestPrivilegesAtDatabaseScope extends AbstractTestWithHiveServer {
+public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfiguration {
 
   private Context context;
   private File dataFile;
@@ -54,7 +54,9 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithHiveServer {
   @Before
   public void setup() throws Exception {
     testProperties = new HashMap<String, String>();
+
     policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP);
+    context = createContext();
   }
 
   @After
@@ -69,7 +71,6 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithHiveServer {
    */
   @Test
   public void testAllPrivilege() throws Exception {
-    context = createContext(testProperties);
 
     //copy data file to test dir
     File dataDir = context.getDataDir();
@@ -180,7 +181,6 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithHiveServer {
    */
   @Test
   public void testAllPrivilegeOnObjectOwnedByAdmin() throws Exception {
-    context = createContext(testProperties);
 
     //copy data file to test dir
     File dataDir = context.getDataDir();
@@ -306,7 +306,6 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithHiveServer {
    */
   @Test
   public void testUseDbPrivilege() throws Exception {
-    context = createContext(testProperties);
 
     policyFile
         .addRolesToGroup(USERGROUP1, "all_db1")
@@ -370,7 +369,6 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithHiveServer {
    */
   @Test
   public void testDefaultDbPrivilege() throws Exception {
-    context = createContext(testProperties);
 
     policyFile
         .addRolesToGroup(USERGROUP1, "all_db1")
@@ -403,54 +401,4 @@ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithHiveServer {
     context.close();
   }
 
-  /**
-   * Test access to default DB with explicit privilege requirement
-   * Admin should be able to run use default with server level access
-   * User with db level access should be able to run use default
-   * User with table level access should be able to run use default
-   * User with no access to default db objects, should NOT be able run use default
-   * @throws Exception
-   */
-  @Test
-  public void testDefaultDbRestrictivePrivilege() throws Exception {
-    testProperties.put(AuthzConfVars.AUTHZ_RESTRICT_DEFAULT_DB.getVar(), "true");
-    context = createContext(testProperties);
-
-    policyFile
-        .addRolesToGroup(USERGROUP1, "all_default")
-        .addRolesToGroup(USERGROUP2, "select_default")
-        .addRolesToGroup(USERGROUP3, "all_db1")
-        .addPermissionsToRole("all_default", "server=server1->db=default")
-        .addPermissionsToRole("select_default", "server=server1->db=default->table=tab_2->action=select")
-        .addPermissionsToRole("all_db1", "server=server1->db=DB_1")
-        .setUserGroupMapping(StaticUserGroup.getStaticMapping())
-        .write(context.getPolicyFile());
-
-    Connection connection = context.createConnection(ADMIN1, "hive");
-    Statement statement = context.createStatement(connection);
-    statement.execute("use default");
-    context.close();
-
-    connection = context.createConnection(USER1_1, "hive");
-    statement = context.createStatement(connection);
-    statement.execute("use default");
-    context.close();
-
-    connection = context.createConnection(USER2_1, "hive");
-    statement = context.createStatement(connection);
-    statement.execute("use default");
-    context.close();
-
-    connection = context.createConnection(USER3_1, "hive");
-    statement = context.createStatement(connection);
-    try {
-      // user3 doesn't have any implicit permission for default
-      statement.execute("use default");
-      assertFalse("user3 shouldn't be able switch to default", true);
-    } catch (SQLException e) {
-      context.verifyAuthzException(e);
-    }
-    context.close();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
index 3194790..1b5447b 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtFunctionScope.java
@@ -32,7 +32,7 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticLocalFS {
+public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticConfiguration {
   private Context context;
   private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";
   private File dataDir;
@@ -87,7 +87,7 @@ public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticLocalFS
     statement.execute("DROP TABLE IF EXISTS " + dbName1 + "." + tableName1);
     statement.execute("create table " + dbName1 + "." + tableName1
         + " (under_col int comment 'the under column', value string)");
-    statement.execute("LOAD DATA INPATH '" + dataFile.getPath() + "' INTO TABLE "
+    statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE "
         + dbName1 + "." + tableName1);
     statement.execute("DROP TEMPORARY FUNCTION IF EXISTS printf_test");
     statement.execute("DROP TEMPORARY FUNCTION IF EXISTS printf_test_2");
@@ -161,7 +161,7 @@ public class TestPrivilegesAtFunctionScope extends AbstractTestWithStaticLocalFS
     statement.execute("USE " + dbName1);
     statement.execute("create table " + tableName1
         + " (under_col int comment 'the under column', value string)");
-    statement.execute("LOAD DATA INPATH '" + dataFile.getPath() + "' INTO TABLE "
+    statement.execute("LOAD DATA LOCAL INPATH '" + dataFile.getPath() + "' INTO TABLE "
         + dbName1 + "." + tableName1);
     statement.execute("SELECT rand(), concat(value, '_foo') FROM " + tableName1);
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java
index a5c36ad..92ec6f5 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtTableScope.java
@@ -40,7 +40,7 @@ import com.google.common.io.Resources;
 /* Tests privileges at table scope within a single database.
  */
 
-public class TestPrivilegesAtTableScope extends AbstractTestWithStaticLocalFS {
+public class TestPrivilegesAtTableScope extends AbstractTestWithStaticConfiguration {
 
   private Context context;
   private PolicyFile policyFile;

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java
index cd398da..31985bd 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java
@@ -41,7 +41,7 @@ import com.google.common.io.Resources;
  */
 public class TestRuntimeMetadataRetrieval
     extends
-      AbstractTestWithStaticLocalFS {
+      AbstractTestWithStaticConfiguration {
   private Context context;
   private PolicyFile policyFile;
   private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestSandboxOps.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestSandboxOps.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestSandboxOps.java
index d830c21..49dbbde 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestSandboxOps.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestSandboxOps.java
@@ -35,7 +35,7 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class TestSandboxOps  extends AbstractTestWithStaticDFS {
+public class TestSandboxOps  extends AbstractTestWithStaticConfiguration {
   private PolicyFile policyFile;
   private File dataFile;
   private String loadData;
@@ -452,8 +452,8 @@ public class TestSandboxOps  extends AbstractTestWithStaticDFS {
         "test-" + (counter++)));
     File restrictedDir = assertCreateDir(new File(baseDir,
         "test-" + (counter++)));
-    Path allowedDfsDir = assertCreateDfsDir(new Path(dfsBaseDir, "test-" + (counter++)));
-    Path restrictedDfsDir = assertCreateDfsDir(new Path(dfsBaseDir, "test-" + (counter++)));
+    Path allowedDfsDir = dfs.assertCreateDir("test-" + (counter++));
+    Path restrictedDfsDir = dfs.assertCreateDir("test-" + (counter++));
 
     policyFile
         .addRolesToGroup(USERGROUP1, "all_db1", "load_data")
@@ -524,8 +524,8 @@ public class TestSandboxOps  extends AbstractTestWithStaticDFS {
         .addRolesToGroup(USERGROUP1, "select_tbl1")
         .addRolesToGroup(USERGROUP2, "select_tbl2")
         .addPermissionsToRole("select_tbl1", "server=server1->db=db1->table=tbl1->action=select")
-        .addDatabase("db2", dfsBaseDir.toUri().toString() + "/" + DB2_POLICY_FILE)
         .setUserGroupMapping(StaticUserGroup.getStaticMapping())
+        .addDatabase("db2", dfs.getBaseDir().toUri().toString() + "/" + DB2_POLICY_FILE)
         .write(context.getPolicyFile());
 
     File db2PolicyFileHandle = new File(baseDir.getPath(), DB2_POLICY_FILE);
@@ -535,7 +535,7 @@ public class TestSandboxOps  extends AbstractTestWithStaticDFS {
         .addRolesToGroup(USERGROUP2, "select_tbl2")
         .addPermissionsToRole("select_tbl2", "server=server1->db=db2->table=tbl2->action=select")
         .write(db2PolicyFileHandle);
-    PolicyFiles.copyFilesToDir(dfsCluster.getFileSystem(), dfsBaseDir, db2PolicyFileHandle);
+    PolicyFiles.copyFilesToDir(fileSystem, dfs.getBaseDir(), db2PolicyFileHandle);
 
     // setup db objects needed by the test
     Connection connection = context.createConnection(ADMIN1, "hive");

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestServerConfiguration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestServerConfiguration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestServerConfiguration.java
index 7d1ce6f..a301aaa 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestServerConfiguration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestServerConfiguration.java
@@ -212,4 +212,55 @@ public class TestServerConfiguration extends AbstractTestWithHiveServer {
     }
 
   }
+
+  /**
+   * Test access to default DB with explicit privilege requirement
+   * Admin should be able to run use default with server level access
+   * User with db level access should be able to run use default
+   * User with table level access should be able to run use default
+   * User with no access to default db objects, should NOT be able run use default
+   * @throws Exception
+   */
+  @Test
+  public void testDefaultDbRestrictivePrivilege() throws Exception {
+    properties.put(HiveAuthzConf.AuthzConfVars.AUTHZ_RESTRICT_DEFAULT_DB.getVar(), "true");
+    context = createContext(properties);
+
+    policyFile
+        .addRolesToGroup(USERGROUP1, "all_default")
+        .addRolesToGroup(USERGROUP2, "select_default")
+        .addRolesToGroup(USERGROUP3, "all_db1")
+        .addPermissionsToRole("all_default", "server=server1->db=default")
+        .addPermissionsToRole("select_default", "server=server1->db=default->table=tab_2->action=select")
+        .addPermissionsToRole("all_db1", "server=server1->db=DB_1")
+        .setUserGroupMapping(StaticUserGroup.getStaticMapping())
+        .write(context.getPolicyFile());
+
+    Connection connection = context.createConnection(ADMIN1, "hive");
+    Statement statement = context.createStatement(connection);
+    statement.execute("use default");
+    context.close();
+
+    connection = context.createConnection(USER1_1, "hive");
+    statement = context.createStatement(connection);
+    statement.execute("use default");
+    context.close();
+
+    connection = context.createConnection(USER2_1, "hive");
+    statement = context.createStatement(connection);
+    statement.execute("use default");
+    context.close();
+
+    connection = context.createConnection(USER3_1, "hive");
+    statement = context.createStatement(connection);
+    try {
+      // user3 doesn't have any implicit permission for default
+      statement.execute("use default");
+      assertFalse("user3 shouldn't be able switch to default", true);
+    } catch (SQLException e) {
+      context.verifyAuthzException(e);
+    }
+    context.close();
+  }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUriPermissions.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUriPermissions.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUriPermissions.java
index 4dc9b88..ba651a9 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUriPermissions.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUriPermissions.java
@@ -28,7 +28,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-public class TestUriPermissions extends AbstractTestWithStaticLocalFS {
+public class TestUriPermissions extends AbstractTestWithStaticConfiguration {
   private Context context;
   private PolicyFile policyFile;
 
@@ -104,7 +104,7 @@ public class TestUriPermissions extends AbstractTestWithStaticLocalFS {
     String dbName = "db1";
     String tabName = "tab1";
     String newPartitionDir = "foo";
-    String tabDir = "file://" + hiveServer.getProperty(HiveServerFactory.WAREHOUSE_DIR) +
+    String tabDir = hiveServer.getProperty(HiveServerFactory.WAREHOUSE_DIR) +
       "/" + tabName + "/" + newPartitionDir;
     Connection userConn = null;
     Statement userStmt = null;

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUserManagement.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUserManagement.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUserManagement.java
index 102c6cf..93bfc2b 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUserManagement.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestUserManagement.java
@@ -33,7 +33,7 @@ import org.junit.Test;
 
 import com.google.common.io.Resources;
 
-public class TestUserManagement extends AbstractTestWithStaticLocalFS {
+public class TestUserManagement extends AbstractTestWithStaticConfiguration {
   private static final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat";
   private static final String dbName = "db1";
   private static final String tableName = "t1";

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/AbstractDFS.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/AbstractDFS.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/AbstractDFS.java
new file mode 100644
index 0000000..873c537
--- /dev/null
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/AbstractDFS.java
@@ -0,0 +1,66 @@
+/*
+ * 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.sentry.tests.e2e.hive.fs;
+
+import junit.framework.Assert;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+
+import java.io.IOException;
+
+public abstract class AbstractDFS implements DFS{
+  protected static FileSystem fileSystem;
+  protected static Path dfsBaseDir;
+
+  @Override
+  public FileSystem getFileSystem(){
+    return fileSystem;
+  }
+
+  @Override
+  public void tearDown() throws Exception {
+    cleanBaseDir();
+  }
+
+  @Override
+  public void createBaseDir() throws Exception {
+    Assert.assertTrue(dfsBaseDir.toString(), fileSystem.delete(dfsBaseDir, true));
+    Assert.assertTrue(dfsBaseDir.toString(), fileSystem.mkdirs(dfsBaseDir));
+  }
+
+  @Override
+  public Path assertCreateDir(String path) throws Exception{
+    return assertCreateDfsDir( new Path(dfsBaseDir + path));
+  }
+
+  @Override
+  public Path getBaseDir(){
+    return dfsBaseDir;
+  }
+
+  protected void cleanBaseDir() throws Exception {
+    Assert.assertTrue(dfsBaseDir.toString(), fileSystem.delete(dfsBaseDir, true));
+  }
+
+  protected Path assertCreateDfsDir(Path dir) throws IOException {
+    if(!fileSystem.isDirectory(dir)) {
+      Assert.assertTrue("Failed creating " + dir, fileSystem.mkdirs(dir));
+    }
+    return dir;
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/DFS.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/DFS.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/DFS.java
new file mode 100644
index 0000000..b9764bc
--- /dev/null
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/DFS.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sentry.tests.e2e.hive.fs;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+
+import java.io.IOException;
+
+public interface DFS {
+  public FileSystem getFileSystem();
+  public void tearDown() throws Exception;
+  public Path assertCreateDir(String dir) throws Exception;
+  public Path getBaseDir();
+  public void createBaseDir() throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/DFSFactory.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/DFSFactory.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/DFSFactory.java
new file mode 100644
index 0000000..cbfe3f4
--- /dev/null
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/DFSFactory.java
@@ -0,0 +1,45 @@
+/*
+ * 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.sentry.tests.e2e.hive.fs;
+
+import com.google.common.annotations.VisibleForTesting;
+
+import java.io.File;
+
+public class DFSFactory {
+  public static final String FS_TYPE = "sentry.e2etest.DFSType";
+
+  public static DFS create(String dfsType, File baseDir) throws Exception{
+    DFSType type;
+    if(dfsType!=null) {
+      type = DFSType.valueOf(dfsType.trim());
+    }else {
+      type = DFSType.MiniDFS;
+    }
+    switch (type) {
+      case MiniDFS:
+        return new MiniDFS(baseDir);
+      default:
+        throw new UnsupportedOperationException(type.name());
+    }
+  }
+
+  @VisibleForTesting
+  public static enum DFSType {
+    MiniDFS;
+  };
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/MiniDFS.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/MiniDFS.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/MiniDFS.java
new file mode 100644
index 0000000..dba2a54
--- /dev/null
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/MiniDFS.java
@@ -0,0 +1,54 @@
+/*
+ * 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.sentry.tests.e2e.hive.fs;
+
+import junit.framework.Assert;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+
+import java.io.File;
+import java.io.IOException;
+
+public class MiniDFS extends AbstractDFS {
+  private static MiniDFSCluster dfsCluster;
+
+  MiniDFS(File baseDir) throws Exception {
+    Configuration conf = new Configuration();
+    File dfsDir = assertCreateDir(new File(baseDir, "dfs"));
+    conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, dfsDir.getPath());
+    dfsCluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
+    fileSystem = dfsCluster.getFileSystem();
+    dfsBaseDir = assertCreateDfsDir(new Path(new Path(fileSystem.getUri()), "/base"));
+  }
+
+  @Override
+  public void tearDown() throws Exception {
+    if(dfsCluster != null) {
+      dfsCluster.shutdown();
+      dfsCluster = null;
+    }
+  }
+
+  //Utilities
+  private static File assertCreateDir(File dir) {
+    if(!dir.isDirectory()) {
+      Assert.assertTrue("Failed creating " + dir, dir.mkdirs());
+    }
+    return dir;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/5950ba8b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java
index 653d2ec..e452f71 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServerFactory.java
@@ -135,7 +135,7 @@ public class HiveServerFactory {
     Assert.assertNotNull(hadoopBinPath, "Hadoop Bin");
     File hadoopBin = new File(hadoopBinPath);
     if(!hadoopBin.isFile()) {
-      Assert.fail("Path to hadoop bin " + hadoopBin.getPath() + "is invalid. "
+      Assert.fail("Path to hadoop bin " + hadoopBin.getPath() + " is invalid. "
           + "Perhaps you missed the download-hadoop profile.");
     }
     /*


Mime
View raw message