NihalJain commented on code in PR #6931:
URL: https://github.com/apache/hbase/pull/6931#discussion_r2109658150


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestReadOnlyController.java:
##########
@@ -69,20 +80,39 @@ public class TestReadOnlyController {
   @BeforeClass
   public static void beforeClass() throws Exception {
     conf = TEST_UTIL.getConfiguration();
-    // Only try once so that if there is failure in connection then test 
should fail faster
-    conf.setInt("hbase.ipc.client.connect.max.retries", 1);
-    // Shorter session timeout is added so that in case failures test should 
not take more time
+
+    // Shorten the run time of failed unit tests by limiting retries and the 
session timeout
+    // threshold
+    conf.setInt(HBASE_CLIENT_RETRIES_NUMBER, 1);
     conf.setInt(HConstants.ZK_SESSION_TIMEOUT, 1000);
-    // Enable ReadOnly mode for the cluster
-    conf.setBoolean(HConstants.HBASE_GLOBAL_READONLY_ENABLED_KEY, true);
-    // Add the ReadOnlyController coprocessor for region server to interrupt 
any write operation
-    conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, 
ReadOnlyController.class.getName());
-    // Add the ReadOnlyController coprocessor to for master to interrupt any 
write operation
-    conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, 
ReadOnlyController.class.getName());
-    // Start the test cluster
-    TEST_UTIL.startMiniCluster(2);
-    // Get connection to the HBase
-    connection = ConnectionFactory.createConnection(conf);
+
+    // Set up test class with Read-Only mode disabled so a table can be created
+    conf.setBoolean(HConstants.HBASE_GLOBAL_READONLY_ENABLED_KEY, false);
+
+    // Add ReadOnlyController coprocessors to the master, region server, and 
regions
+    conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, 
READ_ONLY_CONTROLLER_NAME);
+    conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, 
READ_ONLY_CONTROLLER_NAME);
+    conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, 
READ_ONLY_CONTROLLER_NAME);
+
+    try {
+      // Start the test cluster
+      cluster = TEST_UTIL.startMiniCluster(1);
+
+      hMaster = cluster.getMaster();
+      hRegionServer = 
cluster.getRegionServerThreads().get(0).getRegionServer();
+      connection = ConnectionFactory.createConnection(conf);
+
+      // Create a test table
+      testTable = TEST_UTIL.createTable(TEST_TABLE, TEST_FAMILY);
+    } catch (Exception e) {
+      // Delete the created table, and clean up the connection and cluster 
before throwing an
+      // exception
+      disableReadOnlyMode();
+      TEST_UTIL.deleteTable(TEST_TABLE);
+      connection.close();
+      TEST_UTIL.shutdownMiniCluster();
+      throw new RuntimeException(e);

Review Comment:
   I hope this would not cause the whole test pipeline to fail?



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java:
##########
@@ -609,6 +609,12 @@ protected String getUseThisHostnameInstead(Configuration 
conf) {
   private void registerConfigurationObservers() {
     configurationManager.registerObserver(this.rpcServices);
     configurationManager.registerObserver(this);
+    if (cpHost != null) {

Review Comment:
   Do we not need to deregister in case of Master also?



-- 
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