Repository: incubator-sentry Updated Branches: refs/heads/master c737e3803 -> 66e425f20
SENTRY-313: Fix some uri failing tests (Sravya Tirukkovalur via Prasad Mujumdar) Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/66e425f2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/66e425f2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/66e425f2 Branch: refs/heads/master Commit: 66e425f20606233fa6753887c4d06f57c16672eb Parents: c737e38 Author: Prasad Mujumdar <[email protected]> Authored: Tue Jun 24 23:41:28 2014 -0700 Committer: Prasad Mujumdar <[email protected]> Committed: Tue Jun 24 23:41:28 2014 -0700 ---------------------------------------------------------------------- .../sentry/tests/e2e/hive/StaticUserGroup.java | 6 ++++-- .../apache/sentry/tests/e2e/hive/TestOperations.java | 10 +++++----- .../sentry/tests/e2e/hive/TestUriPermissions.java | 15 ++++++++------- 3 files changed, 17 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/66e425f2/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/StaticUserGroup.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/StaticUserGroup.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/StaticUserGroup.java index d3d8585..66f088f 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/StaticUserGroup.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/StaticUserGroup.java @@ -20,9 +20,8 @@ import java.util.HashMap; import java.util.Map; public class StaticUserGroup { + public static String ADMIN1,ADMINGROUP; public static final String - ADMIN1 = "admin1", - ADMINGROUP = "admin", USER1_1 = "user1_1", USER1_2 = "user1_2", USER2_1 = "user2_1", @@ -35,6 +34,9 @@ public class StaticUserGroup { private static final Map<String, String> staticMapping; static { + + ADMIN1 = System.getProperty("sentry.e2etest.admin.user", "admin1"); + ADMINGROUP = System.getProperty("sentry.e2etest.admin.group", "admin"); staticMapping = new HashMap<String, String>(); staticMapping.put(ADMIN1, ADMINGROUP); staticMapping.put(USER1_1, USERGROUP1); http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/66e425f2/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java index 22f7dce..794ce82 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java @@ -36,10 +36,9 @@ public class TestOperations extends AbstractTestWithStaticConfiguration { private PolicyFile policyFile; final String dbName = "db1"; final String tableName = "tb1"; - static String warehouseDir = hiveServer.getProperty(HiveServerFactory.WAREHOUSE_DIR); final String semanticException = "SemanticException No valid privileges"; - static final Map<String, String> privileges = new HashMap<String, String>(); + static Map<String, String> privileges = new HashMap<String, String>(); static { privileges.put("all_server", "server=server1->action=all"); privileges.put("all_db1", "server=server1->db=db1->action=all"); @@ -58,6 +57,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration { policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP) .setUserGroupMapping(StaticUserGroup.getStaticMapping()); writePolicyFile(policyFile); + } private void adminCreate(String db, String table) throws Exception{ @@ -426,7 +426,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration { @Test public void testAlterAllOnTableAndURI() throws Exception { adminCreate(dbName, tableName, true); - String tabLocation = warehouseDir + "/blah"; + String tabLocation = dfs.getBaseDir() + "/" + Math.random(); policyFile .addPermissionsToRole("all_db1_tb1", privileges.get("all_db1_tb1")) .addPermissionsToRole("all_uri", "server=server1->uri=" + tabLocation) @@ -515,7 +515,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration { dropDb(ADMIN1, dbName); createDb(ADMIN1, dbName); createTable(ADMIN1, dbName, dataFile, tableName); - String location = warehouseDir + "/loc"; + String location = dfs.getBaseDir() + "/" + Math.random(); policyFile .addPermissionsToRole("all_db1", privileges.get("all_db1")) .addPermissionsToRole("all_uri", "server=server1->uri="+ location) @@ -630,7 +630,7 @@ public class TestOperations extends AbstractTestWithStaticConfiguration { createDb(ADMIN1, "db2"); createTable(ADMIN1, dbName, dataFile, tableName); createTable(ADMIN1, "db2", null, "tb2"); - String location = warehouseDir + "/loc"; + String location = dfs.getBaseDir() + "/" + Math.random(); policyFile .addPermissionsToRole("select_db1_tb1", privileges.get("select_db1_tb1")) http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/66e425f2/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 99f3a77..c633cc2 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 @@ -21,6 +21,7 @@ import java.io.FileOutputStream; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; +import java.util.Random; import com.google.common.io.Resources; import junit.framework.Assert; @@ -37,18 +38,19 @@ public class TestUriPermissions extends AbstractTestWithStaticConfiguration { @Before public void setup() throws Exception { - dataFile = new File(dataDir, SINGLE_TYPE_DATA_FILE_NAME); - FileOutputStream to = new FileOutputStream(dataFile); - Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to); - to.close(); policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP); - loadData = "server=server1->uri=file://" + dataFile.getPath(); } // test load data into table @Test public void testLoadPrivileges() throws Exception { + dataFile = new File(dataDir, SINGLE_TYPE_DATA_FILE_NAME); + FileOutputStream to = new FileOutputStream(dataFile); + Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to); + to.close(); + loadData = "server=server1->uri=file://" + dataFile.getPath(); + String dbName = "db1"; String tabName = "tab1"; Connection userConn = null; @@ -162,7 +164,6 @@ public class TestUriPermissions extends AbstractTestWithStaticConfiguration { " LOCATION '" + tabDir + "/foo'"); userStmt.execute( "ALTER TABLE " + tabName + " DROP PARTITION (dt = '21-Dec-2012')"); - userConn.close(); userStmt.close(); userConn.close(); @@ -218,7 +219,7 @@ public class TestUriPermissions extends AbstractTestWithStaticConfiguration { String dbName = "db1"; Connection userConn = null; Statement userStmt = null; - String tableDir = "file://" + context.getDataDir(); + String tableDir = "file://" + context.getDataDir() + "/" + Math.random(); policyFile .addRolesToGroup(USERGROUP1, "db1_all", "data_read")
