taklwu commented on code in PR #7474:
URL: https://github.com/apache/hbase/pull/7474#discussion_r2612162163


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java:
##########
@@ -225,4 +228,70 @@ public void testClusterMetricsMetaTableSkipping() throws 
Exception {
       master.getTableDescriptors().remove(replicaMetaTable);
     }
   }
+
+  @Test
+  public void testClusterMetricsForeignTableSkipping() throws Exception {
+    List<TableName> allTables = new ArrayList<>();
+
+    // These tables, including the cluster's meta table, should not be foreign 
to the cluster.
+    // The cluster should be able to find their state.
+    allTables.add(TableName.META_TABLE_NAME);
+    List<TableName> familiarTables = new ArrayList<>();
+    familiarTables.add(TableName.valueOf(null, "familiarTable1"));
+    familiarTables.add(TableName.valueOf("", "familiarTable2"));
+    familiarTables.add(TableName.valueOf("default", "familiarTable3"));
+    familiarTables.add(TableName.valueOf("familiarNamespace", 
"familiarTable4"));
+    familiarTables.add(TableName.valueOf("familiarNamespace", 
"familiarTable5"));
+
+    // Create these "familiar" tables so their state can be found
+    
TEST_UTIL.getAdmin().createNamespace(NamespaceDescriptor.create("familiarNamespace").build());
+    for (TableName familiarTable : familiarTables) {
+      TEST_UTIL.createTable(familiarTable, "cf");
+      allTables.add(familiarTable);
+    }
+
+    // These tables should be foreign to the cluster.
+    // The cluster should not be able to find their state.
+    allTables.add(TableName.valueOf("hbase", "meta_replica"));
+    allTables.add(TableName.valueOf(null, "defaultNamespaceTable1"));
+    allTables.add(TableName.valueOf("", "defaultNamespaceTable2"));
+    allTables.add(TableName.valueOf("default", "defaultNamespaceTable3"));
+    allTables.add(TableName.valueOf("customNamespace", 
"customNamespaceTable1"));
+    allTables.add(TableName.valueOf("customNamespace", 
"customNamespaceTable2"));
+    allTables.add(TableName.valueOf("anotherNamespace", 
"anotherNamespaceTable"));
+    allTables.add(TableName.valueOf("sharedNamespace", 
"sharedNamespaceTable1"));
+    allTables.add(TableName.valueOf("sharedNamespace", 
"sharedNamespaceTable2"));
+
+    // Update master's table descriptors to have all tables
+    TableDescriptor foreignTableDescriptor;
+    for (TableName tableName : allTables) {
+      foreignTableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
+        .setColumnFamily(ColumnFamilyDescriptorBuilder.of("cf")).build();
+      master.getTableDescriptors().update(foreignTableDescriptor, true);
+    }

Review Comment:
   so, I use debug mode to check the unit test, I found that 
`listTableDescriptors` is always using the `cache` of `FSTableDescriptors` 
instead of loading from the filesystem, such that we're relying on the 
`tableStateManager` via meta to see if the additional loaded tables should be 
included. 
   
   
   the test itself is right, just I'm wondered practically how newly added 
table on the primary/write cluster being added to the `cache` of 
`FSTableDescriptors` after master has been initialized ? or does it add from 
the filesystem after restarting the master (meta is yet synced)? 
   
   so, please consider to test it manually and see if that's what you expected 
in [HBASE-29579](https://issues.apache.org/jira/browse/HBASE-29579)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to