SENTRY-931: Improve TestDatabaseProvider for keep consistent with Hive metadata.(Dapeng Sun, reviewed by Colin Ma)
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/4a4bfecf Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/4a4bfecf Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/4a4bfecf Branch: refs/heads/master Commit: 4a4bfecfe77aca0c8152ad3357d92d19812fae0c Parents: 695d60d Author: Sun Dapeng <[email protected]> Authored: Tue Oct 27 09:14:40 2015 +0800 Committer: Sun Dapeng <[email protected]> Committed: Tue Oct 27 09:14:40 2015 +0800 ---------------------------------------------------------------------- .../sentry/tests/e2e/dbprovider/TestDatabaseProvider.java | 7 +++++++ 1 file changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/4a4bfecf/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java index dc008a2..98de57d 100644 --- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java +++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/dbprovider/TestDatabaseProvider.java @@ -1225,6 +1225,7 @@ public class TestDatabaseProvider extends AbstractTestWithStaticConfiguration { Connection connection = context.createConnection(ADMIN1); Statement statement = context.createStatement(connection); + statement.execute("CREATE TABLE IF NOT EXISTS tab1(c1 string)"); //Drop a role which does not exist context.assertSentryException(statement, "DROP ROLE role1", SentryNoSuchObjectException.class.getSimpleName()); @@ -1474,6 +1475,7 @@ public class TestDatabaseProvider extends AbstractTestWithStaticConfiguration { ResultSet resultSet = statement.executeQuery("SHOW GRANT ROLE role1"); assertResultSize(resultSet, 0); statement.execute("CREATE ROLE role2"); + statement.execute("CREATE TABLE IF NOT EXISTS t1(c1 string, c2 int)"); statement.execute("GRANT SELECT ON TABLE t1 TO ROLE role1"); statement.execute("GRANT ROLE role1 to GROUP " + USERGROUP1); @@ -1532,6 +1534,10 @@ public class TestDatabaseProvider extends AbstractTestWithStaticConfiguration { Connection connection = context.createConnection(ADMIN1); Statement statement = context.createStatement(connection); statement.execute("CREATE ROLE role1"); + statement.execute("CREATE TABLE IF NOT EXISTS t1(c1 string, c2 int)"); + statement.execute("CREATE TABLE IF NOT EXISTS t2(c1 string, c2 int)"); + statement.execute("CREATE TABLE IF NOT EXISTS t3(c1 string, c2 int)"); + statement.execute("CREATE TABLE IF NOT EXISTS t4(c1 string, c2 int)"); statement.execute("GRANT SELECT (c1) ON TABLE t1 TO ROLE role1"); statement.execute("GRANT SELECT (c2) ON TABLE t2 TO ROLE role1"); statement.execute("GRANT SELECT (c1,c2) ON TABLE t3 TO ROLE role1"); @@ -1667,6 +1673,7 @@ public class TestDatabaseProvider extends AbstractTestWithStaticConfiguration { Connection connection = context.createConnection(ADMIN1); Statement statement = context.createStatement(connection); statement.execute("CREATE ROLE role1"); + statement.execute("CREATE TABLE IF NOT EXISTS t1(c1 string)"); statement.execute("GRANT SELECT ON TABLE t1 TO ROLE role1"); //On table - positive
