Skip to content

Commit

Permalink
HBASE-24103 [Flakey Tests] TestSnapshotScannerHDFSAclController (#1416)
Browse files Browse the repository at this point in the history
Signed-off-by: stack <stack@apache.org>
  • Loading branch information
mymeiyi authored and saintstack committed Apr 2, 2020
1 parent 2109415 commit 5f8dea5
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public void testGrantGlobal1() throws Exception {
admin.snapshot(snapshot2, table);
TestHDFSAclHelper.canUserScanSnapshot(TEST_UTIL, grantUser, snapshot2, 6);
assertTrue(hasUserGlobalHdfsAcl(aclTable, grantUserName));
deleteTable(table);
}

@Test
Expand Down Expand Up @@ -205,6 +206,8 @@ public void testGrantGlobal2() throws Exception {
checkUserAclEntry(FS, helper.getGlobalRootPaths(), grantUserName, false, false);
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace1), grantUserName, true, true);
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace2), grantUserName, false, false);
deleteTable(table1);
deleteTable(table2);
}

@Test
Expand Down Expand Up @@ -236,6 +239,8 @@ public void testGrantGlobal3() throws Exception {
checkUserAclEntry(FS, helper.getGlobalRootPaths(), grantUserName, false, false);
checkUserAclEntry(FS, helper.getTableRootPaths(table2, false), grantUserName, false, false);
checkUserAclEntry(FS, helper.getTableRootPaths(table1, false), grantUserName, true, true);
deleteTable(table1);
deleteTable(table2);
}

@Test
Expand Down Expand Up @@ -268,6 +273,8 @@ public void testGrantNamespace1() throws Exception {
TestHDFSAclHelper.canUserScanSnapshot(TEST_UTIL, grantUser, snapshot1, -1);
assertFalse(hasUserNamespaceHdfsAcl(aclTable, grantUserName, namespace));
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace), grantUserName, false, false);
deleteTable(table1);
deleteTable(table2);
}

@Test
Expand All @@ -294,6 +301,7 @@ public void testGrantNamespace2() throws Exception {
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace), grantUserName, true, false);
assertTrue(hasUserTableHdfsAcl(aclTable, grantUserName, table1));
checkUserAclEntry(FS, helper.getTableRootPaths(table1, false), grantUserName, true, true);
deleteTable(table1);
}

@Test
Expand All @@ -319,6 +327,7 @@ public void testGrantNamespace3() throws Exception {
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace), grantUserName, true, true);
assertTrue(hasUserGlobalHdfsAcl(aclTable, grantUserName));
checkUserAclEntry(FS, helper.getGlobalRootPaths(), grantUserName, true, true);
deleteTable(table);
}

@Test
Expand Down Expand Up @@ -367,6 +376,7 @@ public void testGrantTable() throws Exception {
TestHDFSAclHelper.canUserScanSnapshot(TEST_UTIL, grantUser, snapshot1, -1);
assertFalse(hasUserTableHdfsAcl(aclTable, grantUserName, table1));
checkUserAclEntry(FS, helper.getTableRootPaths(table1, false), grantUserName, false, false);
deleteTable(table1);
}

@Test
Expand All @@ -385,6 +395,7 @@ public void testGrantMobTable() throws Exception {
assertTrue(hasUserTableHdfsAcl(aclTable, grantUserName, table));
checkUserAclEntry(FS, helper.getTableRootPaths(table, false), grantUserName, true, true);
}
deleteTable(table);
}

@Test
Expand All @@ -402,6 +413,7 @@ public void testRevokeGlobal1() throws Exception {
TestHDFSAclHelper.canUserScanSnapshot(TEST_UTIL, grantUser, snapshot1, -1);
assertFalse(hasUserGlobalHdfsAcl(aclTable, grantUserName));
checkUserAclEntry(FS, helper.getGlobalRootPaths(), grantUserName, false, false);
deleteTable(table1);
}

@Test
Expand All @@ -426,6 +438,7 @@ public void testRevokeGlobal2() throws Exception {
checkUserAclEntry(FS, helper.getGlobalRootPaths(), grantUserName, false, false);
assertTrue(hasUserNamespaceHdfsAcl(aclTable, grantUserName, namespace));
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace), grantUserName, true, true);
deleteTable(table1);
}

@Test
Expand All @@ -451,6 +464,7 @@ public void testRevokeGlobal3() throws Exception {
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace), grantUserName, true, false);
assertTrue(hasUserTableHdfsAcl(aclTable, grantUserName, table1));
checkUserAclEntry(FS, helper.getTableRootPaths(table1, false), grantUserName, true, true);
deleteTable(table1);
}

@Test
Expand Down Expand Up @@ -479,6 +493,7 @@ public void testRevokeNamespace1() throws Exception {
TestHDFSAclHelper.canUserScanSnapshot(TEST_UTIL, grantUser, snapshot1, 6);
assertFalse(hasUserNamespaceHdfsAcl(aclTable, grantUserName, namespace));
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace), grantUserName, true, true);
deleteTable(table1);
}

