HBASE-12581 TestCellACLWithMultipleVersions failing since task 5 HBASE-12404 (HBASE-12404 addendum)

This commit is contained in:
stack 2014-11-25 16:29:53 -08:00
parent b9dfcd01b8
commit c9376e6d37
1 changed files with 346 additions and 369 deletions

View File

@ -34,6 +34,8 @@ import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
@ -249,8 +251,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
// with rw ACL for "user1"
Put p = new Put(TEST_ROW1);
p.add(TEST_FAMILY1, TEST_Q1, ZERO);
@ -265,8 +267,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
p.setACL(user1.getShortName(), new Permission(Permission.Action.READ,
Permission.Action.WRITE));
t.put(p);
} finally {
t.close();
}
}
return null;
}
@ -275,8 +276,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
// with rw ACL for "user1" and "user2"
Put p = new Put(TEST_ROW1);
p.add(TEST_FAMILY1, TEST_Q1, ZERO);
@ -294,8 +295,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
p.add(TEST_FAMILY1, TEST_Q2, ZERO);
p.setACL(perms);
t.put(p);
} finally {
t.close();
}
}
return null;
}
@ -306,14 +306,13 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user1.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW1);
d.deleteColumns(TEST_FAMILY1, TEST_Q1);
d.deleteColumns(TEST_FAMILY1, TEST_Q2);
t.delete(d);
} finally {
t.close();
}
}
return null;
}
@ -323,8 +322,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user2.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW2);
d.deleteColumns(TEST_FAMILY1, TEST_Q1);
d.deleteColumns(TEST_FAMILY1, TEST_Q2);
@ -332,8 +331,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
fail("user2 should not be allowed to delete the row");
} catch (Exception e) {
} finally {
t.close();
}
}
return null;
}
@ -342,13 +340,12 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user1.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW2);
d.deleteFamily(TEST_FAMILY1);
t.delete(d);
} finally {
t.close();
}
}
return null;
}
@ -363,21 +360,20 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
// Store read only ACL at a future time
Put p = new Put(TEST_ROW).add(TEST_FAMILY1, TEST_Q1,
EnvironmentEdgeManager.currentTime() + 1000000,
ZERO);
p.setACL(USER_OTHER.getShortName(), new Permission(Permission.Action.READ));
t.put(p);
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
// Store a read write ACL without a timestamp, server will use current time
p = new Put(TEST_ROW).add(TEST_FAMILY1, TEST_Q2, ONE);
Put p = new Put(TEST_ROW).add(TEST_FAMILY1, TEST_Q2, ONE);
p.setACL(USER_OTHER.getShortName(), new Permission(Permission.Action.READ,
Permission.Action.WRITE));
t.put(p);
} finally {
t.close();
LOG.info("Stored at current time");
// Store read only ACL at a future time
p = new Put(TEST_ROW).add(TEST_FAMILY1, TEST_Q1,
EnvironmentEdgeManager.currentTime() + 1000000, ZERO);
p.setACL(USER_OTHER.getShortName(), new Permission(Permission.Action.READ));
t.put(p);
}
}
return null;
}
@ -389,11 +385,10 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
@Override
public Object run() throws Exception {
Get get = new Get(TEST_ROW).addColumn(TEST_FAMILY1, TEST_Q1);
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
return t.get(get).listCells();
} finally {
t.close();
}
}
}
};
@ -402,11 +397,10 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
@Override
public Object run() throws Exception {
Get get = new Get(TEST_ROW).addColumn(TEST_FAMILY1, TEST_Q2);
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
return t.get(get).listCells();
} finally {
t.close();
}
}
}
};
@ -422,11 +416,10 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
@Override
public Object run() throws Exception {
Delete delete = new Delete(TEST_ROW).deleteFamily(TEST_FAMILY1);
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
t.delete(delete);
} finally {
t.close();
}
}
return null;
}
@ -448,8 +441,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
USER_OWNER.runAs(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
// This version (TS = 123) with rw ACL for USER_OTHER and USER_OTHER2
Put p = new Put(TEST_ROW);
p.add(TEST_FAMILY1, TEST_Q1, 123L, ZERO);
@ -483,8 +476,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
t.put(p);
return null;
} finally {
t.close();
}
}
}
});
@ -493,13 +485,12 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
USER_OTHER2.runAs(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW, 124L);
d.deleteColumns(TEST_FAMILY1, TEST_Q1);
t.delete(d);
} finally {
t.close();
}
}
return null;
}
@ -509,13 +500,12 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
USER_OTHER2.runAs(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW);
d.deleteColumns(TEST_FAMILY1, TEST_Q2, 124L);
t.delete(d);
} finally {
t.close();
}
}
return null;
}
@ -535,8 +525,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Map<String, Permission> permsU1andOwner = new HashMap<String, Permission>();
permsU1andOwner.put(user1.getShortName(), new Permission(Permission.Action.READ,
Permission.Action.WRITE));
@ -580,8 +570,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
p.add(TEST_FAMILY2, TEST_Q2, 129, ZERO);
p.setACL(permsU1andOwner);
t.put(p);
} finally {
t.close();
}
}
return null;
}
@ -592,15 +581,14 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user1.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW1);
d.deleteColumn(TEST_FAMILY1, TEST_Q1, 123);
d.deleteColumn(TEST_FAMILY1, TEST_Q2);
d.deleteFamilyVersion(TEST_FAMILY2, 125);
t.delete(d);
} finally {
t.close();
}
}
return null;
}
@ -609,8 +597,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user2.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW1, 127);
d.deleteColumns(TEST_FAMILY1, TEST_Q1);
d.deleteColumns(TEST_FAMILY1, TEST_Q2);
@ -619,8 +607,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
fail("user2 can not do the delete");
} catch (Exception e) {
} finally {
t.close();
}
}
return null;
}
@ -640,8 +627,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Map<String, Permission> permsU1andOwner = new HashMap<String, Permission>();
permsU1andOwner.put(user1.getShortName(), new Permission(Permission.Action.READ,
Permission.Action.WRITE));
@ -669,8 +656,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
p.add(TEST_FAMILY1, TEST_Q2, 127, ZERO);
p.setACL(permsU1andOwner);
t.put(p);
} finally {
t.close();
}
}
return null;
}
@ -680,15 +666,14 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user1.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Increment inc = new Increment(TEST_ROW1);
inc.setTimeRange(0, 123);
inc.addColumn(TEST_FAMILY1, TEST_Q1, 2L);
t.increment(inc);
t.incrementColumnValue(TEST_ROW1, TEST_FAMILY1, TEST_Q2, 1L);
} finally {
t.close();
}
}
return null;
}
@ -697,8 +682,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user2.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Increment inc = new Increment(TEST_ROW1);
inc.setTimeRange(0, 127);
inc.addColumn(TEST_FAMILY1, TEST_Q2, 2L);
@ -706,8 +691,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
fail();
} catch (Exception e) {
} finally {
t.close();
}
}
return null;
}
@ -727,8 +711,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Map<String, Permission> permsU1andOwner = new HashMap<String, Permission>();
permsU1andOwner.put(user1.getShortName(), new Permission(Permission.Action.READ,
Permission.Action.WRITE));
@ -756,8 +740,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
p.add(TEST_FAMILY1, TEST_Q2, 127, ZERO);
p.setACL(permsU1andOwner);
t.put(p);
} finally {
t.close();
}
}
return null;
}
@ -769,16 +752,15 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user1.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Put p = new Put(TEST_ROW1);
p.add(TEST_FAMILY1, TEST_Q1, 125, ZERO);
p.add(TEST_FAMILY1, TEST_Q2, ZERO);
p.setACL(user2.getShortName(), new Permission(Permission.Action.READ,
Permission.Action.WRITE));
t.put(p);
} finally {
t.close();
}
}
return null;
}
@ -788,8 +770,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user2.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Put p = new Put(TEST_ROW1);
// column Q1 covers version at 123 fr which user2 do not have permission
p.add(TEST_FAMILY1, TEST_Q1, 124, ZERO);
@ -798,8 +780,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
fail();
} catch (Exception e) {
} finally {
t.close();
}
}
return null;
}
@ -817,8 +798,8 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
verifyAllowed(new AccessTestAction() {
@Override
public Object run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Map<String, Permission> permsU1andOwner = new HashMap<String, Permission>();
permsU1andOwner.put(user1.getShortName(), new Permission(Permission.Action.READ,
Permission.Action.WRITE));
@ -858,8 +839,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
p.add(TEST_FAMILY1, TEST_Q2, 127, ZERO);
p.setACL(user2.getShortName(), new Permission(Permission.Action.READ));
t.put(p);
} finally {
t.close();
}
}
return null;
}
@ -870,13 +850,12 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user1.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW1);
d.deleteColumns(TEST_FAMILY1, TEST_Q1, 120);
t.checkAndDelete(TEST_ROW1, TEST_FAMILY1, TEST_Q1, ZERO, d);
} finally {
t.close();
}
}
return null;
}
@ -886,15 +865,14 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user2.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW1);
d.deleteColumns(TEST_FAMILY1, TEST_Q1);
t.checkAndDelete(TEST_ROW1, TEST_FAMILY1, TEST_Q1, ZERO, d);
fail("user2 should not be allowed to do checkAndDelete");
} catch (Exception e) {
} finally {
t.close();
}
}
return null;
}
@ -905,13 +883,12 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
user2.runAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
Table t = new HTable(conf, TEST_TABLE.getTableName());
try {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Delete d = new Delete(TEST_ROW1);
d.deleteColumn(TEST_FAMILY1, TEST_Q2, 120);
t.checkAndDelete(TEST_ROW1, TEST_FAMILY1, TEST_Q2, ZERO, d);
} finally {
t.close();
}
}
return null;
}