InvisibleProgrammer commented on code in PR #6412:
URL: https://github.com/apache/hive/pull/6412#discussion_r3149921550


##########
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java:
##########
@@ -128,9 +129,46 @@ public class TestJdbcDriver2 {
   private static Connection con;
   private static final float floatCompareDelta = 0.0001f;
 
+  /**
+   * Required prefix of {@link SQLTimeoutException#getMessage()} for a 1s 
limit. HS2 may append
+   * {@code ; Query ID: ...} after the base text from {@code HiveSQLException}.
+   */
+  private static final String QUERY_TIMED_OUT_AFTER_1_SECONDS = "Query timed 
out after 1 seconds";
+
   @Rule public ExpectedException thrown = ExpectedException.none();
   @Rule public final TestName testName = new TestName();
 
+  /**
+   * {@code SET hive.query.timeout.seconds} applies to the whole HS2 session. 
Tests such as
+   * {@link #testQueryTimeoutMessageUsesHiveConf()} must not leave a short 
limit on the shared
+   * {@link #con}, or unrelated tests will see {@link SQLTimeoutException}.
+   */
+  @After
+  public void resetHiveSessionQueryTimeout() {
+    try {
+      if (con == null || con.isClosed()) {
+        return;
+      }
+      try (Statement st = con.createStatement()) {
+        st.execute("set hive.query.timeout.seconds=0s");
+      }
+    } catch (SQLException e) {
+      LOG.warn("Could not reset hive.query.timeout.seconds after {}", 
testName.getMethodName(), e);
+    }
+  }
+
+  private static void assertTimeoutMessageShowsOneSecond(String context, 
SQLTimeoutException e) {
+    String msg = e.getMessage();
+    assertNotNull(context + ": message should not be null", msg);
+    assertTrue(
+        context + ": should start with " + QUERY_TIMED_OUT_AFTER_1_SECONDS
+            + " (HS2 may append ; Query ID: ...); actual=" + msg,
+        msg.startsWith(QUERY_TIMED_OUT_AFTER_1_SECONDS));
+    assertFalse(

Review Comment:
   What is the intent of this assert? If the message contains after 0 seconds, 
the previous assertion will fail. Otherwise, we have a new problem, like 
duplicated output. But this test case is not about testing that one. 



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to