58
58
import org .apache .hadoop .hbase .testclassification .LargeTests ;
59
59
import org .apache .hadoop .hbase .testclassification .SecurityTests ;
60
60
import org .apache .hadoop .hbase .util .Bytes ;
61
+ import org .apache .hadoop .hbase .util .FSUtils ;
61
62
import org .apache .hadoop .hbase .util .HFileArchiveUtil ;
62
63
import org .junit .AfterClass ;
63
64
import org .junit .BeforeClass ;
@@ -883,9 +884,24 @@ public void testRestartMaster() throws Exception {
883
884
User grantUser = User .createUserForTesting (conf , grantUserName , new String [] {});
884
885
String namespace = name .getMethodName ();
885
886
TableName table = TableName .valueOf (namespace , "t1" );
887
+ TableName table2 = TableName .valueOf (namespace , "t2" );
886
888
String snapshot = namespace + "t1" ;
887
889
admin .createNamespace (NamespaceDescriptor .create (namespace ).build ());
888
890
891
+ // create table2
892
+ TestHDFSAclHelper .createTableAndPut (TEST_UTIL , table2 );
893
+ // make some region files in tmp dir and check if master archive these region correctly
894
+ Path tmpTableDir = helper .getPathHelper ().getTmpTableDir (table2 );
895
+ // make a empty region dir, this is an error region
896
+ fs .mkdirs (new Path (tmpTableDir , "1" ));
897
+ // copy regions from data dir, this is a valid region
898
+ for (Path regionDir : FSUtils .getRegionDirs (fs ,
899
+ helper .getPathHelper ().getDataTableDir (table2 ))) {
900
+ FSUtils .copyFilesParallel (fs , regionDir , fs ,
901
+ new Path (tmpTableDir , regionDir .getName () + "abc" ), conf , 1 );
902
+ }
903
+ assertEquals (4 , fs .listStatus (tmpTableDir ).length );
904
+
889
905
// grant N(R)
890
906
SecureTestUtil .grantOnNamespace (TEST_UTIL , grantUserName , namespace , READ );
891
907
// restart cluster and tmp directory will not be deleted
@@ -894,15 +910,16 @@ public void testRestartMaster() throws Exception {
894
910
TEST_UTIL .waitUntilNoRegionsInTransition ();
895
911
896
912
Path tmpNsDir = helper .getPathHelper ().getTmpNsDir (namespace );
897
- assertFalse (fs .exists (tmpNsDir ));
913
+ assertTrue (fs .exists (tmpNsDir ));
914
+ // check all regions in tmp table2 dir are archived
915
+ assertEquals (0 , fs .listStatus (tmpTableDir ).length );
898
916
899
- // create table2 and snapshot
917
+ // create table1 and snapshot
900
918
TestHDFSAclHelper .createTableAndPut (TEST_UTIL , table );
901
919
admin = TEST_UTIL .getAdmin ();
902
920
aclTable = TEST_UTIL .getConnection ().getTable (PermissionStorage .ACL_TABLE_NAME );
903
921
admin .snapshot (snapshot , table );
904
- // TODO fix it in another patch
905
- TestHDFSAclHelper .canUserScanSnapshot (TEST_UTIL , grantUser , snapshot , -1 );
922
+ TestHDFSAclHelper .canUserScanSnapshot (TEST_UTIL , grantUser , snapshot , 6 );
906
923
}
907
924
908
925
private void checkUserAclEntry (List <Path > paths , String user , boolean requireAccessAcl ,
0 commit comments