@Test
Expand All @@ -502,6 +517,7 @@ public void testRevokeNamespace2() throws Exception {
assertTrue(hasUserTableHdfsAcl(aclTable, grantUserName, table));
checkUserAclEntry(FS, helper.getTableRootPaths(table, false),
grantUserName, true, true);
deleteTable(table);
}

@Test
Expand All @@ -526,6 +542,7 @@ public void testRevokeTable1() throws Exception {
TestHDFSAclHelper.canUserScanSnapshot(TEST_UTIL, grantUser, snapshot, -1);
assertFalse(hasUserTableHdfsAcl(aclTable, grantUserName, table));
checkUserAclEntry(FS, helper.getTableRootPaths(table, false), grantUserName, false, false);
deleteTable(table);
}

@Test
Expand All @@ -547,6 +564,7 @@ public void testRevokeTable2() throws Exception {
checkUserAclEntry(FS, helper.getTableRootPaths(table, false), grantUserName, true, true);
assertTrue(hasUserNamespaceHdfsAcl(aclTable, grantUserName, namespace));
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace), grantUserName, true, true);
deleteTable(table);
}

@Test
Expand All @@ -568,6 +586,7 @@ public void testRevokeTable3() throws Exception {
checkUserAclEntry(FS, helper.getTableRootPaths(table, false), grantUserName, true, true);
assertTrue(hasUserGlobalHdfsAcl(aclTable, grantUserName));
checkUserAclEntry(FS, helper.getGlobalRootPaths(), grantUserName, true, true);
deleteTable(table);
}

@Test
Expand Down Expand Up @@ -606,6 +625,7 @@ public void testTruncateTable() throws Exception {
checkUserAclEntry(FS, helper.getTableRootPaths(tableName, false), grantUserName, true, true);
checkUserAclEntry(FS, helper.getNamespaceRootPaths(namespace), grantUserName, true, false);
}
deleteTable(tableName);
}

@Test
Expand Down Expand Up @@ -643,6 +663,7 @@ public void testDeleteTable() throws Exception {
// check tmp table directory does not exist
Path tmpTableDir = helper.getPathHelper().getTmpTableDir(table);
assertFalse(FS.exists(tmpTableDir));
deleteTable(table);
}

@Test
Expand Down Expand Up @@ -671,6 +692,7 @@ public void testDeleteNamespace() throws Exception {
assertFalse(FS.exists(helper.getPathHelper().getTmpNsDir(namespace)));
assertFalse(FS.exists(helper.getPathHelper().getDataNsDir(namespace)));
// assertFalse(fs.exists(FS, helper.getPathHelper().getMobDataNsDir(namespace)));
deleteTable(table);
}

@Test
Expand Down Expand Up @@ -700,6 +722,7 @@ public void testCleanArchiveTableDir() throws Exception {
SnapshotScannerHDFSAclCleaner.isArchiveDataDir(archiveTableDir.getParent().getParent()));
assertFalse(SnapshotScannerHDFSAclCleaner
.isArchiveDataDir(archiveTableDir.getParent().getParent().getParent()));
deleteTable(table);
}

@Test
Expand Down Expand Up @@ -761,6 +784,7 @@ public void testModifyTable1() throws Exception {
assertFalse(hasUserTableHdfsAcl(aclTable, user, table));
checkUserAclEntry(FS, helper.getTableRootPaths(table, false), user, false, false);
}
deleteTable(table);
}

@Test
Expand Down Expand Up @@ -824,6 +848,8 @@ public void testModifyTable2() throws Exception {
assertTrue(hasUserNamespaceHdfsAcl(aclTable, nsUserName, namespace));
assertTrue(hasUserNamespaceHdfsAcl(aclTable, tableUserName2, namespace));
assertFalse(hasUserTableHdfsAcl(aclTable, tableUserName, table));
deleteTable(table);
deleteTable(table2);
}

@Test
Expand Down Expand Up @@ -872,6 +898,8 @@ public void testRestartMaster() throws Exception {
aclTable = TEST_UTIL.getConnection().getTable(PermissionStorage.ACL_TABLE_NAME);
admin.snapshot(snapshot, table);
TestHDFSAclHelper.canUserScanSnapshot(TEST_UTIL, grantUser, snapshot, 6);
deleteTable(table);
deleteTable(table2);
}

static void checkUserAclEntry(FileSystem fs, List<Path> paths, String user,
Expand Down Expand Up @@ -901,4 +929,13 @@ static void checkUserAclEntry(FileSystem fs, Path path, String userName, boolean
assertEquals(message, requireAccessAcl, accessAclEntry);
assertEquals(message, requireDefaultAcl, defaultAclEntry);
}

static void deleteTable(TableName tableName) {
try {
admin.disableTable(tableName);
admin.deleteTable(tableName);
} catch (IOException e) {
LOG.warn("Failed to delete table: {}", tableName);
}
}
}

0 comments on commit 5f8dea5

Please sign in to comment.