-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-806332 Fix test timeouts (#1380)
* SNOW-806332 Fix test timeouts
- Loading branch information
1 parent
9b7fb9d
commit 930c7ec
Showing
3 changed files
with
88 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
src/test/java/net/snowflake/client/jdbc/PreparedStatementLargeUpdateIT.java
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
src/test/java/net/snowflake/client/jdbc/PreparedStatementLargeUpdateLatestIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
package net.snowflake.client.jdbc; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.spy; | ||
|
||
import java.sql.Connection; | ||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
import java.util.Map; | ||
import net.snowflake.client.ConditionalIgnoreRule; | ||
import net.snowflake.client.RunningOnGithubAction; | ||
import net.snowflake.client.category.TestCategoryStatement; | ||
import net.snowflake.client.core.ExecTimeTelemetryData; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.mockito.Mockito; | ||
|
||
@Category(TestCategoryStatement.class) | ||
public class PreparedStatementLargeUpdateLatestIT extends BaseJDBCTest { | ||
|
||
/** | ||
* Test that large update larger than MAX_INT returns correctly | ||
* | ||
* @throws Throwable | ||
*/ | ||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class) | ||
public void testLargeUpdate() throws Throwable { | ||
try (Connection con = getConnection()) { | ||
long expectedUpdateRows = (long) Integer.MAX_VALUE + 10L; | ||
con.createStatement().execute("create or replace table test_large_update(c1 boolean)"); | ||
PreparedStatement st = | ||
con.prepareStatement( | ||
"insert into test_large_update select true from table(generator(rowcount=>" | ||
+ expectedUpdateRows | ||
+ "))"); | ||
PreparedStatement spyp = spy(st); | ||
// Mock internal method which returns rowcount | ||
Mockito.doReturn(expectedUpdateRows) | ||
.when((SnowflakePreparedStatementV1) spyp) | ||
.executeUpdateInternal( | ||
Mockito.any(String.class), | ||
Mockito.any(Map.class), | ||
Mockito.any(boolean.class), | ||
Mockito.any(ExecTimeTelemetryData.class)); | ||
long updatedRows = spyp.executeLargeUpdate(); | ||
assertEquals(expectedUpdateRows, updatedRows); | ||
con.createStatement().execute("drop table if exists test_large_update"); | ||
} | ||
} | ||
|
||
/** | ||
* Test that when a batch size larger than MAX_INT is returned, the result is returned as a long. | ||
* | ||
* @throws SQLException | ||
*/ | ||
@Test | ||
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class) | ||
public void testExecuteLargeBatchOverIntMax() throws SQLException { | ||
try (Connection connection = getConnection()) { | ||
connection | ||
.createStatement() | ||
.execute("create or replace table over_int_table (val string, id int)"); | ||
PreparedStatement pstmt = connection.prepareStatement("UPDATE over_int_table SET ID=200"); | ||
PreparedStatement spyp = spy(pstmt); | ||
long numRows = Integer.MAX_VALUE + 10L; | ||
// Mock internal method which returns rowcount | ||
Mockito.doReturn(numRows) | ||
.when((SnowflakePreparedStatementV1) spyp) | ||
.executeUpdateInternal( | ||
Mockito.any(String.class), | ||
Mockito.any(Map.class), | ||
Mockito.any(boolean.class), | ||
Mockito.any(ExecTimeTelemetryData.class)); | ||
pstmt.addBatch(); | ||
long[] queryResult = spyp.executeLargeBatch(); | ||
assertEquals(1, queryResult.length); | ||
assertEquals(numRows, queryResult[0]); | ||
connection.createStatement().execute("drop table if exists over_int_table"); | ||
} | ||
} | ||
} |