Skip to content

Commit

Permalink
[CALCITE-6855] Report elapsed time in ConnectionPropertiesHATest assert
Browse files Browse the repository at this point in the history
  • Loading branch information
stoty committed Feb 25, 2025
1 parent c8e57f2 commit a72c4d4
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
Expand Down Expand Up @@ -265,9 +267,19 @@ public void testConnectionPropertiesHAHttpConnectionTimeout5Sec() throws Excepti
} catch (RuntimeException re) {
long endTime = System.currentTimeMillis();
long elapsedTime = endTime - startTime;
Assert.assertTrue(elapsedTime < Timeout.ofMinutes(3).toMilliseconds());
Assert.assertTrue(elapsedTime >= 5000);
Assert.assertTrue(re.getCause() instanceof ConnectTimeoutException);
String stackTrace = "";
try (StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw)) {
re.printStackTrace(pw);
stackTrace = sw.toString();
}
Assert.assertTrue(
"Expected RuntimeException with ConnectTimeoutException cause, got:\n" + stackTrace,
re.getCause() instanceof ConnectTimeoutException);
Assert.assertTrue("Elapsed time: " + elapsedTime + " ms, expected less than 3 minutes",
elapsedTime < Timeout.ofMinutes(3).toMilliseconds());
Assert.assertTrue("Elapsed time: " + elapsedTime + " ms, expected at least 5000 ms",
elapsedTime >= 5000);
}
}

Expand Down

0 comments on commit a72c4d4

Please sign in to comment.