Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4F018103E9 for ; Wed, 9 Oct 2013 19:23:23 +0000 (UTC) Received: (qmail 62538 invoked by uid 500); 9 Oct 2013 19:23:23 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 62513 invoked by uid 500); 9 Oct 2013 19:23:22 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 61654 invoked by uid 99); 9 Oct 2013 19:23:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Oct 2013 19:23:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Oct 2013 19:23:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 245212388868; Wed, 9 Oct 2013 19:22:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1530770 - /hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/ Date: Wed, 09 Oct 2013 19:22:55 -0000 To: commits@hive.apache.org From: thejas@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131009192256.245212388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: thejas Date: Wed Oct 9 19:22:55 2013 New Revision: 1530770 URL: http://svn.apache.org/r1530770 Log: HIVE-5476: Authorization-provider tests fail in sequential run (Sushanth Sowmyan via Ashutosh Chauhan) Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java?rev=1530770&r1=1530769&r2=1530770&view=diff ============================================================================== --- hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java (original) +++ hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestClientSideAuthorizationProvider.java Wed Oct 9 19:22:55 2013 @@ -95,18 +95,26 @@ public class TestClientSideAuthorization } private void validateCreateDb(Database expectedDb, String dbName) { - assertEquals(expectedDb.getName(), dbName); + assertEquals(expectedDb.getName().toLowerCase(), dbName.toLowerCase()); } private void validateCreateTable(Table expectedTable, String tblName, String dbName) { assertNotNull(expectedTable); - assertEquals(expectedTable.getTableName(),tblName); - assertEquals(expectedTable.getDbName(),dbName); + assertEquals(expectedTable.getTableName().toLowerCase(),tblName.toLowerCase()); + assertEquals(expectedTable.getDbName().toLowerCase(),dbName.toLowerCase()); + } + + protected String getTestDbName(){ + return "smp_cl_db"; + } + + protected String getTestTableName(){ + return "smp_cl_tbl"; } public void testSimplePrivileges() throws Exception { - String dbName = "smpdb"; - String tblName = "smptbl"; + String dbName = getTestDbName(); + String tblName = getTestTableName(); String userName = ugi.getUserName(); @@ -159,6 +167,10 @@ public class TestClientSideAuthorization ret = driver.run("alter table "+tblName+" add partition (b='2011')"); assertEquals(0,ret.getResponseCode()); + allowDropOnTable(tblName, userName, tbl.getSd().getLocation()); + allowDropOnDb(dbName,userName,db.getLocationUri()); + driver.run("drop database if exists "+getTestDbName()+" cascade"); + } protected void allowCreateInTbl(String tableName, String userName, String location) @@ -182,6 +194,16 @@ public class TestClientSideAuthorization // nothing needed here by default } + protected void allowDropOnTable(String tblName, String userName, String location) + throws Exception { + driver.run("grant drop on table "+tblName+" to user "+userName); + } + + protected void allowDropOnDb(String dbName, String userName, String location) + throws Exception { + driver.run("grant drop on database "+dbName+" to user "+userName); + } + protected void assertNoPrivileges(CommandProcessorResponse ret){ assertNotNull(ret); assertFalse(0 == ret.getResponseCode()); Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java?rev=1530770&r1=1530769&r2=1530770&view=diff ============================================================================== --- hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java (original) +++ hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java Wed Oct 9 19:22:55 2013 @@ -115,19 +115,26 @@ public class TestMetastoreAuthorizationP } private void validateCreateDb(Database expectedDb, String dbName) { - assertEquals(expectedDb.getName(), dbName); + assertEquals(expectedDb.getName().toLowerCase(), dbName.toLowerCase()); } private void validateCreateTable(Table expectedTable, String tblName, String dbName) { assertNotNull(expectedTable); - assertEquals(expectedTable.getTableName(),tblName); - assertEquals(expectedTable.getDbName(),dbName); + assertEquals(expectedTable.getTableName().toLowerCase(),tblName.toLowerCase()); + assertEquals(expectedTable.getDbName().toLowerCase(),dbName.toLowerCase()); } - public void testSimplePrivileges() throws Exception { - String dbName = "smpdb"; - String tblName = "smptbl"; + protected String getTestDbName(){ + return "smp_ms_db"; + } + + protected String getTestTableName(){ + return "smp_ms_tbl"; + } + public void testSimplePrivileges() throws Exception { + String dbName = getTestDbName(); + String tblName = getTestTableName(); String userName = ugi.getUserName(); CommandProcessorResponse ret = driver.run("create database " + dbName); @@ -235,6 +242,10 @@ public class TestMetastoreAuthorizationP ret = driver.run("alter table "+tblName+" add partition (b='2011')"); assertEquals(0,ret.getResponseCode()); + allowDropOnTable(tblName, userName, tbl.getSd().getLocation()); + allowDropOnDb(dbName,userName,db.getLocationUri()); + driver.run("drop database if exists "+getTestDbName()+" cascade"); + } protected void allowCreateInTbl(String tableName, String userName, String location) @@ -258,6 +269,16 @@ public class TestMetastoreAuthorizationP driver.run("revoke create on database "+dbName+" from user "+userName); } + protected void allowDropOnTable(String tblName, String userName, String location) + throws Exception { + driver.run("grant drop on table "+tblName+" to user "+userName); + } + + protected void allowDropOnDb(String dbName, String userName, String location) + throws Exception { + driver.run("grant drop on database "+dbName+" to user "+userName); + } + protected void assertNoPrivileges(MetaException me){ assertNotNull(me); assertTrue(me.getMessage().indexOf("No privilege") != -1); Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java?rev=1530770&r1=1530769&r2=1530770&view=diff ============================================================================== --- hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java (original) +++ hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedClientSideAuthorizationProvider.java Wed Oct 9 19:22:55 2013 @@ -64,6 +64,18 @@ public class TestStorageBasedClientSideA setPermissions(location,"-r--r--r--"); } + @Override + protected void allowDropOnTable(String tblName, String userName, String location) + throws Exception { + setPermissions(location,"-rwxr--r--"); + } + + @Override + protected void allowDropOnDb(String dbName, String userName, String location) + throws Exception { + setPermissions(location,"-rwxr--r--"); + } + private void setPermissions(String locn, String permissions) throws Exception { FileSystem fs = FileSystem.get(new URI(locn), clientHiveConf); fs.setPermission(new Path(locn), FsPermission.valueOf(permissions)); @@ -76,4 +88,15 @@ public class TestStorageBasedClientSideA assertTrue(ret.getErrorMessage().indexOf("not permitted") != -1); } + + @Override + protected String getTestDbName(){ + return super.getTestDbName() + "_SBAP"; + } + + @Override + protected String getTestTableName(){ + return super.getTestTableName() + "_SBAP"; + } + } Modified: hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java?rev=1530770&r1=1530769&r2=1530770&view=diff ============================================================================== --- hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java (original) +++ hive/branches/branch-0.12/ql/src/test/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProvider.java Wed Oct 9 19:22:55 2013 @@ -69,6 +69,18 @@ public class TestStorageBasedMetastoreAu setPermissions(location,"-r--r--r--"); } + @Override + protected void allowDropOnTable(String tblName, String userName, String location) + throws Exception { + setPermissions(location,"-rwxr--r--"); + } + + @Override + protected void allowDropOnDb(String dbName, String userName, String location) + throws Exception { + setPermissions(location,"-rwxr--r--"); + } + private void setPermissions(String locn, String permissions) throws Exception { FileSystem fs = FileSystem.get(new URI(locn), clientHiveConf); fs.setPermission(new Path(locn), FsPermission.valueOf(permissions)); @@ -80,4 +92,14 @@ public class TestStorageBasedMetastoreAu assertTrue(me.getMessage().indexOf("not permitted") != -1); } + @Override + protected String getTestDbName(){ + return super.getTestDbName() + "_SBAP"; + } + + @Override + protected String getTestTableName(){ + return super.getTestTableName() + "_SBAP"; + } + }