From 31b4fbdee58d377e6135b53c1f910552d90d645d Mon Sep 17 00:00:00 2001 From: Bharath Vissapragada Date: Wed, 15 Jan 2020 09:16:28 -0800 Subject: [PATCH] HBASE-23665: Split unit tests from TestTableName into a separate test-only class. (#1032) Signed-off-by: Nick Dimiduk --- .../hadoop/hbase/TableNameTestRule.java | 38 ++++++ .../apache/hadoop/hbase/TestTableName.java | 126 +++++++----------- .../TestScannerRetriableFailure.java | 6 +- .../access/TestAccessController2.java | 29 ++-- .../TestCellACLWithMultipleVersions.java | 73 +++++----- .../hbase/security/access/TestCellACLs.java | 50 ++++--- .../access/TestScanEarlyTermination.java | 29 ++-- .../access/TestWithDisabledAuthorization.java | 98 +++++++------- .../snapshot/TestSnapshotClientRetries.java | 12 +- .../TestSnapshotWhenChoreCleaning.java | 4 +- 10 files changed, 231 insertions(+), 234 deletions(-) create mode 100644 hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java new file mode 100644 index 000000000000..b5654265efac --- /dev/null +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TableNameTestRule.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase; + +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; + +/** + * Returns a {@code TableName} based on currently running test method name. + */ +public class TableNameTestRule extends TestWatcher { + + private TableName tableName; + + @Override + protected void starting(Description description) { + tableName = TableName.valueOf(description.getMethodName()); + } + + public TableName getTableName() { + return tableName; + } +} diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java index 43a384ade931..e1cd52adafef 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestTableName.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -20,99 +20,36 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; - +import static org.junit.Assert.assertThrows; import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Map; -import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.MiscTests; +import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.rules.TestWatcher; -import org.junit.runner.Description; /** - * Returns a {@code byte[]} containing the name of the currently running test method. + * Tests for various kinds of TableNames. */ -@Category({MiscTests.class, MediumTests.class}) -public class TestTableName extends TestWatcher { - +@Category({MiscTests.class, SmallTests.class}) +public class TestTableName { @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestTableName.class); - private TableName tableName; - - /** - * Invoked when a test is about to start - */ - @Override - protected void starting(Description description) { - tableName = TableName.valueOf(description.getMethodName()); - } - - public TableName getTableName() { - return tableName; - } - - String[] emptyNames = {"", " "}; - String[] invalidNamespace = {":a", "%:a"}; - String[] legalTableNames = {"foo", "with-dash_under.dot", "_under_start_ok", + private static String[] emptyNames = {"", " "}; + private static String[] invalidNamespace = {":a", "%:a"}; + private static String[] legalTableNames = {"foo", "with-dash_under.dot", "_under_start_ok", "with-dash.with_underscore", "02-01-2012.my_table_01-02", "xyz._mytable_", "9_9_0.table_02", "dot1.dot2.table", "new.-mytable", "with-dash.with.dot", "legal..t2", "legal..legal.t2", "trailingdots..", "trailing.dots...", "ns:mytable", "ns:_mytable_", "ns:my_table_01-02"}; - String[] illegalTableNames = {".dot_start_illegal", "-dash_start_illegal", "spaces not ok", - "-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash", + private static String[] illegalTableNames = {".dot_start_illegal", "-dash_start_illegal", + "spaces not ok", "-dash-.start_illegal", "new.table with space", "01 .table", "ns:-illegaldash", "new:.illegaldot", "new:illegalcolon1:", "new:illegalcolon1:2"}; - - @Test(expected = IllegalArgumentException.class) - public void testInvalidNamespace() { - for (String tn : invalidNamespace) { - TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); - fail("invalid namespace " + tn - + " should have failed with IllegalArgumentException for namespace"); - } - } - - @Test(expected = IllegalArgumentException.class) - public void testEmptyNamespaceName() { - for (String nn : emptyNames) { - TableName.isLegalNamespaceName(Bytes.toBytes(nn)); - fail("invalid Namespace name " + nn + " should have failed with IllegalArgumentException"); - } - } - - @Test(expected = IllegalArgumentException.class) - public void testEmptyTableName() { - for (String tn : emptyNames) { - TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); - fail("invalid tablename " + tn + " should have failed with IllegalArgumentException"); - } - } - - @Test - public void testLegalHTableNames() { - for (String tn : legalTableNames) { - TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); - } - } - - @Test - public void testIllegalHTableNames() { - for (String tn : illegalTableNames) { - try { - TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); - fail("invalid tablename " + tn + " should have failed"); - } catch (Exception e) { - // expected - } - } - } - static class Names { String ns; byte[] nsb; @@ -147,7 +84,6 @@ public boolean equals(Object o) { if (!tn.equals(names.tn)) { return false; } - return true; } @@ -159,7 +95,7 @@ public int hashCode() { } } - Names[] names = new Names[] { + private static Names[] names = new Names[] { new Names("n1", "n1"), new Names("n2", "n2"), new Names("table1", "table1"), @@ -172,9 +108,41 @@ public int hashCode() { new Names("n2", "table2") }; - @Test - public void testValueOf() { + @Test public void testInvalidNamespace() { + for (String tn : invalidNamespace) { + assertThrows(IllegalArgumentException.class, + () -> TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn))); + } + } + + @Test public void testEmptyNamespaceName() { + for (String nn : emptyNames) { + assertThrows(IllegalArgumentException.class, + () -> TableName.isLegalNamespaceName(Bytes.toBytes(nn))); + } + } + + @Test public void testEmptyTableName() { + for (String tn : emptyNames) { + assertThrows(IllegalArgumentException.class, + () -> TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn))); + } + } + + @Test public void testLegalHTableNames() { + for (String tn : legalTableNames) { + TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn)); + } + } + @Test public void testIllegalHTableNames() { + for (String tn : illegalTableNames) { + assertThrows(Exception.class, + () -> TableName.isLegalFullyQualifiedTableName(Bytes.toBytes(tn))); + } + } + + @Test public void testValueOf() { Map inCache = new HashMap<>(); // fill cache for (Names name : names) { @@ -188,7 +156,6 @@ public void testValueOf() { assertSame(inCache.get(name.nn), validateNames(TableName.valueOf( ByteBuffer.wrap(name.nsb), ByteBuffer.wrap(name.tnb)), name)); } - } private TableName validateNames(TableName expected, Names names) { @@ -200,5 +167,4 @@ private TableName validateNames(TableName expected, Names names) { assertArrayEquals(expected.getNamespace(), names.nsb); return expected; } - } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java index 9345f7c94f34..8b4f2957991d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerRetriableFailure.java @@ -30,7 +30,7 @@ import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.TestTableName; +import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; @@ -68,7 +68,7 @@ public class TestScannerRetriableFailure { private static final String FAMILY_NAME_STR = "f"; private static final byte[] FAMILY_NAME = Bytes.toBytes(FAMILY_NAME_STR); - @Rule public TestTableName TEST_TABLE = new TestTableName(); + @Rule public TableNameTestRule testTable = new TableNameTestRule(); public static class FaultyScannerObserver implements RegionCoprocessor, RegionObserver { private int faults = 0; @@ -116,7 +116,7 @@ public static void tearDown() throws Exception { @Test public void testFaultyScanner() throws Exception { - TableName tableName = TEST_TABLE.getTableName(); + TableName tableName = testTable.getTableName(); Table table = UTIL.createTable(tableName, FAMILY_NAME); try { final int NUM_ROWS = 100; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java index 8dfb7663d64f..5b483696fb43 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import java.util.Arrays; import java.util.List; import org.apache.hadoop.conf.Configuration; @@ -34,8 +33,8 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNotFoundException; -import org.apache.hadoop.hbase.TestTableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; @@ -105,7 +104,7 @@ public class TestAccessController2 extends SecureTestUtil { private static User TESTGROUP2_USER1; @Rule - public TestTableName TEST_TABLE = new TestTableName(); + public TableNameTestRule testTable = new TableNameTestRule(); private String namespace = "testNamespace"; private String tname = namespace + ":testtable1"; private TableName tableName = TableName.valueOf(tname); @@ -187,7 +186,7 @@ public void testCreateWithCorrectOwner() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - HTableDescriptor desc = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor desc = new HTableDescriptor(testTable.getTableName()); desc.addFamily(new HColumnDescriptor(TEST_FAMILY)); try (Connection connection = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration(), testUser)) { @@ -198,11 +197,11 @@ public Object run() throws Exception { return null; } }, testUser); - TEST_UTIL.waitTableAvailable(TEST_TABLE.getTableName()); + TEST_UTIL.waitTableAvailable(testTable.getTableName()); // Verify that owner permissions have been granted to the test user on the // table just created List perms = PermissionStorage - .getTablePermissions(conf, TEST_TABLE.getTableName()).get(testUser.getShortName()); + .getTablePermissions(conf, testTable.getTableName()).get(testUser.getShortName()); assertNotNull(perms); assertFalse(perms.isEmpty()); // Should be RWXCA @@ -220,7 +219,7 @@ public void testCreateTableWithGroupPermissions() throws Exception { AccessTestAction createAction = new AccessTestAction() { @Override public Object run() throws Exception { - HTableDescriptor desc = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor desc = new HTableDescriptor(testTable.getTableName()); desc.addFamily(new HColumnDescriptor(TEST_FAMILY)); try (Connection connection = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration())) { @@ -261,13 +260,13 @@ public void testACLTableAccess() throws Exception { User nsCreate = User.createUserForTesting(conf, "nsCreate", new String[0]); User nsAdmin = User.createUserForTesting(conf, "nsAdmin", new String[0]); SecureTestUtil.grantOnNamespace(TEST_UTIL, nsRead.getShortName(), - TEST_TABLE.getTableName().getNamespaceAsString(), Action.READ); + testTable.getTableName().getNamespaceAsString(), Action.READ); SecureTestUtil.grantOnNamespace(TEST_UTIL, nsWrite.getShortName(), - TEST_TABLE.getTableName().getNamespaceAsString(), Action.WRITE); + testTable.getTableName().getNamespaceAsString(), Action.WRITE); SecureTestUtil.grantOnNamespace(TEST_UTIL, nsCreate.getShortName(), - TEST_TABLE.getTableName().getNamespaceAsString(), Action.CREATE); + testTable.getTableName().getNamespaceAsString(), Action.CREATE); SecureTestUtil.grantOnNamespace(TEST_UTIL, nsAdmin.getShortName(), - TEST_TABLE.getTableName().getNamespaceAsString(), Action.ADMIN); + testTable.getTableName().getNamespaceAsString(), Action.ADMIN); // Table users User tableRead = User.createUserForTesting(conf, "tableRead", new String[0]); @@ -275,13 +274,13 @@ public void testACLTableAccess() throws Exception { User tableCreate = User.createUserForTesting(conf, "tableCreate", new String[0]); User tableAdmin = User.createUserForTesting(conf, "tableAdmin", new String[0]); SecureTestUtil.grantOnTable(TEST_UTIL, tableRead.getShortName(), - TEST_TABLE.getTableName(), null, null, Action.READ); + testTable.getTableName(), null, null, Action.READ); SecureTestUtil.grantOnTable(TEST_UTIL, tableWrite.getShortName(), - TEST_TABLE.getTableName(), null, null, Action.WRITE); + testTable.getTableName(), null, null, Action.WRITE); SecureTestUtil.grantOnTable(TEST_UTIL, tableCreate.getShortName(), - TEST_TABLE.getTableName(), null, null, Action.CREATE); + testTable.getTableName(), null, null, Action.CREATE); SecureTestUtil.grantOnTable(TEST_UTIL, tableAdmin.getShortName(), - TEST_TABLE.getTableName(), null, null, Action.ADMIN); + testTable.getTableName(), null, null, Action.ADMIN); grantGlobal(TEST_UTIL, TESTGROUP_1_NAME, Action.WRITE); try { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java index b4dd8c63b4c5..e2690d541c1e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java @@ -19,7 +19,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; - import java.io.IOException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; @@ -31,8 +30,8 @@ import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNotFoundException; -import org.apache.hadoop.hbase.TestTableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; @@ -71,7 +70,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil { private static final Logger LOG = LoggerFactory.getLogger(TestCellACLWithMultipleVersions.class); @Rule - public TestTableName TEST_TABLE = new TestTableName(); + public TableNameTestRule testTable = new TableNameTestRule(); private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final byte[] TEST_FAMILY1 = Bytes.toBytes("f1"); private static final byte[] TEST_FAMILY2 = Bytes.toBytes("f2"); @@ -133,7 +132,7 @@ public static void tearDownAfterClass() throws Exception { @Before public void setUp() throws Exception { - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY1); hcd.setMaxVersions(4); htd.setOwner(USER_OWNER); @@ -148,7 +147,7 @@ public void setUp() throws Exception { admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); } } - TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName()); + TEST_UTIL.waitTableEnabled(testTable.getTableName()); LOG.info("Sleeping a second because of HBASE-12581"); Threads.sleep(1000); } @@ -163,7 +162,7 @@ public void testCellPermissionwithVersions() throws Exception { @Override public Object run() throws Exception { try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { Put p; // with ro ACL p = new Put(TEST_ROW).addColumn(TEST_FAMILY1, TEST_Q1, ZERO); @@ -195,7 +194,7 @@ public Object run() throws Exception { Get get = new Get(TEST_ROW); get.setMaxVersions(10); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { return t.get(get).listCells(); } } @@ -207,7 +206,7 @@ public Object run() throws Exception { Get get = new Get(TEST_ROW); get.setMaxVersions(10); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { return t.get(get).listCells(); } } @@ -223,7 +222,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { Put p; p = new Put(TEST_ROW).addColumn(TEST_FAMILY1, TEST_Q1, ZERO); p.setACL(writePerms); @@ -269,7 +268,7 @@ public void testCellPermissionsWithDeleteMutipleVersions() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { // with rw ACL for "user1" Put p = new Put(TEST_ROW1); p.addColumn(TEST_FAMILY1, TEST_Q1, ZERO); @@ -294,7 +293,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { // with rw ACL for "user1", "user2" and "@group" Put p = new Put(TEST_ROW1); p.addColumn(TEST_FAMILY1, TEST_Q1, ZERO); @@ -322,7 +321,7 @@ public Object run() throws Exception { @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(TEST_ROW1); d.addColumns(TEST_FAMILY1, TEST_Q1); d.addColumns(TEST_FAMILY1, TEST_Q2); @@ -345,7 +344,7 @@ public Void run() throws Exception { @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(TEST_ROW2); d.addFamily(TEST_FAMILY1); t.delete(d); @@ -362,7 +361,7 @@ private void verifyUserDeniedForDeleteMultipleVersions(final User user, final by @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(row); d.addColumns(TEST_FAMILY1, q1); d.addColumns(TEST_FAMILY1, q2); @@ -386,7 +385,7 @@ public void testDeleteWithFutureTimestamp() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { // Store a read write ACL without a timestamp, server will use current time Put p = new Put(TEST_ROW).addColumn(TEST_FAMILY1, TEST_Q2, ONE); Map readAndWritePerms = @@ -416,7 +415,7 @@ public Object run() throws Exception { public Object run() throws Exception { Get get = new Get(TEST_ROW).addColumn(TEST_FAMILY1, TEST_Q1); try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { return t.get(get).listCells(); } } @@ -428,7 +427,7 @@ public Object run() throws Exception { public Object run() throws Exception { Get get = new Get(TEST_ROW).addColumn(TEST_FAMILY1, TEST_Q2); try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { return t.get(get).listCells(); } } @@ -462,7 +461,7 @@ private AccessTestAction getDeleteFamilyAction(final byte[] fam) { public Object run() throws Exception { Delete delete = new Delete(TEST_ROW).addFamily(fam); try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { t.delete(delete); } } @@ -478,7 +477,7 @@ public void testCellPermissionsWithDeleteWithUserTs() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { // This version (TS = 123) with rw ACL for USER_OTHER and USER_OTHER2 Put p = new Put(TEST_ROW); p.addColumn(TEST_FAMILY1, TEST_Q1, 123L, ZERO); @@ -517,7 +516,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(TEST_ROW, 124L); d.addColumns(TEST_FAMILY1, TEST_Q1); t.delete(d); @@ -532,7 +531,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(TEST_ROW); d.addColumns(TEST_FAMILY1, TEST_Q2, 124L); t.delete(d); @@ -557,7 +556,7 @@ public void testCellPermissionsWithDeleteExactVersion() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Map permsU1andOwner = prepareCellPermissions( new String[] { user1.getShortName(), USER_OWNER.getShortName() }, Action.READ, @@ -611,7 +610,7 @@ public Object run() throws Exception { @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(TEST_ROW1); d.addColumn(TEST_FAMILY1, TEST_Q1, 123); d.addColumn(TEST_FAMILY1, TEST_Q2); @@ -633,7 +632,7 @@ private void verifyUserDeniedForDeleteExactVersion(final User user, final byte[] @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(row, 127); d.addColumns(TEST_FAMILY1, q1); d.addColumns(TEST_FAMILY1, q2); @@ -663,7 +662,7 @@ public void testCellPermissionsForIncrementWithMultipleVersions() throws Excepti @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Map permsU1andOwner = prepareCellPermissions( new String[] { user1.getShortName(), USER_OWNER.getShortName() }, Action.READ, @@ -700,7 +699,7 @@ public Object run() throws Exception { @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Increment inc = new Increment(TEST_ROW1); inc.setTimeRange(0, 123); inc.addColumn(TEST_FAMILY1, TEST_Q1, 2L); @@ -722,7 +721,7 @@ private void verifyUserDeniedForIncrementMultipleVersions(final User user, final @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Increment inc = new Increment(row); inc.setTimeRange(0, 127); inc.addColumn(TEST_FAMILY1, q1, 2L); @@ -751,7 +750,7 @@ public void testCellPermissionsForPutWithMultipleVersions() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Map permsU1andOwner = prepareCellPermissions( new String[] { user1.getShortName(), USER_OWNER.getShortName() }, Action.READ, @@ -794,7 +793,7 @@ public Object run() throws Exception { @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Put p = new Put(TEST_ROW1); p.addColumn(TEST_FAMILY1, TEST_Q1, 125, ZERO); p.addColumn(TEST_FAMILY1, TEST_Q2, ZERO); @@ -818,7 +817,7 @@ private void verifyUserDeniedForPutMultipleVersions(final User user, final byte[ @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Put p = new Put(row); // column Q1 covers version at 123 fr which user2 do not have permission p.addColumn(TEST_FAMILY1, q1, 124, value); @@ -847,7 +846,7 @@ public void testCellPermissionsForCheckAndDelete() throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Map permsU1andOwner = prepareCellPermissions( new String[] { user1.getShortName(), USER_OWNER.getShortName() }, Action.READ, @@ -900,7 +899,7 @@ public Object run() throws Exception { @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(TEST_ROW1); d.addColumns(TEST_FAMILY1, TEST_Q1, 120); t.checkAndMutate(TEST_ROW1, TEST_FAMILY1).qualifier(TEST_Q1) @@ -937,7 +936,7 @@ private void verifyUserAllowedforCheckAndDelete(final User user, final byte[] ro @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(row); d.addColumn(TEST_FAMILY1, q1, 120); t.checkAndMutate(row, TEST_FAMILY1).qualifier(q1).ifEquals(value).thenDelete(d); @@ -954,7 +953,7 @@ private void verifyUserDeniedForCheckAndDelete(final User user, final byte[] row @Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table t = connection.getTable(TEST_TABLE.getTableName())) { + try (Table t = connection.getTable(testTable.getTableName())) { Delete d = new Delete(row); d.addColumns(TEST_FAMILY1, TEST_Q1); t.checkAndMutate(row, TEST_FAMILY1).qualifier(TEST_Q1).ifEquals(value).thenDelete(d); @@ -971,11 +970,11 @@ public Void run() throws Exception { public void tearDown() throws Exception { // Clean the _acl_ table try { - TEST_UTIL.deleteTable(TEST_TABLE.getTableName()); + TEST_UTIL.deleteTable(testTable.getTableName()); } catch (TableNotFoundException ex) { // Test deleted the table, no problem - LOG.info("Test deleted table " + TEST_TABLE.getTableName()); + LOG.info("Test deleted table " + testTable.getTableName()); } - assertEquals(0, PermissionStorage.getTablePermissions(conf, TEST_TABLE.getTableName()).size()); + assertEquals(0, PermissionStorage.getTablePermissions(conf, testTable.getTableName()).size()); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java index 24dbaee3d735..726a93f8a66b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java @@ -18,7 +18,6 @@ package org.apache.hadoop.hbase.security.access; import static org.junit.Assert.assertEquals; - import java.util.HashMap; import java.util.List; import java.util.Map; @@ -31,8 +30,8 @@ import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNotFoundException; -import org.apache.hadoop.hbase.TestTableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; @@ -62,7 +61,6 @@ import org.junit.experimental.categories.Category; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import org.apache.hbase.thirdparty.com.google.common.collect.Lists; @Category({SecurityTests.class, LargeTests.class}) @@ -75,7 +73,7 @@ public class TestCellACLs extends SecureTestUtil { private static final Logger LOG = LoggerFactory.getLogger(TestCellACLs.class); @Rule - public TestTableName TEST_TABLE = new TestTableName(); + public TableNameTestRule testTable = new TableNameTestRule(); private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final byte[] TEST_FAMILY = Bytes.toBytes("f1"); private static final byte[] TEST_ROW = Bytes.toBytes("cellpermtest"); @@ -137,13 +135,13 @@ public static void tearDownAfterClass() throws Exception { public void setUp() throws Exception { // Create the test table (owner added to the _acl_ table) Admin admin = TEST_UTIL.getAdmin(); - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY); hcd.setMaxVersions(4); htd.setOwner(USER_OWNER); htd.addFamily(hcd); admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); - TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName()); + TEST_UTIL.waitTableEnabled(testTable.getTableName()); LOG.info("Sleeping a second because of HBASE-12581"); Threads.sleep(1000); } @@ -155,7 +153,7 @@ public void testCellPermissions() throws Exception { @Override public Object run() throws Exception { try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { Put p; // with ro ACL p = new Put(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1, ZERO); @@ -182,7 +180,7 @@ public Object run() throws Exception { public Object run() throws Exception { Get get = new Get(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { return t.get(get).listCells(); } } @@ -193,7 +191,7 @@ public Object run() throws Exception { public Object run() throws Exception { Get get = new Get(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q2); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { return t.get(get).listCells(); } } @@ -204,7 +202,7 @@ public Object run() throws Exception { public Object run() throws Exception { Get get = new Get(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q3); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { return t.get(get).listCells(); } } @@ -215,7 +213,7 @@ public Object run() throws Exception { public Object run() throws Exception { Get get = new Get(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q4); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { return t.get(get).listCells(); } } @@ -245,7 +243,7 @@ public List run() throws Exception { scan.setStopRow(Bytes.add(TEST_ROW, new byte[]{ 0 } )); scan.addFamily(TEST_FAMILY); Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName()); + Table t = connection.getTable(testTable.getTableName()); try { ResultScanner scanner = t.getScanner(scan); Result result = null; @@ -284,7 +282,7 @@ public List run() throws Exception { public Object run() throws Exception { Increment i = new Increment(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1, 1L); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { t.increment(i); } return null; @@ -296,7 +294,7 @@ public Object run() throws Exception { public Object run() throws Exception { Increment i = new Increment(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q2, 1L); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { t.increment(i); } return null; @@ -310,7 +308,7 @@ public Object run() throws Exception { // Tag this increment with an ACL that denies write permissions to USER_OTHER and GROUP i.setACL(prepareCellPermissions(usersAndGroups, Action.READ)); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { t.increment(i); } return null; @@ -322,7 +320,7 @@ public Object run() throws Exception { public Object run() throws Exception { Increment i = new Increment(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q3, 1L); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { t.increment(i); } return null; @@ -347,7 +345,7 @@ public Object run() throws Exception { public Object run() throws Exception { Delete delete = new Delete(TEST_ROW).addFamily(TEST_FAMILY); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { t.delete(delete); } return null; @@ -359,7 +357,7 @@ public Object run() throws Exception { public Object run() throws Exception { Delete delete = new Delete(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1); try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { t.delete(delete); } return null; @@ -378,10 +376,10 @@ public Object run() throws Exception { @Test public void testCoveringCheck() throws Exception { // Grant read access to USER_OTHER - grantOnTable(TEST_UTIL, USER_OTHER.getShortName(), TEST_TABLE.getTableName(), TEST_FAMILY, + grantOnTable(TEST_UTIL, USER_OTHER.getShortName(), testTable.getTableName(), TEST_FAMILY, null, Action.READ); // Grant read access to GROUP - grantOnTable(TEST_UTIL, AuthUtil.toGroupEntry(GROUP), TEST_TABLE.getTableName(), TEST_FAMILY, + grantOnTable(TEST_UTIL, AuthUtil.toGroupEntry(GROUP), testTable.getTableName(), TEST_FAMILY, null, Action.READ); // A write by USER_OTHER should be denied. @@ -396,7 +394,7 @@ public void testCoveringCheck() throws Exception { @Override public Object run() throws Exception { try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { Put p; p = new Put(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1, ZERO); t.put(p); @@ -421,7 +419,7 @@ private void verifyUserDeniedForWrite(final User user, final byte[] value) throw @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { Put p; p = new Put(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1, value); t.put(p); @@ -436,7 +434,7 @@ private void verifyUserAllowedForRead(final User user) throws Exception { @Override public Object run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { return t.get(new Get(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1)); } } @@ -455,11 +453,11 @@ private Map prepareCellPermissions(String[] users, Action... public void tearDown() throws Exception { // Clean the _acl_ table try { - TEST_UTIL.deleteTable(TEST_TABLE.getTableName()); + TEST_UTIL.deleteTable(testTable.getTableName()); } catch (TableNotFoundException ex) { // Test deleted the table, no problem - LOG.info("Test deleted table " + TEST_TABLE.getTableName()); + LOG.info("Test deleted table " + testTable.getTableName()); } - assertEquals(0, PermissionStorage.getTablePermissions(conf, TEST_TABLE.getTableName()).size()); + assertEquals(0, PermissionStorage.getTablePermissions(conf, testTable.getTableName()).size()); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java index 0e6c66afa49d..8eb0605e345d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java @@ -20,7 +20,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Coprocessor; import org.apache.hadoop.hbase.HBaseClassTestRule; @@ -28,8 +27,8 @@ import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNotFoundException; -import org.apache.hadoop.hbase.TestTableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; @@ -65,7 +64,7 @@ public class TestScanEarlyTermination extends SecureTestUtil { private static final Logger LOG = LoggerFactory.getLogger(TestScanEarlyTermination.class); @Rule - public TestTableName TEST_TABLE = new TestTableName(); + public TableNameTestRule testTable = new TableNameTestRule(); private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final byte[] TEST_FAMILY1 = Bytes.toBytes("f1"); private static final byte[] TEST_FAMILY2 = Bytes.toBytes("f2"); @@ -116,7 +115,7 @@ public static void tearDownAfterClass() throws Exception { @Before public void setUp() throws Exception { Admin admin = TEST_UTIL.getAdmin(); - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); htd.setOwner(USER_OWNER); HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY1); hcd.setMaxVersions(10); @@ -130,25 +129,25 @@ public void setUp() throws Exception { htd.setConfiguration(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, "true"); admin.createTable(htd); - TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE.getTableName()); + TEST_UTIL.waitUntilAllRegionsAssigned(testTable.getTableName()); } @After public void tearDown() throws Exception { // Clean the _acl_ table try { - TEST_UTIL.deleteTable(TEST_TABLE.getTableName()); + TEST_UTIL.deleteTable(testTable.getTableName()); } catch (TableNotFoundException ex) { // Test deleted the table, no problem - LOG.info("Test deleted table " + TEST_TABLE.getTableName()); + LOG.info("Test deleted table " + testTable.getTableName()); } - assertEquals(0, PermissionStorage.getTablePermissions(conf, TEST_TABLE.getTableName()).size()); + assertEquals(0, PermissionStorage.getTablePermissions(conf, testTable.getTableName()).size()); } @Test public void testEarlyScanTermination() throws Exception { // Grant USER_OTHER access to TEST_FAMILY1 only - grantOnTable(TEST_UTIL, USER_OTHER.getShortName(), TEST_TABLE.getTableName(), TEST_FAMILY1, + grantOnTable(TEST_UTIL, USER_OTHER.getShortName(), testTable.getTableName(), TEST_FAMILY1, null, Action.READ); // Set up test data @@ -158,7 +157,7 @@ public Object run() throws Exception { // force a new RS connection conf.set("testkey", TEST_UTIL.getRandomUUID().toString()); Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName()); + Table t = connection.getTable(testTable.getTableName()); try { Put put = new Put(TEST_ROW).addColumn(TEST_FAMILY1, TEST_Q1, ZERO); t.put(put); @@ -185,7 +184,7 @@ public Object run() throws Exception { // force a new RS connection conf.set("testkey", TEST_UTIL.getRandomUUID().toString()); Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName()); + Table t = connection.getTable(testTable.getTableName()); try { Scan scan = new Scan().addFamily(TEST_FAMILY1); Result result = t.getScanner(scan).next(); @@ -211,7 +210,7 @@ public Object run() throws Exception { // force a new RS connection conf.set("testkey", TEST_UTIL.getRandomUUID().toString()); Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName()); + Table t = connection.getTable(testTable.getTableName()); try { Scan scan = new Scan(); Result result = t.getScanner(scan).next(); @@ -235,7 +234,7 @@ public Object run() throws Exception { // force a new RS connection conf.set("testkey", TEST_UTIL.getRandomUUID().toString()); Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName()); + Table t = connection.getTable(testTable.getTableName()); try { Scan scan = new Scan().addFamily(TEST_FAMILY2); Result result = t.getScanner(scan).next(); @@ -251,7 +250,7 @@ public Object run() throws Exception { }, USER_OTHER); // Now grant USER_OTHER access to TEST_FAMILY2:TEST_Q2 - grantOnTable(TEST_UTIL, USER_OTHER.getShortName(), TEST_TABLE.getTableName(), TEST_FAMILY2, + grantOnTable(TEST_UTIL, USER_OTHER.getShortName(), testTable.getTableName(), TEST_FAMILY2, TEST_Q2, Action.READ); // A scan of FAMILY1 and FAMILY2 will produce combined results. In FAMILY2 @@ -263,7 +262,7 @@ public Object run() throws Exception { // force a new RS connection conf.set("testkey", TEST_UTIL.getRandomUUID().toString()); Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName()); + Table t = connection.getTable(testTable.getTableName()); try { Scan scan = new Scan(); Result result = t.getScanner(scan).next(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java index 6ab99569234a..eb7dcc644fd2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestWithDisabledAuthorization.java @@ -18,7 +18,6 @@ package org.apache.hadoop.hbase.security.access; import static org.junit.Assert.assertEquals; - import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; @@ -33,8 +32,8 @@ import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.TableNotFoundException; -import org.apache.hadoop.hbase.TestTableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Append; import org.apache.hadoop.hbase.client.Connection; @@ -78,7 +77,6 @@ import org.junit.experimental.categories.Category; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import org.apache.hbase.thirdparty.com.google.common.collect.Lists; @Category({SecurityTests.class, LargeTests.class}) @@ -105,7 +103,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil { private static RegionServerCoprocessorEnvironment RSCP_ENV; private RegionCoprocessorEnvironment RCP_ENV; - @Rule public TestTableName TEST_TABLE = new TestTableName(); + @Rule public TableNameTestRule testTable = new TableNameTestRule(); // default users @@ -177,15 +175,15 @@ public static void tearDownAfterClass() throws Exception { public void setUp() throws Exception { // Create the test table (owner added to the _acl_ table) Admin admin = TEST_UTIL.getAdmin(); - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY); hcd.setMaxVersions(100); htd.addFamily(hcd); htd.setOwner(USER_OWNER); admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); - TEST_UTIL.waitUntilAllRegionsAssigned(TEST_TABLE.getTableName()); + TEST_UTIL.waitUntilAllRegionsAssigned(testTable.getTableName()); - HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0); + HRegion region = TEST_UTIL.getHBaseCluster().getRegions(testTable.getTableName()).get(0); RegionCoprocessorHost rcpHost = region.getCoprocessorHost(); RCP_ENV = rcpHost.createEnvironment(ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, TEST_UTIL.getConfiguration()); @@ -199,44 +197,44 @@ public void setUp() throws Exception { Permission.Action.WRITE); grantOnTable(TEST_UTIL, USER_RW.getShortName(), - TEST_TABLE.getTableName(), TEST_FAMILY, null, + testTable.getTableName(), TEST_FAMILY, null, Permission.Action.READ, Permission.Action.WRITE); // USER_CREATE is USER_RW plus CREATE permissions grantOnTable(TEST_UTIL, USER_CREATE.getShortName(), - TEST_TABLE.getTableName(), null, null, + testTable.getTableName(), null, null, Permission.Action.CREATE, Permission.Action.READ, Permission.Action.WRITE); grantOnTable(TEST_UTIL, USER_RO.getShortName(), - TEST_TABLE.getTableName(), TEST_FAMILY, null, + testTable.getTableName(), TEST_FAMILY, null, Permission.Action.READ); grantOnTable(TEST_UTIL, USER_QUAL.getShortName(), - TEST_TABLE.getTableName(), TEST_FAMILY, TEST_Q1, + testTable.getTableName(), TEST_FAMILY, TEST_Q1, Permission.Action.READ, Permission.Action.WRITE); assertEquals(5, PermissionStorage - .getTablePermissions(TEST_UTIL.getConfiguration(), TEST_TABLE.getTableName()).size()); + .getTablePermissions(TEST_UTIL.getConfiguration(), testTable.getTableName()).size()); } @After public void tearDown() throws Exception { // Clean the _acl_ table try { - deleteTable(TEST_UTIL, TEST_TABLE.getTableName()); + deleteTable(TEST_UTIL, testTable.getTableName()); } catch (TableNotFoundException ex) { // Test deleted the table, no problem - LOG.info("Test deleted table " + TEST_TABLE.getTableName()); + LOG.info("Test deleted table " + testTable.getTableName()); } // Verify all table/namespace permissions are erased assertEquals(0, PermissionStorage - .getTablePermissions(TEST_UTIL.getConfiguration(), TEST_TABLE.getTableName()).size()); + .getTablePermissions(TEST_UTIL.getConfiguration(), testTable.getTableName()).size()); assertEquals(0, PermissionStorage.getNamespacePermissions(TEST_UTIL.getConfiguration(), - TEST_TABLE.getTableName().getNamespaceAsString()).size()); + testTable.getTableName().getNamespaceAsString()).size()); } @Test @@ -278,7 +276,7 @@ public Void run() throws Exception { AccessTestAction checkTableAdmin = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), null, null, + checkTablePerms(TEST_UTIL, testTable.getTableName(), null, null, Permission.Action.ADMIN); return null; } @@ -290,7 +288,7 @@ public Void run() throws Exception { AccessTestAction checkTableCreate = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), null, null, + checkTablePerms(TEST_UTIL, testTable.getTableName(), null, null, Permission.Action.CREATE); return null; } @@ -302,7 +300,7 @@ public Void run() throws Exception { AccessTestAction checkTableRead = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), null, null, + checkTablePerms(TEST_UTIL, testTable.getTableName(), null, null, Permission.Action.READ); return null; } @@ -314,7 +312,7 @@ public Void run() throws Exception { AccessTestAction checkTableReadWrite = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), null, null, + checkTablePerms(TEST_UTIL, testTable.getTableName(), null, null, Permission.Action.READ, Permission.Action.WRITE); return null; } @@ -326,7 +324,7 @@ public Void run() throws Exception { AccessTestAction checkColumnRead = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), TEST_FAMILY, null, + checkTablePerms(TEST_UTIL, testTable.getTableName(), TEST_FAMILY, null, Permission.Action.READ); return null; } @@ -338,7 +336,7 @@ public Void run() throws Exception { AccessTestAction checkColumnReadWrite = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), TEST_FAMILY, null, + checkTablePerms(TEST_UTIL, testTable.getTableName(), TEST_FAMILY, null, Permission.Action.READ, Permission.Action.WRITE); return null; } @@ -350,7 +348,7 @@ public Void run() throws Exception { AccessTestAction checkQualifierRead = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), TEST_FAMILY, TEST_Q1, + checkTablePerms(TEST_UTIL, testTable.getTableName(), TEST_FAMILY, TEST_Q1, Permission.Action.READ); return null; } @@ -362,7 +360,7 @@ public Void run() throws Exception { AccessTestAction checkQualifierReadWrite = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), TEST_FAMILY, TEST_Q1, + checkTablePerms(TEST_UTIL, testTable.getTableName(), TEST_FAMILY, TEST_Q1, Permission.Action.READ, Permission.Action.WRITE); return null; } @@ -376,9 +374,9 @@ public Void run() throws Exception { public Void run() throws Exception { checkTablePerms(TEST_UTIL, new Permission[] { - Permission.newBuilder(TEST_TABLE.getTableName()).withFamily(TEST_FAMILY) + Permission.newBuilder(testTable.getTableName()).withFamily(TEST_FAMILY) .withQualifier(TEST_Q1).withActions(Action.READ).build(), - Permission.newBuilder(TEST_TABLE.getTableName()).withFamily(TEST_FAMILY) + Permission.newBuilder(testTable.getTableName()).withFamily(TEST_FAMILY) .withQualifier(TEST_Q2).withActions(Action.READ).build() }); return null; } @@ -392,10 +390,10 @@ public Void run() throws Exception { public Void run() throws Exception { checkTablePerms(TEST_UTIL, new Permission[] { - Permission.newBuilder(TEST_TABLE.getTableName()).withFamily(TEST_FAMILY) + Permission.newBuilder(testTable.getTableName()).withFamily(TEST_FAMILY) .withQualifier(TEST_Q1) .withActions(Permission.Action.READ, Permission.Action.WRITE).build(), - Permission.newBuilder(TEST_TABLE.getTableName()).withFamily(TEST_FAMILY) + Permission.newBuilder(testTable.getTableName()).withFamily(TEST_FAMILY) .withQualifier(TEST_Q2) .withActions(Permission.Action.READ, Permission.Action.WRITE).build() }); return null; @@ -420,7 +418,7 @@ public void testPassiveGrantRevoke() throws Exception { AccessTestAction checkTableRead = new AccessTestAction() { @Override public Void run() throws Exception { - checkTablePerms(TEST_UTIL, TEST_TABLE.getTableName(), TEST_FAMILY, null, + checkTablePerms(TEST_UTIL, testTable.getTableName(), TEST_FAMILY, null, Permission.Action.READ); return null; } @@ -434,7 +432,7 @@ public Void run() throws Exception { @Override public Void run() throws Exception { try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); - Table t = conn.getTable(TEST_TABLE.getTableName())) { + Table t = conn.getTable(testTable.getTableName())) { t.get(new Get(TEST_ROW).addFamily(TEST_FAMILY)); } return null; @@ -445,7 +443,7 @@ public Void run() throws Exception { // Grant read perms to the test user - grantOnTable(TEST_UTIL, tblUser.getShortName(), TEST_TABLE.getTableName(), TEST_FAMILY, + grantOnTable(TEST_UTIL, tblUser.getShortName(), testTable.getTableName(), TEST_FAMILY, null, Permission.Action.READ); // Now both the permission check and actual op will succeed @@ -455,7 +453,7 @@ public Void run() throws Exception { // Revoke read perms from the test user - revokeFromTable(TEST_UTIL, tblUser.getShortName(), TEST_TABLE.getTableName(), TEST_FAMILY, + revokeFromTable(TEST_UTIL, tblUser.getShortName(), testTable.getTableName(), TEST_FAMILY, null, Permission.Action.READ); // Now the permission check will indicate revocation but the actual op will still succeed @@ -472,7 +470,7 @@ public void testPassiveMasterOperations() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), htd, null); @@ -484,11 +482,11 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor(TEST_FAMILY2)); ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV), - TEST_TABLE.getTableName(), htd); + testTable.getTableName(), htd); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -498,7 +496,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preDeleteTable(ObserverContextImpl.createAndPrepare(CP_ENV), - TEST_TABLE.getTableName()); + testTable.getTableName()); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -508,7 +506,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preTruncateTable(ObserverContextImpl.createAndPrepare(CP_ENV), - TEST_TABLE.getTableName()); + testTable.getTableName()); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -518,7 +516,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preEnableTable(ObserverContextImpl.createAndPrepare(CP_ENV), - TEST_TABLE.getTableName()); + testTable.getTableName()); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -528,7 +526,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV), - TEST_TABLE.getTableName()); + testTable.getTableName()); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -537,7 +535,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName()); + HRegionInfo region = new HRegionInfo(testTable.getTableName()); ServerName srcServer = ServerName.valueOf("1.1.1.1", 1, 0); ServerName destServer = ServerName.valueOf("2.2.2.2", 2, 0); ACCESS_CONTROLLER.preMove(ObserverContextImpl.createAndPrepare(CP_ENV), region, @@ -550,7 +548,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName()); + HRegionInfo region = new HRegionInfo(testTable.getTableName()); ACCESS_CONTROLLER.preAssign(ObserverContextImpl.createAndPrepare(CP_ENV), region); return null; } @@ -560,7 +558,7 @@ public Object run() throws Exception { verifyAllowed(new AccessTestAction() { @Override public Object run() throws Exception { - HRegionInfo region = new HRegionInfo(TEST_TABLE.getTableName()); + HRegionInfo region = new HRegionInfo(testTable.getTableName()); ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), region, true); return null; @@ -591,7 +589,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { SnapshotDescription snapshot = new SnapshotDescription("foo"); - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); ACCESS_CONTROLLER.preSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; @@ -614,7 +612,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { SnapshotDescription snapshot = new SnapshotDescription("foo"); - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); ACCESS_CONTROLLER.preCloneSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; @@ -626,7 +624,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { SnapshotDescription snapshot = new SnapshotDescription("foo"); - HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName()); + HTableDescriptor htd = new HTableDescriptor(testTable.getTableName()); ACCESS_CONTROLLER.preRestoreSnapshot(ObserverContextImpl.createAndPrepare(CP_ENV), snapshot, htd); return null; @@ -649,7 +647,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { List tableNamesList = Lists.newArrayList(); - tableNamesList.add(TEST_TABLE.getTableName()); + tableNamesList.add(testTable.getTableName()); List descriptors = Lists.newArrayList(); ACCESS_CONTROLLER.preGetTableDescriptors(ObserverContextImpl.createAndPrepare(CP_ENV), tableNamesList, descriptors, ".+"); @@ -727,7 +725,7 @@ public Object run() throws Exception { public Object run() throws Exception { ACCESS_CONTROLLER.preSplitRegion( ObserverContextImpl.createAndPrepare(CP_ENV), - TEST_TABLE.getTableName(), + testTable.getTableName(), Bytes.toBytes("ss")); return null; } @@ -748,7 +746,7 @@ public Object run() throws Exception { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preSetTableQuota(ObserverContextImpl.createAndPrepare(CP_ENV), - TEST_TABLE.getTableName(), null); + testTable.getTableName(), null); return null; } }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE); @@ -936,7 +934,7 @@ public void testPassiveCellPermissions() throws Exception { @Override public Object run() throws Exception { try(Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName())) { + Table t = connection.getTable(testTable.getTableName())) { Put p; // with ro ACL p = new Put(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1, ZERO); @@ -968,7 +966,7 @@ public List run() throws Exception { scan.setStopRow(Bytes.add(TEST_ROW, new byte[]{ 0 } )); scan.addFamily(TEST_FAMILY); Connection connection = ConnectionFactory.createConnection(conf); - Table t = connection.getTable(TEST_TABLE.getTableName()); + Table t = connection.getTable(testTable.getTableName()); try { ResultScanner scanner = t.getScanner(scan); Result result = null; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java index 2f6c66fa5587..b99abe5d6b4f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotClientRetries.java @@ -25,7 +25,7 @@ import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.TestTableName; +import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.client.SnapshotDescription; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; @@ -53,7 +53,7 @@ public class TestSnapshotClientRetries { private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final Logger LOG = LoggerFactory.getLogger(TestSnapshotClientRetries.class); - @Rule public TestTableName TEST_TABLE = new TestTableName(); + @Rule public TableNameTestRule testTable = new TableNameTestRule(); @Before public void setUp() throws Exception { @@ -70,15 +70,15 @@ public void tearDown() throws Exception { @Test(expected=SnapshotExistsException.class) public void testSnapshotAlreadyExist() throws Exception { final String snapshotName = "testSnapshotAlreadyExist"; - TEST_UTIL.createTable(TEST_TABLE.getTableName(), "f"); - TEST_UTIL.getAdmin().snapshot(snapshotName, TEST_TABLE.getTableName()); - snapshotAndAssertOneRetry(snapshotName, TEST_TABLE.getTableName()); + TEST_UTIL.createTable(testTable.getTableName(), "f"); + TEST_UTIL.getAdmin().snapshot(snapshotName, testTable.getTableName()); + snapshotAndAssertOneRetry(snapshotName, testTable.getTableName()); } @Test(expected=SnapshotDoesNotExistException.class) public void testCloneNonExistentSnapshot() throws Exception { final String snapshotName = "testCloneNonExistentSnapshot"; - cloneAndAssertOneRetry(snapshotName, TEST_TABLE.getTableName()); + cloneAndAssertOneRetry(snapshotName, testTable.getTableName()); } public static class MasterSyncObserver implements MasterCoprocessor, MasterObserver { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotWhenChoreCleaning.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotWhenChoreCleaning.java index 22591c7bd370..b8211fd4496b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotWhenChoreCleaning.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotWhenChoreCleaning.java @@ -31,7 +31,7 @@ import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.TestTableName; +import org.apache.hadoop.hbase.TableNameTestRule; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.master.HMaster; @@ -75,7 +75,7 @@ public class TestSnapshotWhenChoreCleaning { private static Table TABLE; @Rule - public TestTableName TEST_TABLE = new TestTableName(); + public TableNameTestRule testTable = new TableNameTestRule(); @BeforeClass public static void setUp() throws Exception {