Skip to content

chore(bigquery-jdbc): update integration tests to handle different cancellation#13541

Open
logachev wants to merge 2 commits into
mainfrom
kirl/test_cancellation_errors
Open

chore(bigquery-jdbc): update integration tests to handle different cancellation#13541
logachev wants to merge 2 commits into
mainfrom
kirl/test_cancellation_errors

Conversation

@logachev

Copy link
Copy Markdown
Contributor

Due to 64cde7f now jobs.query API is used even if we request job creation (Previously it falls back to jobs.insert). Due to this, updating integration test with new error/timeout values.

@logachev logachev requested review from a team as code owners June 23, 2026 01:03

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates integration tests for the BigQuery JDBC driver. In ITNightlyBigQueryTest, the sleep duration before cancellation is increased to 15 seconds to ensure the job is in the appropriate state, and a debug print statement is added. In ITStatementTest, the expected exception message for a timed-out query is updated. Feedback suggests removing the leftover System.out.println debugging statement and refactoring the try-catch block in ITStatementTest to use assertThrows to ensure the test fails if no exception is thrown.

Comment on lines 334 to 338
try {
statement.executeQuery(selectQuery);
} catch (SQLException e) {
assertTrue(true);
assertEquals("SQL execution canceled", e.getMessage());
assertEquals("BigQueryException during runQuery\nJob execution was cancelled: Job timed out", e.getMessage());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using a try-catch block without an explicit fail statement means that if statement.executeQuery(selectQuery) unexpectedly succeeds without throwing an exception, the test will pass silently. Using assertThrows is a safer and more idiomatic way to assert that an exception is thrown.

    SQLException e =
        assertThrows(SQLException.class, () -> statement.executeQuery(selectQuery));
    assertEquals("BigQueryException during runQuery\nJob execution was cancelled: Job timed out", e.getMessage());

Comment on lines +230 to 231
System.out.println(e.getMessage());
assertTrue(e.getMessage().contains("User requested cancellation"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The System.out.println statement appears to be a leftover debugging aid. It should be removed to keep the test output clean.

Suggested change
System.out.println(e.getMessage());
assertTrue(e.getMessage().contains("User requested cancellation"));
assertTrue(e.getMessage().contains("User requested cancellation"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant