You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by an...@apache.org on 2016/06/21 15:58:21 UTC
sentry git commit: SENTRY-1346: add a test case into hdfs acl e2e
suite to test a db.tbl wit out partition,
can take more than certain number groups.
Repository: sentry
Updated Branches:
refs/heads/master 8b8442bb2 -> 5a648880c
SENTRY-1346: add a test case into hdfs acl e2e suite to test a db.tbl wit out partition, can take more than certain number groups.
Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/5a648880
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/5a648880
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/5a648880
Branch: refs/heads/master
Commit: 5a648880ca1c354c6d9eadb7c7a1c7f997dd1a7b
Parents: 8b8442b
Author: Anne Yu <an...@cloudera.com>
Authored: Mon Jun 20 17:16:41 2016 -0700
Committer: Anne Yu <an...@cloudera.com>
Committed: Tue Jun 21 09:33:32 2016 -0700
----------------------------------------------------------------------
.../sentry/tests/e2e/hdfs/TestDbHdfsBase.java | 28 ++++++++++++++--
.../tests/e2e/hdfs/TestDbHdfsMaxGroups.java | 35 ++++++++++++++++++++
2 files changed, 61 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sentry/blob/5a648880/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsBase.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsBase.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsBase.java
index 44ce575..e545c37 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsBase.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsBase.java
@@ -44,7 +44,7 @@ import org.junit.BeforeClass;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.equalToIgnoringCase;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -231,7 +231,7 @@ public abstract class TestDbHdfsBase extends AbstractTestWithStaticConfiguration
}
break;
}
- assertThat(retry, lessThanOrEqualTo(NUM_RETRIES_FOR_ACLS));
+ assertThat(retry, lessThan(NUM_RETRIES_FOR_ACLS));
if (recursive && fileSystem.getFileStatus(path).isDirectory()) {
FileStatus[] children = fileSystem.listStatus(path);
for (FileStatus fs : children) {
@@ -329,6 +329,30 @@ public abstract class TestDbHdfsBase extends AbstractTestWithStaticConfiguration
}
}
+ /**
+ * Create test database and table with location pointing
+ * to testPathLoc without partitions
+ * @param db
+ * @param tbl
+ * @throws Exception
+ */
+ protected void dropRecreateDbTblNoPar(String db, String tbl) throws Exception {
+ Connection connection = context.createConnection(ADMIN1);
+ Statement statement = connection.createStatement();
+ exec(statement, "DROP DATABASE IF EXISTS " + db + " CASCADE");
+ exec(statement, "CREATE DATABASE " + db);
+ exec(statement, "USE " + db);
+ exec(statement, "CREATE TABLE " + tbl + "(number INT, value STRING)");
+ exec(statement, "INSERT INTO TABLE " + tbl + " VALUES (1, 'test1')");
+ exec(statement, "SELECT * FROM " + tbl);
+ if (statement != null) {
+ statement.close();
+ }
+ if (connection != null ) {
+ connection.close();
+ }
+ }
+
protected static void kinitFromKeytabFile (String user, String keyTabFile) throws IOException {
Configuration conf = new Configuration();
conf.set("hadoop.security.authentication", authenticationType);
http://git-wip-us.apache.org/repos/asf/sentry/blob/5a648880/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsMaxGroups.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsMaxGroups.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsMaxGroups.java
index 623ed5d..6dd03d5 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsMaxGroups.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestDbHdfsMaxGroups.java
@@ -194,4 +194,39 @@ public class TestDbHdfsMaxGroups extends TestDbHdfsBase {
// column level perm should not syncup acls to any db, tbl and par paths
verifyNoAclRecursive(colacls, extDbDir, true);
}
+
+ /**
+ * Test Db and tbl level acls are synced up to db, tbl (no partitions)
+ * @throws Exception
+ */
+ @Test
+ public void testIntDbTblMaxAclsWithGroupsNoPar() throws Exception {
+ final String TEST_DB = "test_hdfs_max_group_int_nopar_db";
+ String extDbDir = Path.getPathWithoutSchemeAndAuthority(new Path(metastoreDir))
+ + "/" + TEST_DB + ".db";
+ LOGGER.info("extDbDir = " + extDbDir);
+ dropRecreateDbTblNoPar(TEST_DB, TEST_TBL);
+
+ String tblPathLoc = extDbDir + "/" + TEST_TBL;
+ LOGGER.info("tblPathLoc = " + tblPathLoc);
+ Connection connection = context.createConnection(ADMIN1);
+ Statement statement = connection.createStatement();
+ exec(statement, "USE " + TEST_DB);
+ dropRecreateRole(statement, TEST_ROLE1);
+ exec(statement, "GRANT SELECT ON TABLE " + TEST_TBL + " TO ROLE " + TEST_ROLE1);
+
+ List<AclEntry> dbacls = new ArrayList<>();
+ List<AclEntry> tblacls = new ArrayList<>();
+ for (int i = 0; i < MAX_NUM_OF_GROUPS; i ++) {
+ String tblgrp = "tblgrp" + String.valueOf(i);
+ tblacls.add(AclEntry.parseAclEntry("group:" + tblgrp + ":r-x", true));
+ exec(statement, "GRANT ROLE " + TEST_ROLE1 + " TO GROUP " + tblgrp);
+ }
+ context.close();
+
+ // tbl level privileges should sync up acls to tbl and par paths
+ verifyAclsRecursive(tblacls, tblPathLoc, true);
+ // tbl level privileges should not sync up acls to db path
+ verifyNoAclRecursive(tblacls, extDbDir, false);
+ }
}