5858import  org .apache .hadoop .hbase .testclassification .MediumTests ;
5959import  org .apache .hadoop .hbase .util .Bytes ;
6060import  org .apache .hadoop .hbase .util .EnvironmentEdgeManager ;
61+ import  org .apache .hadoop .hbase .util .FSTableDescriptors ;
6162import  org .apache .hadoop .hbase .util .MockServer ;
6263import  org .apache .hadoop .hbase .zookeeper .ZKWatcher ;
6364import  org .junit .AfterClass ;
@@ -124,6 +125,8 @@ public void beforeTest() throws Exception {
124125    fs .mkdirs (OLD_WALS_DIR );
125126
126127    TableName  tableName  = tableNameRule .getTableName ();
128+     conf .set (ReplicationStorageFactory .REPLICATION_QUEUE_TABLE_NAME , tableName .getNameAsString ());
129+ 
127130    TableDescriptor  td  = ReplicationStorageFactory .createReplicationQueueTableDescriptor (tableName );
128131    TEST_UTIL .getAdmin ().createTable (td );
129132    TEST_UTIL .waitTableAvailable (tableName );
@@ -134,6 +137,7 @@ public void beforeTest() throws Exception {
134137    when (masterServices .getConnection ()).thenReturn (TEST_UTIL .getConnection ());
135138    ReplicationPeerManager  rpm  = mock (ReplicationPeerManager .class );
136139    when (masterServices .getReplicationPeerManager ()).thenReturn (rpm );
140+     when (masterServices .getTableDescriptors ()).thenReturn (new  FSTableDescriptorsTest (conf ));
137141    when (rpm .getQueueStorage ()).thenReturn (queueStorage );
138142    when (rpm .getReplicationLogCleanerBarrier ()).thenReturn (new  ReplicationLogCleanerBarrier ());
139143    when (rpm .listPeers (null )).thenReturn (new  ArrayList <>());
@@ -314,4 +318,24 @@ public ZKWatcher getZooKeeper() {
314318      return  null ;
315319    }
316320  }
321+ 
322+   private  static  class  FSTableDescriptorsTest  extends  FSTableDescriptors  {
323+     private  TableName  replicationQueueTableName ;
324+ 
325+     public  FSTableDescriptorsTest (final  Configuration  conf ) throws  IOException  {
326+       super (conf );
327+       replicationQueueTableName  =
328+         TableName .valueOf (conf .get (ReplicationStorageFactory .REPLICATION_QUEUE_TABLE_NAME ,
329+           ReplicationStorageFactory .REPLICATION_QUEUE_TABLE_NAME_DEFAULT .getNameAsString ()));
330+     }
331+ 
332+     @ Override 
333+     public  boolean  exists (TableName  tablename ) throws  IOException  {
334+       if  (tablename .equals (replicationQueueTableName )) {
335+         return  true ;
336+       } else  {
337+         return  super .exists (tablename );
338+       }
339+     }
340+   }
317341}
0 commit comments