Skip to content

Commit

Permalink
Rename test and consider clearBatch
Browse files Browse the repository at this point in the history
  • Loading branch information
zhicwu committed Jul 15, 2022
1 parent aeb5878 commit 6a11320
Showing 1 changed file with 43 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,49 @@ public void testBatchInsert() throws SQLException {
}
}

@Test(groups = "integration")
public void testBatchInsertWithoutUnboundedQueue() throws Exception {
Properties props = new Properties();
props.setProperty(ClickHouseClientOption.WRITE_BUFFER_SIZE.getKey(), "1");
props.setProperty(ClickHouseClientOption.MAX_QUEUED_BUFFERS.getKey(), "1");
try (ClickHouseConnection conn = newConnection(new Properties());
Statement s = conn.createStatement()) {
s.execute("drop table if exists test_insert_buffer_size; "
+ "CREATE TABLE test_insert_buffer_size(value String) ENGINE=Memory");
try (PreparedStatement ps = conn.prepareStatement(
"INSERT INTO test_insert_buffer_size")) {
ps.setString(1, "1");
ps.addBatch();
ps.setString(1, "2");
ps.addBatch();
ps.setString(1, "3");
ps.addBatch();
ps.executeBatch();

ps.setString(1, "4");
ps.addBatch();
ps.executeBatch();

ps.setString(1, "4");
ps.addBatch();
ps.clearBatch();
ps.setString(1, "5");
ps.addBatch();
ps.setString(1, "6");
ps.addBatch();
ps.executeBatch();
}

try (ResultSet rs = s.executeQuery("select * from test_insert_buffer_size order by value")) {
int count = 1;
while (rs.next()) {
Assert.assertEquals(rs.getInt(1), count++);
}
Assert.assertEquals(count, 7);
}
}
}

@Test(groups = "integration")
public void testQueryWithDateTime() throws SQLException {
try (ClickHouseConnection conn = newConnection(new Properties());
Expand Down Expand Up @@ -1368,36 +1411,6 @@ public void testQueryWithNamedParameter() throws SQLException {
}
}

@Test(groups = "integration")
public void testInsertBufferSize() throws Exception {
Properties props = new Properties();
props.setProperty(ClickHouseClientOption.WRITE_BUFFER_SIZE.getKey(), "1");
props.setProperty(ClickHouseClientOption.MAX_QUEUED_BUFFERS.getKey(), "1");
try (ClickHouseConnection conn = newConnection(new Properties());
Statement s = conn.createStatement()) {
s.execute("drop table if exists test_insert_buffer_size; "
+ "CREATE TABLE test_insert_buffer_size(value String) ENGINE=Memory");
try (PreparedStatement ps = conn.prepareStatement(
"INSERT INTO test_insert_buffer_size")) {
ps.setString(1, "1");
ps.addBatch();
ps.setString(1, "2");
ps.addBatch();
ps.setString(1, "3");
ps.addBatch();
ps.executeBatch();
}

try (ResultSet rs = s.executeQuery("select * from test_insert_buffer_size order by value")) {
int count = 1;
while (rs.next()) {
Assert.assertEquals(rs.getInt(1), count++);
}
Assert.assertEquals(count, 4);
}
}
}

@Test(groups = "integration")
public void testInsertWithAndSelect() throws Exception {
try (ClickHouseConnection conn = newConnection(new Properties());
Expand Down

0 comments on commit 6a11320

Please sign in to comment.