You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "Divneet18 (via GitHub)" <gi...@apache.org> on 2026/06/09 21:57:20 UTC

[PR] [WIP]PHOENIX-7623: Add a profile which runs ITs with phoenix ha client [phoenix]

Divneet18 opened a new pull request, #2508:
URL: https://github.com/apache/phoenix/pull/2508

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://phoenix.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR.
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP] PHOENIX-XXXX Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes, and prefix it with the JIRA id, e.g. 'PHOENIX-XXXX Your PR title ...'.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
   
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Phoenix versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   


-- 
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-unsubscribe@phoenix.apache.org

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


Re: [PR] [WIP] PHOENIX-7623: Add a profile which runs ITs with phoenix ha client [phoenix]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2508:
URL: https://github.com/apache/phoenix/pull/2508#discussion_r3789338053


##########
phoenix-core-client/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java:
##########
@@ -58,7 +58,7 @@ public ReadOnlyProps(Iterator<Entry<String, String>> iterator) {
     this(EMPTY_PROPS, iterator);
   }
 
-  private ReadOnlyProps() {
+  public ReadOnlyProps() {

Review Comment:
   This exposes a new production API solely for the test utility, although `ReadOnlyProps.EMPTY_PROPS` already represents the same immutable empty value. Use that constant in `HBaseTestingUtilityPair` and keep this constructor private to avoid an unnecessary public API change.



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/CbrtFunctionEnd2EndIT.java:
##########
@@ -48,7 +50,8 @@ public void initTable() throws Exception {
     Connection conn = null;
     PreparedStatement stmt = null;
     try {
-      conn = DriverManager.getConnection(getUrl());
+      System.out.println("get url " + getUrl());
+      conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));

Review Comment:
   This unconditional console print is leftover diagnostic output and calls `getUrl()` a second time for every setup. Remove it and let the configured test logging capture any needed URL diagnostics.



##########
phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java:
##########
@@ -381,6 +411,48 @@ protected static String setUpTestCluster(@Nonnull Configuration conf, ReadOnlyPr
     }
   }
 
+  /**
+   * Set up HA cluster for testing in single-cluster mode.
+   * This mode tests HA connection code paths (FailoverPhoenixConnection) without the
+   * resource overhead of running two physical HBase clusters.
+   * Both ACTIVE and STANDBY URLs point to the same physical cluster.
+   */
+  public static void setUpTestClusterForHA(ReadOnlyProps serverProps, ReadOnlyProps clientProps)
+    throws Exception {
+    CLUSTERS = new HighAvailabilityTestingUtility.HBaseTestingUtilityPair(serverProps);
+    CLUSTERS.start(true);  // true = single-cluster mode (only starts cluster1)
+    driver = newTestDriver(clientProps);
+    DriverManager.registerDriver(driver);
+    haGroupName = TEST_PROPERTIES.getProperty(PHOENIX_HA_GROUP_ATTR);
+    // Use single-cluster initialization (only cluster1 is running)
+    CLUSTERS.initClusterRoleRecordFor1Cluster(haGroupName, HighAvailabilityPolicy.FAILOVER);
+    clusterInitialized = true;
+    Properties haGroupProps = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    for (Entry<String, String> entry : clientProps) {
+      haGroupProps.setProperty(entry.getKey(), entry.getValue());
+    }
+    haGroup = getHighAvailibilityGroup(CLUSTERS.getJdbcHAUrl(), haGroupProps);
+    LOGGER.info("Initialized HA group {} with URL {}", haGroup, CLUSTERS.getJdbcHAUrl());
+  }
+
+  /**
+   * Tear down HA cluster resources.
+   * Should be called in @AfterClass when using HA mode.
+   */
+  public static void tearDownForHA() throws Exception {
+    if (Boolean.parseBoolean(System.getProperty("phoenix.ha.profile.active"))) {
+      try {
+        DriverManager.deregisterDriver(PhoenixDriver.INSTANCE);

Review Comment:
   This deregisters the production `PhoenixDriver` but leaves the `PhoenixTestDriver` registered by `setUpTestClusterForHA`. The `ParallelStatsDisabledTest` execution reuses forks, so after the first subclass tears down, the next subclass initializes its role record through non-test JDBC URLs with no production driver registered, while stale test drivers accumulate. Keep the production driver available for the reused fork and explicitly close/deregister `driver` (and reset the shared HA state), or move HA setup/teardown to a fork-scoped lifecycle.



##########
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java:
##########
@@ -763,7 +763,7 @@ public ClusterRoleRecord getRoleRecord() {
    * lifecycle management is confined to this class because an HA group is a shared resource.
    * Someone calling close on this would make it unusable, since the state would become closed.
    */
-  void close() {
+  public void close() {

Review Comment:
   Making this method public contradicts its own lifecycle contract: instances are shared through the static `GROUPS` cache, so any application caller can now close the cached group and break unrelated connections. This is also unnecessary for the test change because `HighAvailabilityTestingUtility.closeHighAvailabilityGroup` already provides a test-only bridge. Keep `close()` package-private and use that helper from `BaseTest`.



##########
phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java:
##########
@@ -148,8 +149,14 @@
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.hbase.index.util.IndexManagementUtil;
+import org.apache.phoenix.jdbc.HighAvailabilityGroup;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.HighAvailabilityTestingUtility;
+import static org.apache.phoenix.jdbc.HighAvailabilityTestingUtility.getHighAvailibilityGroup;

Review Comment:
   Static imports are consistently grouped at the top of this file (for example, lines 26–30), but this new static import is interleaved with regular imports. Move it into the static-import block; otherwise the formatting/import-order check will reject the file.



##########
phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java:
##########
@@ -148,8 +149,14 @@
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.hbase.index.util.IndexManagementUtil;
+import org.apache.phoenix.jdbc.HighAvailabilityGroup;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.HighAvailabilityTestingUtility;
+import static org.apache.phoenix.jdbc.HighAvailabilityTestingUtility.getHighAvailibilityGroup;
 import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixMonitoredConnection;

Review Comment:
   `PhoenixMonitoredConnection` is not referenced anywhere in this file. Remove the unused import so the source passes the repository's import checks.



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java:
##########
@@ -53,12 +53,25 @@ public static synchronized void doSetup() throws Exception {
     props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY,
       Integer.toString(60 * 60)); // An hour
     props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false));
-    setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+
+    // Check if HA profile is enabled
+    if (Boolean.parseBoolean(System.getProperty("phoenix.ha.profile.active"))) {
+      // Set up HA cluster in single-cluster mode
+      setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),
+        new ReadOnlyProps(props.entrySet().iterator()));

Review Comment:
   Putting the HA setup in this shared base switches every `ParallelStatsDisabledIT` subclass to an HA URL, but only `CbrtFunctionEnd2EndIT` was converted to pass `TEST_PROPERTIES`. Existing subclasses such as `ArrayAppendFunctionIT` (lines 74 and 138) still call `DriverManager.getConnection(getUrl())`; an HA URL requires `phoenix.ha.group.name`, so a full `-Pha-enabled` run fails with invalid HA properties. Either scope this setup to the proof-of-concept test or update the shared connection mechanism/all affected tests to supply the HA properties.



-- 
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-unsubscribe@phoenix.apache.org

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