You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/08/22 13:54:05 UTC

[GitHub] [hbase] infraio commented on a change in pull request #2286: HBASE-24913 Refactor TestJMXConnectorServer

infraio commented on a change in pull request #2286:
URL: https://github.com/apache/hbase/pull/2286#discussion_r475093446



##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXConnectorServer.java
##########
@@ -56,39 +58,47 @@
   private static Configuration conf = null;
   private static Admin admin;
   // RMI registry port
-  private static int rmiRegistryPort = 61120;
+  private static int rmiRegistryPort;
   // Switch for customized Accesscontroller to throw ACD exception while executing test case
-  static boolean hasAccess;
+  private volatile static boolean hasAccess;
 
-  @Before
-  public void setUp() throws Exception {
-    UTIL = new HBaseTestingUtility();
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
     conf = UTIL.getConfiguration();
+    String cps = JMXListener.class.getName() + "," + MyAccessController.class.getName();
+    conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, cps);
+    conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, cps);
+    rmiRegistryPort = UTIL.randomFreePort();
+    conf.setInt("master.rmi.registry.port", rmiRegistryPort);
+    conf.setInt("regionserver.rmi.registry.port", rmiRegistryPort);
+    UTIL.startMiniCluster();
+    admin = UTIL.getConnection().getAdmin();
   }
 
-  @After
-  public void tearDown() throws Exception {
-    // Set to true while stopping cluster
-    hasAccess = true;
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
     admin.close();
     UTIL.shutdownMiniCluster();
   }
 
+  @Before
+  public void setUp() {
+    hasAccess = false;

Review comment:
       Seems only the first call will throw AccessDeny exception. Did you know why this design?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org