From ba155ad8542f64e431567f417127a1d690bb06b8 Mon Sep 17 00:00:00 2001 From: mbertozzi Date: Fri, 15 Mar 2013 20:11:37 +0000 Subject: [PATCH] HBASE-8122 TestAccessController depends on the execution order git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1457091 13f79535-47bb-0310-9956-ffa450edef68 --- .../security/access/TestAccessController.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java index 7008f2b78de..afd71ae97b4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.security.access; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -75,7 +76,9 @@ import org.apache.hadoop.hbase.exceptions.AccessDeniedException; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.access.Permission.Action; import org.apache.hadoop.hbase.util.Bytes; +import org.junit.After; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -113,9 +116,9 @@ public class TestAccessController { private static byte[] TEST_FAMILY = Bytes.toBytes("f1"); private static MasterCoprocessorEnvironment CP_ENV; - private static RegionCoprocessorEnvironment RCP_ENV; - private static RegionServerCoprocessorEnvironment RSCP_ENV; private static AccessController ACCESS_CONTROLLER; + private static RegionServerCoprocessorEnvironment RSCP_ENV; + private RegionCoprocessorEnvironment RCP_ENV; @BeforeClass public static void setupBeforeClass() throws Exception { @@ -150,7 +153,16 @@ public class TestAccessController { USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); USER_CREATE = User.createUserForTesting(conf, "tbl_create", new String[0]); USER_NONE = User.createUserForTesting(conf, "nouser", new String[0]); + } + @AfterClass + public static void tearDownAfterClass() throws Exception { + TEST_UTIL.shutdownMiniCluster(); + } + + @Before + public void setUp() throws Exception { + // Create the test table (owner added to the _acl_ table) HBaseAdmin admin = TEST_UTIL.getHBaseAdmin(); HTableDescriptor htd = new HTableDescriptor(TEST_TABLE); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); @@ -186,14 +198,18 @@ public class TestAccessController { protocol.grant(null, RequestConverter.buildGrantRequest(USER_CREATE.getShortName(), TEST_TABLE, null, null, AccessControlProtos.Permission.Action.CREATE)); + + assertEquals(4, AccessControlLists.getTablePermissions(conf, TEST_TABLE).size()); } finally { acl.close(); } } - @AfterClass - public static void tearDownAfterClass() throws Exception { - TEST_UTIL.shutdownMiniCluster(); + @After + public void tearDown() throws Exception { + // Clean the _acl_ table + TEST_UTIL.deleteTable(TEST_TABLE); + assertEquals(0, AccessControlLists.getTablePermissions(conf, TEST_TABLE).size()); } public void verifyAllowed(User user, PrivilegedExceptionAction... actions) throws Exception {