From 1cf920db4395926c634ed0946a57dfa52227472f Mon Sep 17 00:00:00 2001 From: tedyu Date: Mon, 17 Sep 2018 08:25:11 -0700 Subject: [PATCH] HBASE-21160 Assertion in TestVisibilityLabelsWithDeletes#testDeleteColumnsWithoutAndWithVisibilityLabels is ignored (liubangchen) --- .../visibility/TestVisibilityLabels.java | 9 ++++---- ...ilityLabelsWithDefaultVisLabelService.java | 23 +++++++++---------- .../TestVisibilityLabelsWithDeletes.java | 20 ---------------- 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java index e10643410d4..770bf3e39a6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java @@ -423,6 +423,7 @@ public abstract class TestVisibilityLabels { try (Connection conn = ConnectionFactory.createConnection(conf)) { VisibilityClient.setAuths(conn, auths, user); } catch (Throwable e) { + throw new IOException(e); } return null; } @@ -450,7 +451,7 @@ public abstract class TestVisibilityLabels { try (Connection conn = ConnectionFactory.createConnection(conf)) { authsResponse = VisibilityClient.getAuths(conn, user); } catch (Throwable e) { - fail("Should not have failed"); + throw new IOException(e); } List authsList = new ArrayList<>(authsResponse.getAuthList().size()); for (ByteString authBS : authsResponse.getAuthList()) { @@ -475,7 +476,7 @@ public abstract class TestVisibilityLabels { try { authsResponse = VisibilityClient.getAuths(conn, user); } catch (Throwable e) { - fail("Should not have failed"); + throw new IOException(e); } } catch (Throwable e) { } @@ -515,7 +516,7 @@ public abstract class TestVisibilityLabels { try (Connection conn = ConnectionFactory.createConnection(conf)) { VisibilityClient.setAuths(conn, auths, user); } catch (Throwable e) { - fail("Should not have failed"); + throw new IOException(e); } // Removing the auths for SECRET and CONFIDENTIAL for the user. // Passing a non existing auth also. @@ -553,7 +554,7 @@ public abstract class TestVisibilityLabels { try (Connection conn = ConnectionFactory.createConnection(conf)) { authsResponse = VisibilityClient.getAuths(conn, user); } catch (Throwable e) { - fail("Should not have failed"); + throw new IOException(e); } List authsList = new ArrayList<>(authsResponse.getAuthList().size()); for (ByteString authBS : authsResponse.getAuthList()) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java index 0d7ff683144..5f8acfb3e91 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java @@ -22,7 +22,6 @@ import static org.apache.hadoop.hbase.security.visibility.VisibilityUtils.SYSTEM import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import com.google.protobuf.ByteString; import java.io.IOException; @@ -94,7 +93,7 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili try (Connection conn = ConnectionFactory.createConnection(conf)) { response = VisibilityClient.addLabels(conn, labels); } catch (Throwable e) { - fail("Should not have thrown exception"); + throw new IOException(e); } List resultList = response.getResultList(); assertEquals(5, resultList.size()); @@ -183,7 +182,7 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili try (Connection conn = ConnectionFactory.createConnection(conf)) { response = VisibilityClient.listLabels(conn, null); } catch (Throwable e) { - fail("Should not have thrown exception"); + throw new IOException(e); } // The addLabels() in setup added: // { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, COPYRIGHT, ACCENT, @@ -192,12 +191,12 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili // The 'system' label is excluded. List labels = response.getLabelList(); assertEquals(12, labels.size()); - assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom(CONFIDENTIAL.getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom("ABC".getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom("XYZ".getBytes()))); - assertFalse(labels.contains(ByteString.copyFrom(SYSTEM_LABEL.getBytes()))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(SECRET)))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(TOPSECRET)))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(CONFIDENTIAL)))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes("ABC")))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes("XYZ")))); + assertFalse(labels.contains(ByteString.copyFrom(Bytes.toBytes(SYSTEM_LABEL)))); return null; } }; @@ -214,13 +213,13 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili try (Connection conn = ConnectionFactory.createConnection(conf)) { response = VisibilityClient.listLabels(conn, ".*secret"); } catch (Throwable e) { - fail("Should not have thrown exception"); + throw new IOException(e); } // Only return the labels that end with 'secret' List labels = response.getLabelList(); assertEquals(2, labels.size()); - assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes()))); - assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes()))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(SECRET)))); + assertTrue(labels.contains(ByteString.copyFrom(Bytes.toBytes(TOPSECRET)))); return null; } }; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java index b0cabed46d7..405a7fa5ec1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java @@ -313,8 +313,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(1, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -334,8 +332,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -366,8 +362,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -386,8 +380,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -417,8 +409,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(1, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -438,8 +428,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -470,8 +458,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -490,8 +476,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes ResultScanner scanner = table.getScanner(s); Result[] next = scanner.next(3); assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -522,8 +506,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes // The delete would not be able to apply it because of visibility mismatch Result[] next = scanner.next(3); assertEquals(1, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; } @@ -544,8 +526,6 @@ public class TestVisibilityLabelsWithDeletes extends VisibilityLabelsWithDeletes Result[] next = scanner.next(3); // this will alone match assertEquals(0, next.length); - } catch (Throwable t) { - throw new IOException(t); } return null; }