Skip to content

Commit

Permalink
SNOW-1553640: Fix flaky test StatementArrowIT.testTelemetryBatch (#1842)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dprzybysz authored Jul 25, 2024
1 parent 7a26c1d commit 0993c6b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/test/java/net/snowflake/client/jdbc/StatementIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
package net.snowflake.client.jdbc;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
Expand All @@ -20,6 +21,7 @@
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.Statement;
import java.time.Duration;
import java.util.List;
import net.snowflake.client.AbstractDriverIT;
import net.snowflake.client.ConditionalIgnoreRule;
Expand All @@ -28,6 +30,7 @@
import net.snowflake.client.jdbc.telemetry.Telemetry;
import net.snowflake.client.jdbc.telemetry.TelemetryClient;
import net.snowflake.common.core.SqlState;
import org.awaitility.Awaitility;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -513,13 +516,11 @@ public void testTelemetryBatch() throws SQLException {
// there should be logs ready to be sent
assertTrue(((TelemetryClient) telemetryClient).bufferSize() > 0);
}
// closing the statement should flush the buffer, however, flush is async,
// sleep some time before check buffer size
try {
Thread.sleep(1000);
} catch (Throwable e) {
}
assertEquals(((TelemetryClient) telemetryClient).bufferSize(), 0);

Telemetry finalTelemetryClient = telemetryClient;
Awaitility.await()
.atMost(Duration.ofSeconds(10))
.until(() -> ((TelemetryClient) finalTelemetryClient).bufferSize(), equalTo(0));
}

@Test
Expand Down

0 comments on commit 0993c6b

Please sign in to comment.