Skip to content

Commit

Permalink
[misc] batch test correction
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Oct 15, 2019
1 parent aa352d5 commit 21d9493
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/test/java/org/mariadb/jdbc/ExecuteBatchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,16 @@ public void serverBulk1mTest() throws SQLException {
Assume.assumeTrue(checkMaxAllowedPacketMore8m("serverBulk1mTest"));
Assume.assumeTrue(runLongTest);
Assume.assumeFalse(sharedIsAurora());
Assume.assumeTrue(isMariadbServer());

sharedConnection.createStatement().execute("TRUNCATE TABLE ExecuteBatchTest");

try (Connection connection =
setConnection("&useBulkStmts=true&useComMulti=false&useBatchMultiSend=true&profileSql=" + profileSql)) {
PreparedStatement preparedStatement =
connection.prepareStatement("INSERT INTO ExecuteBatchTest(test, test2) values (?, ?)");
// packet size : 7 200 068 kb
addBatchData(preparedStatement, 10000, connection, false, false);
addBatchData(preparedStatement, 10000, connection, false, false || !minVersion(10, 2));
}
}

Expand All @@ -195,7 +197,7 @@ public void serverBulk20mTest() throws SQLException {
PreparedStatement preparedStatement =
connection.prepareStatement("INSERT INTO ExecuteBatchTest(test, test2) values (?, ?)");
// packet size : 7 200 068 kb
addBatchData(preparedStatement, 160000, connection);
addBatchData(preparedStatement, 160000, connection, false, false || !minVersion(10, 2));
}
}

Expand Down Expand Up @@ -231,7 +233,7 @@ public void clientBulkTest() throws SQLException {
+ profileSql)) {
PreparedStatement preparedStatement =
connection.prepareStatement("INSERT INTO ExecuteBatchTest(test, test2) values (?, ?)");
addBatchData(preparedStatement, 10000, connection, false, false);
addBatchData(preparedStatement, 10000, connection, false, false || !minVersion(10, 2));
}
}

Expand All @@ -256,30 +258,16 @@ public void clientMultipleTest() throws SQLException {
}

@Test
public void clientRewriteValuesNotPossible8mTest() throws SQLException {
Assume.assumeTrue(checkMaxAllowedPacketMore8m("clientRewriteValuesNotPossible8mTest"));
Assume.assumeTrue(runLongTest);
sharedConnection.createStatement().execute("TRUNCATE TABLE ExecuteBatchTest");
try (Connection connection =
setConnection("&rewriteBatchedStatements=true&profileSql=" + profileSql)) {
PreparedStatement preparedStatement =
connection.prepareStatement(
"INSERT INTO ExecuteBatchTest(test, test2) values (?, ?) ON DUPLICATE KEY UPDATE id=?");
addBatchData(preparedStatement, 60000, connection, true, true);
}
}

@Test
public void clientRewriteValuesNotPossible20mTest() throws SQLException {
Assume.assumeTrue(checkMaxAllowedPacketMore8m("clientRewriteValuesNotPossible20Test"));
public void clientRewriteValuesNotPossible1mTest() throws SQLException {
Assume.assumeTrue(checkMaxAllowedPacketMore8m("clientRewriteValuesNotPossible1mTest"));
Assume.assumeTrue(runLongTest);
sharedConnection.createStatement().execute("TRUNCATE TABLE ExecuteBatchTest");
try (Connection connection =
setConnection("&rewriteBatchedStatements=true&profileSql=" + profileSql)) {
PreparedStatement preparedStatement =
connection.prepareStatement(
"INSERT INTO ExecuteBatchTest(test, test2) values (?, ?) ON DUPLICATE KEY UPDATE id=?");
addBatchData(preparedStatement, 160000, connection, true, true);
addBatchData(preparedStatement, 10000, connection, true, true);
}
}

Expand Down Expand Up @@ -322,7 +310,8 @@ private void addBatchData(
connection.createStatement().executeQuery("SELECT * FROM ExecuteBatchTest");
for (int i = 0; i < batchNumber; i++) {
assertTrue(resultSet.next());
if (!sharedOptions().useBulkStmts) {
if (sendUnique
&& (!sharedOptions().useBulkStmts || !isMariadbServer() || !minVersion(10, 2))) {
assertEquals(i + 1, resultSet.getInt(1));
}
assertEquals(oneHundredLengthString, resultSet.getString(2));
Expand Down

0 comments on commit 21d9493

Please sign in to comment.