This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch 5.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.3 by this push:
     new 0e1fb732db PHOENIX-7980 Improve handling of test timeouts and resource 
loss (#2593)
0e1fb732db is described below

commit 0e1fb732dbfca700f07e472a0ce4bd0c781c131c
Author: Andrew Purtell <[email protected]>
AuthorDate: Tue Aug 4 17:23:46 2026 -0700

    PHOENIX-7980 Improve handling of test timeouts and resource loss (#2593)
---
 .../java/org/apache/phoenix/query/BaseTest.java    | 23 ++++++++++++++++++++++
 pom.xml                                            |  3 +++
 2 files changed, 26 insertions(+)

diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
index e2e3afedef..41208464f6 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
@@ -169,6 +169,7 @@ import org.apache.phoenix.util.ServerUtil.ConnectionFactory;
 import org.apache.phoenix.util.TestUtil;
 import org.junit.ClassRule;
 import org.junit.rules.TemporaryFolder;
+import org.junit.rules.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -198,6 +199,9 @@ public abstract class BaseTest {
   private static final Logger LOGGER = LoggerFactory.getLogger(BaseTest.class);
   @ClassRule
   public static TemporaryFolder tmpFolder = new TemporaryFolder();
+  @ClassRule
+  public static Timeout CLASS_TIMEOUT =
+    Timeout.builder().withTimeout(20, 
TimeUnit.MINUTES).withLookingForStuckThread(true).build();
   private static final int dropTableTimeout = 120; // 2 mins should be long 
enough.
   private static final ThreadFactory factory = new 
ThreadFactoryBuilder().setDaemon(true)
     .setNameFormat("DROP-TABLE-BASETEST" + "-thread-%s").build();
@@ -446,12 +450,31 @@ public abstract class BaseTest {
 
   protected static synchronized void setUpTestDriver(ReadOnlyProps serverProps,
     ReadOnlyProps clientProps) throws Exception {
+    assertSharedMiniClusterHealthy();
     if (driver == null) {
       String url = checkClusterInitialized(serverProps);
       driver = initAndRegisterTestDriver(url, clientProps);
     }
   }
 
+  private static void assertSharedMiniClusterHealthy() {
+    if (
+      !clusterInitialized || utility == null
+        || isDistributedClusterModeEnabled(utility.getConfiguration())
+    ) {
+      return;
+    }
+    MiniHBaseCluster cluster = utility.getHBaseCluster();
+    HMaster master = cluster == null ? null : cluster.getMaster();
+    if (
+      master == null || !master.isActiveMaster() || !master.isInitialized() || 
master.isAborted()
+        || master.isStopped()
+    ) {
+      throw new IllegalStateException("Shared in-JVM minicluster is unhealthy 
(master not up); "
+        + "failing fast so subsequent tests on this fork do not hang.");
+    }
+  }
+
   private static boolean isDistributedClusterModeEnabled(Configuration conf) {
     boolean isDistributedCluster = false;
     // check if the distributed mode was specified as a system property.
diff --git a/pom.xml b/pom.xml
index a43a3b6ac3..0819539409 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1636,6 +1636,7 @@
               </goals>
               <configuration>
                 <reuseForks>false</reuseForks>
+                
<forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
                 <skip>${skipNeedsOwnMiniClusterTests}</skip>
                 
<groups>org.apache.phoenix.end2end.NeedsOwnMiniClusterTest</groups>
               </configuration>
@@ -1868,6 +1869,8 @@
           <forkCount>${numForkedUT}</forkCount>
           <reuseForks>true</reuseForks>
           
<redirectTestOutputToFile>${test.output.tofile}</redirectTestOutputToFile>
+          <forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
+          
<forkedProcessExitTimeoutInSeconds>180</forkedProcessExitTimeoutInSeconds>
           <shutdown>exit</shutdown>
           <trimStackTrace>false</trimStackTrace>
           <forkNode 
implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>

Reply via email to