Repository: incubator-sentry Updated Branches: refs/heads/master cfaa570f0 -> 36db9ba13
SENTRY-1116: Fix PMD violation for Sentry tests after missing commits Change-Id: I8c303dca3e9358ae1cba07040a41867eefff67ed Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/36db9ba1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/36db9ba1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/36db9ba1 Branch: refs/heads/master Commit: 36db9ba134444dab2d9cb06588a00186484063c4 Parents: cfaa570 Author: hahao <hao....@cloudera.com> Authored: Mon Mar 7 13:45:03 2016 -0800 Committer: hahao <hao....@cloudera.com> Committed: Mon Mar 7 13:45:03 2016 -0800 ---------------------------------------------------------------------- .../e2e/dbprovider/TestColumnEndToEnd.java | 4 +-- .../e2e/dbprovider/TestConcurrentClients.java | 7 ++-- .../TestDbColumnLevelMetaDataOps.java | 5 +-- .../tests/e2e/dbprovider/TestDbComplexView.java | 18 +++++----- .../tests/e2e/dbprovider/TestDbConnections.java | 3 +- .../tests/e2e/dbprovider/TestDbEndToEnd.java | 4 +-- .../TestDbPrivilegeCleanupOnDrop.java | 5 --- .../tests/e2e/dbprovider/TestDbSandboxOps.java | 2 -- .../TestDbSentryOnFailureHookLoading.java | 7 ++-- .../TestPrivilegeWithGrantOption.java | 12 +++---- .../TestPrivilegeWithHAGrantOption.java | 7 ++-- .../sentry/tests/e2e/ha/TestHaEnd2End.java | 3 +- .../tests/e2e/hdfs/TestHDFSIntegration.java | 37 +++++++------------- .../e2e/hive/AbstractTestWithHiveServer.java | 2 +- .../AbstractTestWithStaticConfiguration.java | 13 ++++--- .../apache/sentry/tests/e2e/hive/Context.java | 7 ++-- .../e2e/hive/DummySentryOnFailureHook.java | 3 -- .../sentry/tests/e2e/hive/TestConfigTool.java | 1 - .../e2e/hive/TestCustomSerdePrivileges.java | 4 ++- .../e2e/hive/TestMetadataObjectRetrieval.java | 2 +- .../sentry/tests/e2e/hive/TestOperations.java | 8 +++-- .../e2e/hive/TestPrivilegesAtColumnScope.java | 26 +++++--------- .../e2e/hive/TestPrivilegesAtDatabaseScope.java | 5 --- .../e2e/hive/TestRuntimeMetadataRetrieval.java | 26 +++++++------- .../tests/e2e/hive/TestUriPermissions.java | 6 ---- .../tests/e2e/hive/TestViewPrivileges.java | 2 +- .../apache/sentry/tests/e2e/hive/fs/DFS.java | 12 +++---- .../sentry/tests/e2e/hive/fs/DFSFactory.java | 2 -- .../tests/e2e/hive/hiveserver/HiveServer.java | 10 +++--- .../e2e/hive/hiveserver/HiveServerFactory.java | 25 ++++++------- .../e2e/hive/hiveserver/InternalHiveServer.java | 2 -- .../hiveserver/InternalMetastoreServer.java | 1 - ...actMetastoreTestWithStaticConfiguration.java | 5 +-- .../metastore/SentryPolicyProviderForDb.java | 25 +++++++------ .../e2e/metastore/TestMetastoreEndToEnd.java | 4 +-- .../sentry/tests/e2e/minisentry/SentrySrv.java | 24 ++++++------- 36 files changed, 129 insertions(+), 200 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestColumnEndToEnd.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestColumnEndToEnd.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestColumnEndToEnd.java index 0fa21a2..32d0a61 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestColumnEndToEnd.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestColumnEndToEnd.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.List; import org.apache.sentry.provider.db.SentryAccessDeniedException; -import org.apache.sentry.provider.file.PolicyFile; import org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration; import org.junit.Before; import org.junit.BeforeClass; @@ -46,7 +45,6 @@ public class TestColumnEndToEnd extends AbstractTestWithStaticConfiguration { private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat"; private File dataFile; - private PolicyFile policyFile; @BeforeClass public static void setupTestStaticConfiguration() throws Exception{ @@ -60,7 +58,7 @@ public class TestColumnEndToEnd extends AbstractTestWithStaticConfiguration { public void setup() throws Exception { super.setupAdmin(); super.setup(); - policyFile = super.setupPolicy(); + super.setupPolicy(); dataFile = new File(dataDir, SINGLE_TYPE_DATA_FILE_NAME); FileOutputStream to = new FileOutputStream(dataFile); Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to); http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestConcurrentClients.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestConcurrentClients.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestConcurrentClients.java index d926797..bf871f0 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestConcurrentClients.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestConcurrentClients.java @@ -233,9 +233,6 @@ public class TestConcurrentClients extends AbstractTestWithStaticConfiguration { public synchronized Throwable getFirstException() { return firstException; } - public synchronized boolean isFailed() { - return failed; - } } /** @@ -253,7 +250,9 @@ public class TestConcurrentClients extends AbstractTestWithStaticConfiguration { @Override public void run() { LOGGER.info("Starting tests: create role, show role, create db and tbl, and create partitions"); - if (state.failed) return; + if (state.failed) { + return; + } try { Long startTime = System.currentTimeMillis(); Long elapsedTime = 0L; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbColumnLevelMetaDataOps.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbColumnLevelMetaDataOps.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbColumnLevelMetaDataOps.java index e639071..a454202 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbColumnLevelMetaDataOps.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbColumnLevelMetaDataOps.java @@ -20,14 +20,11 @@ package org.apache.sentry.tests.e2e.dbprovider; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; import org.apache.hive.service.cli.HiveSQLException; import org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration; import org.apache.sentry.tests.e2e.hive.PrivilegeResultSet; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -371,4 +368,4 @@ public class TestDbColumnLevelMetaDataOps extends AbstractTestWithStaticConfigur String query = "SHOW TABLE EXTENDED IN " + TEST_COL_METADATA_OPS_DB + " LIKE " + TEST_COL_METADATA_OPS_TB; validateSemanticException(query, USER1_1); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbComplexView.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbComplexView.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbComplexView.java index ef70050..35f41c6 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbComplexView.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbComplexView.java @@ -27,11 +27,9 @@ import java.util.List; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; -import static org.junit.Assume.assumeTrue; import org.apache.sentry.provider.file.PolicyFile; import org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration; -import org.apache.sentry.tests.e2e.hive.hiveserver.HiveServerFactory; import org.junit.Before; import org.junit.BeforeClass; @@ -51,7 +49,6 @@ public class TestDbComplexView extends AbstractTestWithStaticConfiguration { private static final String TEST_VIEW_TB2 = "test_complex_view_table_2"; private static final String TEST_VIEW = "test_complex_view"; private static final String TEST_VIEW_ROLE = "test_complex_view_role"; - private PolicyFile policyFile; /** * Run query and validate one column with given column name @@ -91,13 +88,17 @@ public class TestDbComplexView extends AbstractTestWithStaticConfiguration { LOGGER.error("Exception: ", ex); } finally { try { - if (stmt != null) stmt.close(); - if (conn != null) conn.close(); + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } } catch (Exception ex) { LOGGER.error("failed to close connection and statement: " + ex); } - return status; } + return status; } @BeforeClass @@ -111,7 +112,7 @@ public class TestDbComplexView extends AbstractTestWithStaticConfiguration { public void setup() throws Exception { super.setupAdmin(); super.setup(); - policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP); + PolicyFile.setAdminOnServer1(ADMINGROUP); // prepare test db and base table List<String> sqls = new ArrayList<String>(); @@ -222,7 +223,6 @@ public class TestDbComplexView extends AbstractTestWithStaticConfiguration { testView2, TEST_VIEW)); String testView3 = "view2_from_" + TEST_VIEW; - String testRole3 = testView3 + "_test_role"; sqls.add(String.format("CREATE VIEW %s(userid,link) AS SELECT userid,link from %s", testView3, TEST_VIEW)); @@ -311,4 +311,4 @@ public class TestDbComplexView extends AbstractTestWithStaticConfiguration { execBatch(ADMIN1, sqls); grantAndValidatePrivilege(TEST_VIEW, TEST_VIEW_ROLE, USERGROUP1, USER1_1); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbConnections.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbConnections.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbConnections.java index d89b50e..2af0536 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbConnections.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbConnections.java @@ -31,7 +31,6 @@ import org.junit.BeforeClass; import org.junit.Test; public class TestDbConnections extends AbstractTestWithStaticConfiguration { - private PolicyFile policyFile; @BeforeClass public static void setupTestStaticConfiguration() throws Exception { @@ -44,7 +43,7 @@ public class TestDbConnections extends AbstractTestWithStaticConfiguration { public void setup() throws Exception { super.setupAdmin(); super.setup(); - policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP); + PolicyFile.setAdminOnServer1(ADMINGROUP); } /** http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbEndToEnd.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbEndToEnd.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbEndToEnd.java index bb0ec7a..d9f30e0 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbEndToEnd.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbEndToEnd.java @@ -24,7 +24,6 @@ import java.io.File; import java.io.FileOutputStream; import java.sql.Connection; import java.sql.ResultSet; -import java.sql.SQLException; import java.sql.Statement; import org.apache.sentry.provider.db.SentryAccessDeniedException; @@ -39,7 +38,6 @@ import com.google.common.io.Resources; public class TestDbEndToEnd extends AbstractTestWithStaticConfiguration { private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat"; private File dataFile; - private PolicyFile policyFile; @BeforeClass public static void setupTestStaticConfiguration() throws Exception{ @@ -56,7 +54,7 @@ public class TestDbEndToEnd extends AbstractTestWithStaticConfiguration { FileOutputStream to = new FileOutputStream(dataFile); Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to); to.close(); - policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP); + PolicyFile.setAdminOnServer1(ADMINGROUP); } @Test http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java index 39b67f6..767bcbe 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbPrivilegeCleanupOnDrop.java @@ -33,20 +33,15 @@ import java.util.List; import org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration; import org.junit.After; -import org.junit.Assume; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.google.common.collect.Lists; import com.google.common.io.Resources; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class TestDbPrivilegeCleanupOnDrop extends AbstractTestWithStaticConfiguration { - private static final Logger LOGGER = LoggerFactory - .getLogger(TestDbPrivilegeCleanupOnDrop.class); private final static int SHOW_GRANT_TABLE_POSITION = 2; private final static int SHOW_GRANT_DB_POSITION = 1; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSandboxOps.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSandboxOps.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSandboxOps.java index e21dfe3..fa429e7 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSandboxOps.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSandboxOps.java @@ -16,8 +16,6 @@ */ package org.apache.sentry.tests.e2e.dbprovider; -import static org.junit.Assert.assertTrue; - import org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration; import org.apache.sentry.tests.e2e.hive.TestSandboxOps; import org.junit.Before; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java index f166a11..e50ff6f 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDbSentryOnFailureHookLoading.java @@ -17,9 +17,6 @@ package org.apache.sentry.tests.e2e.dbprovider; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -245,12 +242,12 @@ public class TestDbSentryOnFailureHookLoading extends AbstractTestWithDbProvider private void verifyFailureHook(Statement statement, String sqlStr, HiveOperation expectedOp, String dbName, String tableName, boolean checkSentryAccessDeniedException) throws Exception { // negative test case: non admin user can't create role - assertFalse(DummySentryOnFailureHook.invoked); + Assert.assertFalse(DummySentryOnFailureHook.invoked); try { statement.execute(sqlStr); Assert.fail("Expected SQL exception for " + sqlStr); } catch (SQLException e) { - assertTrue("FailureHook is not ran : " + e.getMessage(), DummySentryOnFailureHook.invoked); + Assert.assertTrue("FailureHook is not ran : " + e.getMessage(), DummySentryOnFailureHook.invoked); } finally { DummySentryOnFailureHook.invoked = false; } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithGrantOption.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithGrantOption.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithGrantOption.java index 5c49f98..90c69a3 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithGrantOption.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithGrantOption.java @@ -17,10 +17,6 @@ package org.apache.sentry.tests.e2e.dbprovider; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -221,7 +217,7 @@ public class TestPrivilegeWithGrantOption extends AbstractTestWithStaticConfigur HiveOperation expectedOp, String dbName, String tableName, boolean checkSentryAccessDeniedException) throws Exception { // negative test case: non admin user can't create role - assertFalse(DummySentryOnFailureHook.invoked); + Assert.assertFalse(DummySentryOnFailureHook.invoked); try { statement.execute(sqlStr); Assert.fail("Expected SQL exception for " + sqlStr); @@ -241,7 +237,7 @@ public class TestPrivilegeWithGrantOption extends AbstractTestWithStaticConfigur return; } - assertTrue(DummySentryOnFailureHook.invoked); + Assert.assertTrue(DummySentryOnFailureHook.invoked); if (expectedOp != null) { Assert.assertNotNull("Hive op is null for op: " + expectedOp, DummySentryOnFailureHook.hiveOp); Assert.assertTrue(expectedOp.equals(DummySentryOnFailureHook.hiveOp)); @@ -265,8 +261,8 @@ public class TestPrivilegeWithGrantOption extends AbstractTestWithStaticConfigur String statementSql, int dbObjectPosition, String dbObjectName) throws Exception { ResultSet res = statetment.executeQuery(statementSql); - assertTrue(res.next()); - assertEquals(dbObjectName, res.getString(dbObjectPosition)); + Assert.assertTrue(res.next()); + Assert.assertEquals(dbObjectName, res.getString(dbObjectPosition)); res.close(); } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithHAGrantOption.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithHAGrantOption.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithHAGrantOption.java index 9791790..2762ef7 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithHAGrantOption.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestPrivilegeWithHAGrantOption.java @@ -17,9 +17,6 @@ package org.apache.sentry.tests.e2e.dbprovider; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; @@ -135,12 +132,12 @@ public class TestPrivilegeWithHAGrantOption extends AbstractTestWithDbProvider { private void verifyFailureHook(Statement statement, String sqlStr, HiveOperation expectedOp, String dbName, String tableName, boolean checkSentryAccessDeniedException) throws Exception { // negative test case: non admin user can't create role - assertFalse(DummySentryOnFailureHook.invoked); + Assert.assertFalse(DummySentryOnFailureHook.invoked); try { statement.execute(sqlStr); Assert.fail("Expected SQL exception for " + sqlStr); } catch (SQLException e) { - assertTrue(DummySentryOnFailureHook.invoked); + Assert.assertTrue(DummySentryOnFailureHook.invoked); } finally { DummySentryOnFailureHook.invoked = false; } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/ha/TestHaEnd2End.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/ha/TestHaEnd2End.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/ha/TestHaEnd2End.java index 70828da..6ad70cf 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/ha/TestHaEnd2End.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/ha/TestHaEnd2End.java @@ -40,7 +40,6 @@ public class TestHaEnd2End extends AbstractTestWithStaticConfiguration { private final String SINGLE_TYPE_DATA_FILE_NAME = "kv1.dat"; private File dataFile; - private PolicyFile policyFile; @BeforeClass public static void setupTestStaticConfiguration() throws Exception { @@ -58,7 +57,7 @@ public class TestHaEnd2End extends AbstractTestWithStaticConfiguration { FileOutputStream to = new FileOutputStream(dataFile); Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to); to.close(); - policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP); + PolicyFile.setAdminOnServer1(ADMINGROUP); } /** http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java index 4d9e31c..adb2da5 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java @@ -59,19 +59,11 @@ import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; import org.apache.hadoop.hive.metastore.api.StorageDescriptor; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; -import org.apache.hadoop.mapred.FileInputFormat; -import org.apache.hadoop.mapred.FileOutputFormat; -import org.apache.hadoop.mapred.JobClient; -import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapred.MapReduceBase; import org.apache.hadoop.mapred.Mapper; -import org.apache.hadoop.mapred.MiniMRClientCluster; import org.apache.hadoop.mapred.OutputCollector; import org.apache.hadoop.mapred.Reducer; import org.apache.hadoop.mapred.Reporter; -import org.apache.hadoop.mapred.RunningJob; -import org.apache.hadoop.mapred.TextInputFormat; -import org.apache.hadoop.mapred.TextOutputFormat; import org.apache.hadoop.security.UserGroupInformation; import org.apache.sentry.binding.hive.SentryHiveAuthorizationTaskFactoryImpl; import org.apache.sentry.binding.hive.conf.HiveAuthzConf; @@ -146,7 +138,6 @@ public class TestHDFSIntegration { "dfs.namenode.authorization.provider.class"; private static MiniDFSCluster miniDFS; - private MiniMRClientCluster miniMR; private static InternalHiveServer hiveServer2; private static InternalMetastoreServer metastore; private static HiveMetaStoreClient hmsClient; @@ -300,6 +291,7 @@ public class TestHDFSIntegration { try { metastore.start(); while (true) { + Thread.sleep(1000L); } } catch (Exception e) { LOGGER.info("Could not start Hive Server"); @@ -326,7 +318,9 @@ public class TestHDFSIntegration { public void run() { try { hiveServer2.start(); - while(keepRunning.get()){} + while (keepRunning.get()) { + Thread.sleep(1000L); + } } catch (Exception e) { LOGGER.info("Could not start Hive Server"); } @@ -352,13 +346,6 @@ public class TestHDFSIntegration { } } - private static String getSentryPort() throws Exception{ - if(sentryServer!=null) { - return String.valueOf(sentryServer.get(0).getAddress().getPort()); - } else { - throw new Exception("Sentry server not initialized"); - } - } private static void startDFSandYARN() throws IOException, InterruptedException { adminUgi.doAs(new PrivilegedExceptionAction<Void>() { @@ -1747,7 +1734,9 @@ public class TestHDFSIntegration { List<String> lines = new ArrayList<String>(); do { line = in.readLine(); - if (line != null) lines.add(line); + if (line != null) { + lines.add(line); + } } while (line != null); Assert.assertEquals(3, lines.size()); in.close(); @@ -1787,12 +1776,10 @@ public class TestHDFSIntegration { throw th; } } - if (recurse) { - if (fStatus.isDirectory()) { - FileStatus[] children = miniDFS.getFileSystem().listStatus(p); - for (FileStatus fs : children) { - verifyOnAllSubDirs(fs.getPath(), fsAction, group, groupShouldExist, recurse, NUM_RETRIES); - } + if (recurse && fStatus.isDirectory()) { + FileStatus[] children = miniDFS.getFileSystem().listStatus(p); + for (FileStatus fs : children) { + verifyOnAllSubDirs(fs.getPath(), fsAction, group, groupShouldExist, recurse, NUM_RETRIES); } } } @@ -1814,6 +1801,7 @@ public class TestHDFSIntegration { return acls; } +/* private void runWordCount(JobConf job, String inPath, String outPath) throws Exception { Path in = new Path(inPath); Path out = new Path(outPath); @@ -1842,5 +1830,6 @@ public class TestHDFSIntegration { } } +*/ } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 56ed955..1acde0e 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 @@ -64,7 +64,7 @@ public abstract class AbstractTestWithHiveServer { hiveServer = HiveServerFactory.create(properties, baseDir, confDir, logDir, policyFile.getPath(), fileSystem); hiveServer.start(); return new Context(hiveServer, fileSystem, - baseDir, confDir, dataDir, policyFile); + baseDir, dataDir, policyFile); } protected static File assertCreateDir(File dir) { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 79f74af..704bbee 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 @@ -19,7 +19,6 @@ package org.apache.sentry.tests.e2e.hive; import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_PREFIX; import static org.apache.sentry.policy.common.PolicyConstants.ROLE_SPLITTER; -import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; @@ -179,7 +178,7 @@ public abstract class AbstractTestWithStaticConfiguration { public static void createContext() throws Exception { context = new Context(hiveServer, fileSystem, - baseDir, confDir, dataDir, policyFileLocation); + baseDir, dataDir, policyFileLocation); } protected void dropDb(String user, String...dbs) throws Exception { Connection connection = context.createConnection(user); @@ -195,7 +194,7 @@ public abstract class AbstractTestWithStaticConfiguration { Statement statement = connection.createStatement(); ArrayList<String> allowedDBs = new ArrayList<String>(Arrays.asList(DB1, DB2, DB3)); for(String db : dbs) { - assertTrue(db + " is not part of known test dbs which will be cleaned up after the test", allowedDBs.contains(db)); + Assert.assertTrue(db + " is not part of known test dbs which will be cleaned up after the test", allowedDBs.contains(db)); statement.execute("CREATE DATABASE " + db); } statement.close(); @@ -235,7 +234,7 @@ public abstract class AbstractTestWithStaticConfiguration { LOGGER.info("AbstractTestWithStaticConfiguration setupTestStaticConfiguration"); properties = Maps.newHashMap(); if(!policyOnHdfs) { - policyOnHdfs = new Boolean(System.getProperty("sentry.e2etest.policyonhdfs", "false")); + policyOnHdfs = Boolean.valueOf(System.getProperty("sentry.e2etest.policyonhdfs", "false")); } if (testServerType != null) { properties.put("sentry.e2etest.hiveServer2Type", testServerType); @@ -266,7 +265,7 @@ public abstract class AbstractTestWithStaticConfiguration { policyURI = policyFileLocation.getPath(); } - boolean startSentry = new Boolean(System.getProperty(EXTERNAL_SENTRY_SERVICE, "false")); + boolean startSentry = Boolean.valueOf(System.getProperty(EXTERNAL_SENTRY_SERVICE, "false")); if ("true".equalsIgnoreCase(System.getProperty(ENABLE_SENTRY_HA, "false"))) { enableSentryHA = true; } @@ -671,11 +670,11 @@ public abstract class AbstractTestWithStaticConfiguration { */ protected void validateReturnedResult(List<String> expected, List<String> returned) { for (String obj : expected) { - assertTrue("expected " + obj + " not found in the returned list: " + returned.toString(), + Assert.assertTrue("expected " + obj + " not found in the returned list: " + returned.toString(), returned.contains(obj)); } for (String obj : returned) { - assertTrue("returned " + obj + " not found in the expected list: " + expected.toString(), + Assert.assertTrue("returned " + obj + " not found in the expected list: " + expected.toString(), expected.contains(obj)); } } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java index f600fdf..0dd563a 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java @@ -42,7 +42,6 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; import org.apache.hadoop.hive.metastore.api.MetaException; -import org.apache.hadoop.hive.shims.ShimLoader; import org.apache.hadoop.security.UserGroupInformation; import org.apache.pig.ExecType; import org.apache.pig.PigServer; @@ -76,7 +75,7 @@ public class Context { private final Set<Statement> statements; public Context(HiveServer hiveServer, FileSystem fileSystem, - File baseDir, File confDir, File dataDir, File policyFile) throws Exception { + File baseDir, File dataDir, File policyFile) throws Exception { this.hiveServer = hiveServer; this.fileSystem = fileSystem; this.baseDir = baseDir; @@ -192,7 +191,7 @@ public class Context { Assert.fail("Expected SQLException for '" + query + "'"); } catch (SQLException e) { verifyAuthzExceptionForState(e, AUTHZ_LINK_FAILURE_SQL_STATE); - Assert.assertTrue("Expected " + exceptionType + " : " + e.getMessage(), + assertTrue("Expected " + exceptionType + " : " + e.getMessage(), Strings.nullToEmpty(e.getMessage()).contains(exceptionType)); } } @@ -204,7 +203,7 @@ public class Context { Assert.fail("Expected SQLException for '" + query + "'"); } catch (SQLException e) { verifyAuthzExceptionForState(e, AUTHZ_EXCEPTION_SQL_STATE); - Assert.assertTrue("Expected " + exceptionType + " : " + e.getMessage(), + assertTrue("Expected " + exceptionType + " : " + e.getMessage(), Strings.nullToEmpty(e.getMessage()).contains(exceptionType)); } } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/DummySentryOnFailureHook.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/DummySentryOnFailureHook.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/DummySentryOnFailureHook.java index 4838f76..99614e0 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/DummySentryOnFailureHook.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/DummySentryOnFailureHook.java @@ -17,15 +17,12 @@ package org.apache.sentry.tests.e2e.hive; -import junit.framework.Assert; - import org.apache.hadoop.hive.ql.metadata.AuthorizationException; import org.apache.hadoop.hive.ql.plan.HiveOperation; import org.apache.sentry.binding.hive.SentryOnFailureHook; import org.apache.sentry.binding.hive.SentryOnFailureHookContext; import org.apache.sentry.core.model.db.Database; import org.apache.sentry.core.model.db.Table; -import org.apache.sentry.provider.db.SentryAccessDeniedException; public class DummySentryOnFailureHook implements SentryOnFailureHook { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestConfigTool.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestConfigTool.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestConfigTool.java index cd5a75f..ac0a9cd 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestConfigTool.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestConfigTool.java @@ -33,7 +33,6 @@ import org.apache.sentry.binding.hive.conf.HiveAuthzConf; import org.apache.sentry.core.common.SentryConfigurationException; import org.apache.sentry.core.common.Subject; import org.apache.sentry.provider.file.PolicyFile; -import org.junit.After; import org.junit.Before; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCustomSerdePrivileges.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCustomSerdePrivileges.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCustomSerdePrivileges.java index 6dfdb3c..2723815 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCustomSerdePrivileges.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCustomSerdePrivileges.java @@ -20,8 +20,10 @@ package org.apache.sentry.tests.e2e.hive; import com.google.common.collect.Maps; import org.apache.sentry.binding.hive.conf.HiveAuthzConf; import org.apache.sentry.provider.file.PolicyFile; -import org.junit.*; +import org.junit.AfterClass; import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import java.security.CodeSource; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 1415647..fb0ef19 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 @@ -494,7 +494,7 @@ public class TestMetadataObjectRetrieval extends AbstractTestWithStaticConfigura } private void verifyParition(Statement statement, String table) throws Exception { - ResultSet rs = statement.executeQuery("SHOW PARTITIONS " + TBL1); + ResultSet rs = statement.executeQuery("SHOW PARTITIONS " + table); assertTrue(rs.next()); assertEquals("dt=3", rs.getString(1).trim()); } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 7b44e0a..7d3db2b 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 @@ -1100,8 +1100,12 @@ public class TestOperations extends AbstractTestWithStaticConfiguration { assertSemanticException(statement, "create external table " + DB1 + ".tb1(a int) location '" + extTableDir + "'"); } finally { - if (statement != null) statement.close(); - if (connection != null) connection.close(); + if (statement != null) { + statement.close(); + } + if (connection != null) { + connection.close(); + } } } } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtColumnScope.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtColumnScope.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtColumnScope.java index ecf1117..6c27cf6 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtColumnScope.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestPrivilegesAtColumnScope.java @@ -20,16 +20,11 @@ package org.apache.sentry.tests.e2e.hive; import java.io.File; import java.io.FileOutputStream; import java.sql.Connection; -import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; import junit.framework.Assert; -import org.apache.hadoop.fs.FSDataOutputStream; -import org.apache.hadoop.fs.Path; import org.apache.sentry.provider.file.PolicyFile; import org.junit.Before; import org.junit.BeforeClass; @@ -486,18 +481,15 @@ public class TestPrivilegesAtColumnScope extends AbstractTestWithStaticConfigura } // Users with out privileges on partition column can not access it - String [] negativeUsers = {USER2_1}; - for(String user:negativeUsers) { - Connection connection = context.createConnection(USER1_1); - Statement statement = context.createStatement(connection); - statement.execute("USE DB_1"); - try { - statement.execute("SELECT C FROM TAB_3"); - } catch (SQLException e) { - context.verifyAuthzException(e); - } - statement.close(); - connection.close(); + Connection connection = context.createConnection(USER2_1); + Statement statement = context.createStatement(connection); + statement.execute("USE DB_1"); + try { + statement.execute("SELECT C FROM TAB_3"); + } catch (SQLException e) { + context.verifyAuthzException(e); } + statement.close(); + connection.close(); } } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 9437fca..e9863e5 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 @@ -37,16 +37,11 @@ import org.junit.BeforeClass; import org.junit.Test; import com.google.common.io.Resources; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /* Tests privileges at table scope within a single database. */ public class TestPrivilegesAtDatabaseScope extends AbstractTestWithStaticConfiguration { - private static final Logger LOGGER = LoggerFactory. - getLogger(TestPrivilegesAtDatabaseScope.class); - private PolicyFile policyFile; Map <String, String >testProperties; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 4925f2e..efb588e 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 @@ -83,7 +83,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur ResultSet rs = statement.executeQuery("SHOW TABLES"); tableNamesValidation.addAll(Arrays.asList(tableNames)); - validateTables(rs, DB1, tableNamesValidation); + validateTables(rs, tableNamesValidation); statement.close(); policyFile @@ -103,7 +103,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // User1 should see tables with any level of access rs = statement.executeQuery("SHOW TABLES"); tableNamesValidation.addAll(Arrays.asList(user1TableNames)); - validateTables(rs, DB1, tableNamesValidation); + validateTables(rs, tableNamesValidation); statement.close(); } @@ -128,7 +128,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // Admin should see all tables ResultSet rs = statement.executeQuery("SHOW TABLES"); tableNamesValidation.addAll(Arrays.asList(tableNames)); - validateTables(rs, DB1, tableNamesValidation); + validateTables(rs, tableNamesValidation); statement.close(); policyFile @@ -143,7 +143,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // User1 should see tables with any level of access rs = statement.executeQuery("SHOW TABLES"); tableNamesValidation.addAll(Arrays.asList(user1TableNames)); - validateTables(rs, DB1, tableNamesValidation); + validateTables(rs, tableNamesValidation); statement.close(); } @@ -169,7 +169,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // Admin should see all tables ResultSet rs = statement.executeQuery("SHOW TABLES"); tableNamesValidation.addAll(Arrays.asList(adminTableNames)); - validateTables(rs, DB1, tableNamesValidation); + validateTables(rs, tableNamesValidation); statement.close(); policyFile @@ -185,7 +185,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // User1 should see tables with any level of access rs = statement.executeQuery("SHOW TABLES"); tableNamesValidation.addAll(Arrays.asList(user1TableNames)); - validateTables(rs, DB1, tableNamesValidation); + validateTables(rs, tableNamesValidation); statement.close(); } @@ -210,7 +210,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // Admin should be able to see all tables ResultSet rs = statement.executeQuery("SHOW TABLES"); tableNamesValidation.addAll(Arrays.asList(adminTableNames)); - validateTables(rs, DB1, tableNamesValidation); + validateTables(rs, tableNamesValidation); statement.close(); policyFile @@ -225,7 +225,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // User1 should see tables with any level of access rs = statement.executeQuery("SHOW TABLES"); tableNamesValidation.addAll(Arrays.asList(user1TableNames)); - validateTables(rs, DB1, tableNamesValidation); + validateTables(rs, tableNamesValidation); statement.close(); } @@ -287,7 +287,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // Admin should see all tables except table_5, the one does not match the pattern ResultSet rs = statement.executeQuery("SHOW TABLE EXTENDED IN " + DB1 + " LIKE 'tb*'"); tableNamesValidation.addAll(Arrays.asList(tableNames).subList(0, 4)); - validateTablesInRs(rs, DB1, tableNamesValidation); + validateTablesInRs(rs, tableNamesValidation); statement.close(); connection = context.createConnection(USER1_1); @@ -296,7 +296,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // User1 should see tables with any level of access rs = statement.executeQuery("SHOW TABLE EXTENDED IN " + DB1 + " LIKE 'tb*'"); tableNamesValidation.addAll(Arrays.asList(user1TableNames)); - validateTablesInRs(rs, DB1, tableNamesValidation); + validateTablesInRs(rs, tableNamesValidation); statement.close(); } @@ -403,8 +403,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur } // compare the table resultset with given array of table names - private void validateTables(ResultSet rs, String dbName, - List<String> tableNames) throws SQLException { + private void validateTables(ResultSet rs, List<String> tableNames) throws SQLException { while (rs.next()) { String tableName = rs.getString(1); Assert.assertTrue(tableName, tableNames.remove(tableName.toLowerCase())); @@ -416,8 +415,7 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur // compare the tables in resultset with given array of table names // for some hive query like 'show table extended ...', the resultset does // not only contains tableName (See HIVE-8109) - private void validateTablesInRs(ResultSet rs, String dbName, - List<String> tableNames) throws SQLException { + private void validateTablesInRs(ResultSet rs, List<String> tableNames) throws SQLException { while (rs.next()) { String tableName = rs.getString(1); if (tableName.startsWith("tableName:")) { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 911608a..70c932c 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,7 +21,6 @@ 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; @@ -31,13 +30,8 @@ import org.apache.sentry.tests.e2e.hive.hiveserver.HiveServerFactory; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class TestUriPermissions extends AbstractTestWithStaticConfiguration { - private static final Logger LOGGER = LoggerFactory. - getLogger(TestUriPermissions.class); - private PolicyFile policyFile; private File dataFile; private String loadData; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestViewPrivileges.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestViewPrivileges.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestViewPrivileges.java index 8e3d4c9..de05b8c 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestViewPrivileges.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestViewPrivileges.java @@ -98,7 +98,7 @@ public class TestViewPrivileges extends AbstractTestWithHiveServer { ResultSet res = stmt.executeQuery("select count(*) from " + tabName); org.junit.Assert.assertThat(res, notNullValue()); while(res.next()) { - Assume.assumeTrue(res.getInt(1) == new Integer(1000)); + Assume.assumeTrue(res.getInt(1) == Integer.valueOf(1000)); } stmt.execute("create view " + viewName + " as select * from " + tabName + " where id<100"); res = stmt.executeQuery("select count(*) from " + viewName); http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 index 872a084..67ba338 100644 --- 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 @@ -23,10 +23,10 @@ import java.io.File; 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; - public void writePolicyFile(File srcFile) throws IOException; + FileSystem getFileSystem(); + void tearDown() throws Exception; + Path assertCreateDir(String dir) throws Exception; + Path getBaseDir(); + void createBaseDir() throws Exception; + void writePolicyFile(File srcFile) throws IOException; } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 index 3f03ef0..e1881b4 100644 --- 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 @@ -18,8 +18,6 @@ package org.apache.sentry.tests.e2e.hive.fs; import java.io.File; -import org.apache.sentry.tests.e2e.hive.hiveserver.HiveServerFactory.HiveServer2Type; - import com.google.common.annotations.VisibleForTesting; public class DFSFactory { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServer.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServer.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServer.java index ee6155b..175e84c 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServer.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/HiveServer.java @@ -21,14 +21,14 @@ import java.sql.Connection; public interface HiveServer { - public void start() throws Exception; + void start() throws Exception; - public void shutdown() throws Exception; + void shutdown() throws Exception; - public String getURL(); + String getURL(); - public String getProperty(String key); + String getProperty(String key); - public Connection createConnection(String user, String password) throws Exception; + Connection createConnection(String user, String password) throws Exception; } http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/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 e7e497d..847da45 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 @@ -40,7 +40,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.annotations.VisibleForTesting; -import com.google.common.io.Files; import com.google.common.io.Resources; public class HiveServerFactory { @@ -113,7 +112,7 @@ public class HiveServerFactory { fileSystem.mkdirs(new Path("/", "warehouse"), new FsPermission((short) 0777)); } } - Boolean policyOnHDFS = new Boolean(System.getProperty("sentry.e2etest.policyonhdfs", "false")); + Boolean policyOnHDFS = Boolean.valueOf(System.getProperty("sentry.e2etest.policyonhdfs", "false")); if (policyOnHDFS) { // Initialize "hive.exec.scratchdir", according the description of // "hive.exec.scratchdir", the permission should be (733). @@ -163,19 +162,17 @@ public class HiveServerFactory { properties.put(METASTORE_RAW_STORE_IMPL, "org.apache.sentry.binding.metastore.AuthorizingObjectStore"); - if (!properties.containsKey(METASTORE_URI)) { - if (HiveServer2Type.InternalMetastore.equals(type)) { - // The configuration sentry.metastore.service.users is for the user who - // has all access to get the metadata. - properties.put(METASTORE_BYPASS, "accessAllMetaUser"); - properties.put(METASTORE_URI, - "thrift://localhost:" + String.valueOf(findPort())); - if (!properties.containsKey(METASTORE_HOOK)) { - properties.put(METASTORE_HOOK, - "org.apache.sentry.binding.metastore.MetastoreAuthzBinding"); - } - properties.put(ConfVars.METASTORESERVERMINTHREADS.varname, "5"); + if (!properties.containsKey(METASTORE_URI) && HiveServer2Type.InternalMetastore.equals(type)) { + // The configuration sentry.metastore.service.users is for the user who + // has all access to get the metadata. + properties.put(METASTORE_BYPASS, "accessAllMetaUser"); + properties.put(METASTORE_URI, + "thrift://localhost:" + String.valueOf(findPort())); + if (!properties.containsKey(METASTORE_HOOK)) { + properties.put(METASTORE_HOOK, + "org.apache.sentry.binding.metastore.MetastoreAuthzBinding"); } + properties.put(ConfVars.METASTORESERVERMINTHREADS.varname, "5"); } // set the SentryMetaStoreFilterHook for HiveServer2 only, not for metastore http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalHiveServer.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalHiveServer.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalHiveServer.java index 0e53d3d..45f0ef2 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalHiveServer.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalHiveServer.java @@ -18,9 +18,7 @@ package org.apache.sentry.tests.e2e.hive.hiveserver; import org.apache.hadoop.hive.conf.HiveConf; -import org.apache.hadoop.hive.metastore.HiveMetaStore; import org.apache.hive.service.server.HiveServer2; -import org.fest.reflect.core.Reflection; public class InternalHiveServer extends AbstractHiveServer { http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java index 4f73954..bf43798 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java @@ -26,7 +26,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.HiveMetaStore; import org.apache.hadoop.hive.shims.ShimLoader; -import org.fest.reflect.core.Reflection; public class InternalMetastoreServer extends AbstractHiveServer { private final HiveConf conf; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/AbstractMetastoreTestWithStaticConfiguration.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/AbstractMetastoreTestWithStaticConfiguration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/AbstractMetastoreTestWithStaticConfiguration.java index 2c16cd6..f1e6d75 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/AbstractMetastoreTestWithStaticConfiguration.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/AbstractMetastoreTestWithStaticConfiguration.java @@ -43,11 +43,8 @@ import org.apache.pig.PigServer; import org.apache.sentry.provider.file.PolicyFile; import org.apache.sentry.tests.e2e.hive.AbstractTestWithStaticConfiguration; import org.apache.sentry.tests.e2e.hive.hiveserver.HiveServerFactory.HiveServer2Type; -import org.junit.After; import org.junit.BeforeClass; -import com.google.common.collect.Maps; - public abstract class AbstractMetastoreTestWithStaticConfiguration extends AbstractTestWithStaticConfiguration { @@ -107,7 +104,7 @@ public abstract class AbstractMetastoreTestWithStaticConfiguration extends public void addPartition(HiveMetaStoreClient client, String dbName, String tblName, List<String> ptnVals, Table tbl) throws Exception { Partition part = makeMetastorePartitionObject(dbName, tblName, ptnVals, tbl); - Partition retp = client.add_partition(part); + client.add_partition(part); } public void addPartitionWithLocation(HiveMetaStoreClient client, http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java index 4e1e750..2507f83 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/SentryPolicyProviderForDb.java @@ -19,8 +19,6 @@ package org.apache.sentry.tests.e2e.metastore; import static org.apache.sentry.policy.common.PolicyConstants.AUTHORIZABLE_SPLITTER; import static org.apache.sentry.policy.common.PolicyConstants.PRIVILEGE_PREFIX; import static org.apache.sentry.policy.common.PolicyConstants.ROLE_SPLITTER; -import static org.apache.sentry.tests.e2e.hive.StaticUserGroup.ADMIN1; -import static org.apache.sentry.tests.e2e.hive.StaticUserGroup.ADMINGROUP; import java.io.File; import java.io.IOException; @@ -37,6 +35,7 @@ import org.apache.sentry.policy.db.DBModelAuthorizables; import org.apache.sentry.provider.db.service.thrift.SentryPolicyServiceClient; import org.apache.sentry.provider.db.service.thrift.TSentryRole; import org.apache.sentry.provider.file.PolicyFile; +import org.apache.sentry.tests.e2e.hive.StaticUserGroup; import org.apache.tools.ant.util.StringUtils; import org.mortbay.log.Log; @@ -44,7 +43,7 @@ import com.google.common.collect.Sets; public class SentryPolicyProviderForDb extends PolicyFile { protected static final Set<String> ADMIN_GROUP_SET = Sets - .newHashSet(ADMINGROUP); + .newHashSet(StaticUserGroup.ADMINGROUP); private SentryPolicyServiceClient sentryClient; protected SentryPolicyServiceClient getSentryClient() { @@ -72,14 +71,14 @@ public class SentryPolicyProviderForDb extends PolicyFile { } // remove existing metadata - for (TSentryRole tRole : sentryClient.listRoles(ADMIN1)) { - sentryClient.dropRole(ADMIN1, tRole.getRoleName()); + for (TSentryRole tRole : sentryClient.listRoles(StaticUserGroup.ADMIN1)) { + sentryClient.dropRole(StaticUserGroup.ADMIN1, tRole.getRoleName()); } // create roles and add privileges for (Entry<String, Collection<String>> roleEntry : rolesToPermissions .asMap().entrySet()) { - sentryClient.createRole(ADMIN1, roleEntry.getKey()); + sentryClient.createRole(StaticUserGroup.ADMIN1, roleEntry.getKey()); for (String privilege : roleEntry.getValue()) { addPrivilege(roleEntry.getKey(), privilege); } @@ -92,7 +91,7 @@ public class SentryPolicyProviderForDb extends PolicyFile { for (String roleName : roleNames.split(",")) { try { sentryClient - .grantRoleToGroup(ADMIN1, groupEntry.getKey(), roleName); + .grantRoleToGroup(StaticUserGroup.ADMIN1, groupEntry.getKey(), roleName); } catch (SentryUserException e) { Log.warn("Error granting role " + roleName + " to group " + groupEntry.getKey()); @@ -141,18 +140,18 @@ public class SentryPolicyProviderForDb extends PolicyFile { } if (columnName != null) { - sentryClient.grantColumnPrivilege(ADMIN1, roleName, serverName, dbName, + sentryClient.grantColumnPrivilege(StaticUserGroup.ADMIN1, roleName, serverName, dbName, tableName, columnName, action); } else if (tableName != null) { - sentryClient.grantTablePrivilege(ADMIN1, roleName, serverName, dbName, + sentryClient.grantTablePrivilege(StaticUserGroup.ADMIN1, roleName, serverName, dbName, tableName, action); } else if (dbName != null) { - sentryClient.grantDatabasePrivilege(ADMIN1, roleName, serverName, + sentryClient.grantDatabasePrivilege(StaticUserGroup.ADMIN1, roleName, serverName, dbName, action); } else if (uriPath != null) { - sentryClient.grantURIPrivilege(ADMIN1, roleName, serverName, uriPath); + sentryClient.grantURIPrivilege(StaticUserGroup.ADMIN1, roleName, serverName, uriPath); } else if (serverName != null) { - sentryClient.grantServerPrivilege(ADMIN1, roleName, serverName, action); + sentryClient.grantServerPrivilege(StaticUserGroup.ADMIN1, roleName, serverName, action); } } @@ -161,4 +160,4 @@ public class SentryPolicyProviderForDb extends PolicyFile { private boolean usingSentryService() { return sentryClient != null; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java index 1b3240f..b8866c7 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/metastore/TestMetastoreEndToEnd.java @@ -516,7 +516,7 @@ public class TestMetastoreEndToEnd extends */ @Test public void testPartionInsert() throws Exception { - String partVal1 = "part1", partVal2 = "part2", partVal3 = "part5"; + String partVal1 = "part1", partVal2 = "part2"; policyFile.addRolesToGroup(USERGROUP1, uri_role).addPermissionsToRole( uri_role, "server=server1->uri=file://" + dataFile.getPath()); @@ -556,7 +556,7 @@ public class TestMetastoreEndToEnd extends @Test public void testAddPartion() throws Exception { - String partVal1 = "part1", partVal2 = "part2", partVal3 = "part5"; + String partVal1 = "part1", partVal2 = "part2"; String newPath1 = "fooTab1"; String tabDir1 = hiveServer.getProperty(HiveServerFactory.WAREHOUSE_DIR) + File.separator + newPath1; http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/36db9ba1/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/minisentry/SentrySrv.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/minisentry/SentrySrv.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/minisentry/SentrySrv.java index b8cf894..dac1151 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/minisentry/SentrySrv.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/minisentry/SentrySrv.java @@ -25,7 +25,7 @@ public interface SentrySrv { * Start all the sentry services * @throws Exception */ - public void startAll() throws Exception; + void startAll() throws Exception; /** * Start the given server @@ -33,13 +33,13 @@ public interface SentrySrv { * - Server number (0 to N-1) * @throws Exception */ - public void start(int serverNum) throws Exception ; + void start(int serverNum) throws Exception ; /** * Stop all the Sentry servers * @throws Exception */ - public void stopAll() throws Exception; + void stopAll() throws Exception; /** * Stop the specified Sentry server @@ -47,7 +47,7 @@ public interface SentrySrv { * - Server number (0 to N-1) * @throws Exception */ - public void stop(int serverNum) throws Exception ; + void stop(int serverNum) throws Exception ; /** * Get the underlying Sentry service object @@ -55,7 +55,7 @@ public interface SentrySrv { * - Server number (0 to N-1) * @return */ - public SentryService get(int serverNum); + SentryService get(int serverNum); /** * Get the ZK connection string @@ -63,38 +63,38 @@ public interface SentrySrv { * @throws Exception * - If HA is not enabled */ - public String getZKQuorum() throws Exception; + String getZKQuorum() throws Exception; /** * Stop all the nodes and ZK if started. The SentrySrv can't be reused once * closed. */ - public void close(); + void close(); /** * Check if the sentry server is created with HA enabled. * @return True - HA is enabled False - HA is not enabled */ - public boolean isHaEnabled(); + boolean isHaEnabled(); /** * Get the number of active clients connections across servers */ - public long getNumActiveClients(); + long getNumActiveClients(); /** * Get the number of active clients connections for the given server */ - public long getNumActiveClients(int serverNum); + long getNumActiveClients(int serverNum); /** * Get the total number of clients connected so far */ - public long getTotalClients(); + long getTotalClients(); /** * Get the total number of clients connected so far */ - public long getTotalClients(int serverNum); + long getTotalClients(int serverNum); }