Skip to content

Commit fa81a5e

Browse files
authored
chore(bigquery-jdbc): update integration tests to handle different cancellation (#13541)
1 parent 2c7e5f5 commit fa81a5e

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ public void testQueryInterruptGracefullyStopsExplicitJob()
232232
});
233233
t.start();
234234
// Allow thread to actually initiate the query
235-
Thread.sleep(3000);
235+
// Even when job is created, we might be using `query` API which means if we cancle within first
236+
// 10 seconds,
237+
// it is similar to Optional job cancellation. Need to wait until after we're in "Wait for job
238+
// completion" mode.
239+
Thread.sleep(15000);
236240
bigQueryStatement.cancel();
237241
// Wait until background thread is finished
238242
t.join();

java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,10 @@ public void testSetTimeout() throws SQLException {
331331
assertEquals(0, statement.getQueryTimeout());
332332
statement.setQueryTimeout(1);
333333
assertEquals(1, statement.getQueryTimeout());
334-
try {
335-
statement.executeQuery(selectQuery);
336-
} catch (SQLException e) {
337-
assertTrue(true);
338-
assertEquals("SQL execution canceled", e.getMessage());
339-
}
334+
SQLException e = assertThrows(SQLException.class, () -> statement.executeQuery(selectQuery));
335+
assertEquals(
336+
"BigQueryException during runQuery\nJob execution was cancelled: Job timed out",
337+
e.getMessage());
340338
statement.close();
341339
connection.close();
342340
}

0 commit comments

Comments
 (0)