Repository: sentry Updated Branches: refs/heads/sentry-ha-redesign c4d3b5eae -> 91168c623
SENTRY-1596: Hive tests failing for sentry-ha-redesign branch (Hao Hao, Reviewed by: Alexander Kolbasov) Change-Id: Id628aa8f8bba985e591a9375608cd4dbdb1ccf3d Project: http://git-wip-us.apache.org/repos/asf/sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/91168c62 Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/91168c62 Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/91168c62 Branch: refs/heads/sentry-ha-redesign Commit: 91168c6234f6aee63728202d6571d7d590d16e85 Parents: c4d3b5e Author: hahao <[email protected]> Authored: Fri Jan 20 14:27:54 2017 -0800 Committer: hahao <[email protected]> Committed: Fri Jan 20 14:27:54 2017 -0800 ---------------------------------------------------------------------- .../TestDbPrivilegeCleanupOnDrop.java | 36 +++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sentry/blob/91168c62/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 69fc8d2..5ded20c 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 @@ -76,8 +76,11 @@ public class TestDbPrivilegeCleanupOnDrop extends FileOutputStream to = new FileOutputStream(dataFile); Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to); to.close(); - while(!HMSFollower.isConnectedToHMS()) { - Thread.sleep(1000); + // Check the HMS connection only when notification log is enabled. + if (enableNotificationLog) { + while (!HMSFollower.isConnectedToHMS()) { + Thread.sleep(1000); + } } } @@ -99,12 +102,14 @@ public class TestDbPrivilegeCleanupOnDrop extends public void testDropObjects() throws Exception { Connection connection = context.createConnection(ADMIN1); Statement statement = context.createStatement(connection); + setupRoles(statement); // create required roles setupDbObjects(statement); // create test DBs and Tables - Thread.sleep(5000);//TODO: Workaround for SENTRY-1422 setupPrivileges(statement); // setup privileges for USER1 dropDbObjects(statement); // drop objects - Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + if (enableNotificationLog) { + Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + } verifyPrivilegesDropped(statement); // verify privileges are removed statement.close(); @@ -137,12 +142,13 @@ public class TestDbPrivilegeCleanupOnDrop extends Statement statement = context.createStatement(connection); setupRoles(statement); // create required roles setupDbObjects(statement); // create test DBs and Tables - Thread.sleep(5000);//TODO: Workaround for SENTRY-1422 setupPrivileges(statement); // setup privileges for USER1 dropDbObjects(statement); // drop DB and tables setupDbObjects(statement); // recreate same DBs and tables - Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + if (enableNotificationLog) { + Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + } verifyPrivilegesDropped(statement); // verify the stale privileges removed } @@ -159,9 +165,10 @@ public class TestDbPrivilegeCleanupOnDrop extends setupRoles(statement); // create required roles setupDbObjects(statement); // create test DBs and Tables - Thread.sleep(5000);//TODO: Workaround for SENTRY-1422 setupPrivileges(statement); // setup privileges for USER1 - Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + if (enableNotificationLog) { + Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + } // verify privileges on the created tables statement.execute("USE " + DB2); @@ -173,7 +180,9 @@ public class TestDbPrivilegeCleanupOnDrop extends renameTables(statement); // alter tables to rename // verify privileges removed for old tables - Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + if (enableNotificationLog) { + Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + } verifyTablePrivilegesDropped(statement); // verify privileges created for new tables @@ -205,7 +214,6 @@ public class TestDbPrivilegeCleanupOnDrop extends statement.execute("USE " + DB1); statement.execute("CREATE TABLE t1 (c1 string)"); - Thread.sleep(5000);//TODO: Workaround for SENTRY-1422 // Grant SELECT/INSERT/DROP/ALTER to TABLE t1 statement.execute("GRANT SELECT ON TABLE t1 TO ROLE user_role"); statement.execute("GRANT INSERT ON TABLE t1 TO ROLE user_role"); @@ -219,12 +227,16 @@ public class TestDbPrivilegeCleanupOnDrop extends statement = context.createStatement(connection); statement.execute("USE " + DB1); statement.execute("ALTER TABLE t1 RENAME TO t2"); - Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + if (enableNotificationLog) { + Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + } context.assertSentrySemanticException(statement, "drop table t1", semanticException); // After rename table t1 to t2, user_role should have permission to drop t2 statement.execute("drop table t2"); - Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + if (enableNotificationLog) { + Thread.sleep(WAIT_FOR_NOTIFICATION_PROCESSING); + } ResultSet resultSet = statement.executeQuery("SHOW GRANT ROLE user_role"); // user_role will revoke all privilege from table t2, only remain CREATE on db_1 assertRemainingRows(resultSet, 1);
