From fa1c67fa5957e44ebc84f1a6ce81e138744a3011 Mon Sep 17 00:00:00 2001 From: Chris Dennis Date: Tue, 11 Feb 2025 14:02:32 -0500 Subject: [PATCH] [CALCITE-6799] ConnectionPropertiesHATest flakey on MacOS Account for all known connection failure messages. The three failure messages here were sourced from ~100k local runs of this test on macOS. --- .../calcite/avatica/ha/ConnectionPropertiesHATest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/test/java/org/apache/calcite/avatica/ha/ConnectionPropertiesHATest.java b/server/src/test/java/org/apache/calcite/avatica/ha/ConnectionPropertiesHATest.java index ff81f67dc9..1db9bc772a 100644 --- a/server/src/test/java/org/apache/calcite/avatica/ha/ConnectionPropertiesHATest.java +++ b/server/src/test/java/org/apache/calcite/avatica/ha/ConnectionPropertiesHATest.java @@ -52,6 +52,9 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.either; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -317,9 +320,10 @@ public void testConnectionPropertiesCreateStatementAfterDisconnect() throws Exce stmt.execute("SELECT count(1) FROM " + tableName); } catch (Exception e) { assertTrue(e instanceof SQLException); - assertTrue( - e.getMessage().toLowerCase(Locale.ROOT).contains("connection refused") - || e.getMessage().toLowerCase(Locale.ROOT).contains("connection abort")); + assertThat(e.getMessage().toLowerCase(Locale.ROOT), either( + containsString("connection refused")) + .or(containsString("connection abort")) + .or(containsString("connection reset"))); } // Create statement with conn - Fails with HttpHostConnectException.