Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing #1726

Closed
wants to merge 1 commit into from
Closed

testing #1726

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
21 changes: 13 additions & 8 deletions src/test/java/net/snowflake/client/jdbc/ServiceNameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,21 @@ public void testAddServiceNameToRequestHeader() throws Throwable {
props.setProperty(SFSessionProperty.USER.getPropertyKey(), "fakeuser");
props.setProperty(SFSessionProperty.PASSWORD.getPropertyKey(), "fakepassword");
props.setProperty(SFSessionProperty.INSECURE_MODE.getPropertyKey(), Boolean.TRUE.toString());
SnowflakeConnectionV1 con =
try (SnowflakeConnectionV1 con =
new SnowflakeConnectionV1(
"jdbc:snowflake://http://fakeaccount.snowflakecomputing.com", props);
assertThat(con.getSfSession().getServiceName(), is(INITIAL_SERVICE_NAME));
"jdbc:snowflake://http://fakeaccount.snowflakecomputing.com", props)) {
assertThat(con.getSfSession().getServiceName(), is(INITIAL_SERVICE_NAME));

SnowflakeStatementV1 stmt = (SnowflakeStatementV1) con.createStatement();
stmt.execute("SELECT 1");
assertThat(
stmt.getConnection().unwrap(SnowflakeConnectionV1.class).getSfSession().getServiceName(),
is(NEW_SERVICE_NAME));
try (SnowflakeStatementV1 stmt = (SnowflakeStatementV1) con.createStatement()) {
stmt.execute("SELECT 1");
assertThat(
stmt.getConnection()
.unwrap(SnowflakeConnectionV1.class)
.getSfSession()
.getServiceName(),
is(NEW_SERVICE_NAME));
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ public void testChunkDownloaderRetry() throws SQLException, InterruptedException

SnowflakeChunkDownloader snowflakeChunkDownloaderSpy = null;

try (Connection connection = getConnection(properties)) {
Statement statement = connection.createStatement();
try (Connection connection = getConnection(properties);
Statement statement = connection.createStatement()) {
// execute a query that will require chunk downloading
ResultSet resultSet =
try (ResultSet resultSet =
statement.executeQuery(
"select seq8(), randstr(1000, random()) from table(generator(rowcount => 10000))");
List<SnowflakeResultSetSerializable> resultSetSerializables =
((SnowflakeResultSet) resultSet).getResultSetSerializables(100 * 1024 * 1024);
SnowflakeResultSetSerializable resultSetSerializable = resultSetSerializables.get(0);
SnowflakeChunkDownloader downloader =
new SnowflakeChunkDownloader((SnowflakeResultSetSerializableV1) resultSetSerializable);
snowflakeChunkDownloaderSpy = Mockito.spy(downloader);
snowflakeChunkDownloaderSpy.getNextChunkToConsume();
"select seq8(), randstr(1000, random()) from table(generator(rowcount => 10000))")) {
List<SnowflakeResultSetSerializable> resultSetSerializables =
((SnowflakeResultSet) resultSet).getResultSetSerializables(100 * 1024 * 1024);
SnowflakeResultSetSerializable resultSetSerializable = resultSetSerializables.get(0);
SnowflakeChunkDownloader downloader =
new SnowflakeChunkDownloader((SnowflakeResultSetSerializableV1) resultSetSerializable);
snowflakeChunkDownloaderSpy = Mockito.spy(downloader);
snowflakeChunkDownloaderSpy.getNextChunkToConsume();
}
} catch (SnowflakeSQLException exception) {
// verify that request was retried twice before reaching max retries
Mockito.verify(snowflakeChunkDownloaderSpy, Mockito.times(2)).getResultStreamProvider();
Expand Down
Loading
Loading