Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import java.util.Properties;
import java.util.Random;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -3073,7 +3074,7 @@ public void testPerConnectionLoggingE2E() throws SQLException, IOException {
}

@Test
public void testSessionAbortedOnConnectionClose() throws SQLException {
public void testSessionAbortedOnConnectionClose() throws SQLException, InterruptedException {
String sessionId;
try (Connection connection = DriverManager.getConnection(session_enabled_connection_uri)) {
try (Statement statement = connection.createStatement()) {
Expand All @@ -3087,15 +3088,25 @@ public void testSessionAbortedOnConnectionClose() throws SQLException {

// After connection is closed, the session is aborted on the BigQuery server.
// Attaching to the same session_id in a new connection should fail when running a query.
// CI has observed the first query after close() still succeeding on the session, so poll with
// a deadline. The test still fails if the session remains usable for the whole deadline.
String urlWithAbortedSession =
connection_uri + "EnableSession=1;QueryProperties=session_id=" + sessionId + ";";
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(60);
boolean sessionUnusable = false;
try (Connection newConnection = DriverManager.getConnection(urlWithAbortedSession)) {
try (Statement statement = newConnection.createStatement()) {
SQLException ex =
assertThrows(
SQLException.class, () -> statement.execute("SELECT * FROM session_temp_table;"));
while (!sessionUnusable && System.nanoTime() < deadline) {
try (Statement statement = newConnection.createStatement()) {
statement.execute("SELECT * FROM session_temp_table;");
} catch (SQLException expected) {
sessionUnusable = true;
}
if (!sessionUnusable) {
Thread.sleep(2000);
}
}
Comment thread
keshavdandeva marked this conversation as resolved.
}
assertTrue(sessionUnusable, "Session " + sessionId + " was still usable 60s after close()");
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ public void testMetadataResultSetsDoNotInterfere() throws SQLException {
}

@Test
@Tag("advanced") // Asserts this driver returns only the connection's project as a catalog.
public void testDatabaseMetadataGetCatalogs() throws SQLException {

Connection connection = DriverManager.getConnection(ITBase.connectionUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ public void testDatabaseMetaData_getColumns_picosEnabled() throws SQLException {
*/
@ParameterizedTest(name = "JVM zone {0}")
@MethodSource("jvmZones")
@Tag("advanced") // Relies on this driver's TIMESTAMP parameter conversion.
public void testPreparedStatement_insertRoundTrip_backendTruncatesToMicroseconds(String zone)
throws SQLException {
useJvmZone(zone);
Expand Down Expand Up @@ -505,6 +506,7 @@ public void testPreparedStatement_insertRoundTrip_backendTruncatesToMicroseconds
*/
@ParameterizedTest(name = "JVM zone {0}, arrow={1}")
@MethodSource("jvmZonesAndReadPaths")
@Tag("advanced") // Relies on this driver's TIMESTAMP parameter conversion.
public void testPreparedStatement_batchInsertRoundTrip(String zone, boolean arrow)
throws SQLException {
useJvmZone(zone);
Expand Down
Loading