Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -33,6 +33,11 @@

public class ITBase extends BigQueryJdbcBaseTest {

// This query takes 300 seconds to complete
protected final String query300seconds =
"DECLARE DELAY_TIME DATETIME; SET DELAY_TIME = DATETIME_ADD(CURRENT_DATETIME, INTERVAL 300"
+ " SECOND); WHILE CURRENT_DATETIME < DELAY_TIME DO END WHILE;";
Comment thread
logachev marked this conversation as resolved.

private static String sharedDataset;
private static String sharedDataset2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

public class ITNightlyBigQueryTest {
public class ITNightlyBigQueryTest extends ITBase {
Comment thread
logachev marked this conversation as resolved.
static final String PROJECT_ID = ServiceOptions.getDefaultProjectId();
static Connection bigQueryConnection;
static Statement bigQueryStatement;
Expand Down Expand Up @@ -215,18 +215,13 @@ public void testQueryInterruptGracefullyStopsExplicitJob()
DriverManager.getConnection(connection_uri + ";JobCreationMode=1", new Properties());
Statement bigQueryStatement = bigQueryConnection.createStatement();

// This query takes 300 seconds to complete
String query300Seconds =
"DECLARE DELAY_TIME DATETIME; SET DELAY_TIME = DATETIME_ADD(CURRENT_DATETIME, INTERVAL 300"
+ " SECOND); WHILE CURRENT_DATETIME < DELAY_TIME DO END WHILE;";

// Query will be started in the background thread & we will call cancel from current thread.
Thread t =
new Thread(
() -> {
SQLException e =
assertThrows(
SQLException.class, () -> bigQueryStatement.execute(query300Seconds));
SQLException.class, () -> bigQueryStatement.execute(query300seconds));
Comment thread
logachev marked this conversation as resolved.
Outdated
assertTrue(e.getMessage().contains("User requested cancellation"));
threadException.set(false);
});
Expand Down Expand Up @@ -254,18 +249,13 @@ public void testQueryInterruptGracefullyStopsOptionalJob()
DriverManager.getConnection(connection_uri + ";JobCreationMode=2", new Properties());
Statement bigQueryStatement = bigQueryConnection.createStatement();

// This query takes 300 seconds to complete
String query300Seconds =
"DECLARE DELAY_TIME DATETIME; SET DELAY_TIME = DATETIME_ADD(CURRENT_DATETIME, INTERVAL 300"
+ " SECOND); WHILE CURRENT_DATETIME < DELAY_TIME DO END WHILE;";

// Query will be started in the background thread & we will call cancel from current thread.
Thread t =
new Thread(
() -> {
SQLException e =
assertThrows(
SQLException.class, () -> bigQueryStatement.execute(query300Seconds));
SQLException.class, () -> bigQueryStatement.execute(query300seconds));
Comment thread
logachev marked this conversation as resolved.
Outdated
assertTrue(e.getMessage().contains("Query was cancelled."));
threadException.set(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class ITStatementTest {
public class ITStatementTest extends ITBase {
Comment thread
logachev marked this conversation as resolved.
private static final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId();
private static String DATASET;
private static Random random = new Random();
Expand Down Expand Up @@ -323,15 +323,12 @@ public void testSetTimeout() throws SQLException {
Connection connection = DriverManager.getConnection(ITBase.connectionUrl);
Statement statement = connection.createStatement();

String selectQuery =
"SELECT views FROM bigquery-public-data.wikipedia.pageviews_2020 WHERE datehour >="
+ " '2020-01-01' LIMIT 9000000";

// statement.execute(selectQuery);
assertEquals(0, statement.getQueryTimeout());
statement.setQueryTimeout(1);
assertEquals(1, statement.getQueryTimeout());
SQLException e = assertThrows(SQLException.class, () -> statement.executeQuery(selectQuery));
SQLException e =
assertThrows(SQLException.class, () -> statement.executeQuery(query300seconds));
Comment thread
logachev marked this conversation as resolved.
Outdated
assertEquals(
"BigQueryException during runQuery\nJob execution was cancelled: Job timed out",
e.getMessage());
Expand Down Expand Up @@ -388,14 +385,6 @@ public void testRangeSelectDataset() throws SQLException {
connection.close();
}

int getSizeOfResultSet(ResultSet resultSet) throws SQLException {
int count = 0;
while (resultSet.next()) {
count++;
}
return count;
}

Comment thread
logachev marked this conversation as resolved.
@Test
public void testTemporaryDatasetLocation() throws SQLException, InterruptedException {
String projectId = DEFAULT_CATALOG;
Expand Down
Loading