Divneet18 commented on code in PR #2205: URL: https://github.com/apache/phoenix/pull/2205#discussion_r2223736435
########## phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java: ########## @@ -425,20 +434,58 @@ public abstract class BaseTest { protected static String getZKClientPort(Configuration conf) { return conf.get(QueryServices.ZOOKEEPER_PORT_ATTRIB); } - + private static String haGroupName; + private static HighAvailabilityGroup haGroup; protected static String url; protected static PhoenixTestDriver driver; protected static boolean clusterInitialized = false; protected static HBaseTestingUtility utility; protected static final Configuration config = HBaseConfiguration.create(); + protected static HighAvailabilityTestingUtility.HBaseTestingUtilityPair CLUSTERS; + private static final Logger LOG = LoggerFactory.getLogger(BaseTest.class); + @AfterClass + public static void tearDownForHA() throws Exception { + if(Boolean.parseBoolean(System.getProperty("phoenix.ha.profile.active"))){ + try { + DriverManager.deregisterDriver(PhoenixDriver.INSTANCE); + CLUSTERS.close(); + haGroup.close(); + driver.getConnectionQueryServices(CLUSTERS.getJdbcUrl1(haGroup), haGroup.getProperties()) + .close(); + driver.getConnectionQueryServices(CLUSTERS.getJdbcUrl2(haGroup), haGroup.getProperties()) + .close(); + } catch (Exception e) { + LOG.error("Fail to tear down the HA group and the CQS. Will ignore", e); + } + } + } protected static String getUrl() { if (!clusterInitialized) { throw new IllegalStateException("Cluster must be initialized before attempting to get the URL"); } + if(Boolean.parseBoolean(System.getProperty("phoenix.ha.profile.active"))){ + url = CLUSTERS.getJdbcHAUrlWithoutPrincipal()+";"+PHOENIX_TEST_DRIVER_URL_PARAM; + } return url; } + protected static String getActiveUrl() { + if (!clusterInitialized) { + throw new IllegalStateException("Cluster must be initialized before attempting to get the URL"); + } + Optional<String> url; + if(Boolean.parseBoolean(System.getProperty("phoenix.ha.profile.active"))){ + url = haGroup.getRoleRecord().getActiveUrl(); + if (url.isPresent()) { + return url.get() + ";" + PHOENIX_TEST_DRIVER_URL_PARAM; + } else { Review Comment: remove else block -- 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: issues-unsubscr...@phoenix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org