|
7 | 7 | import com.clickhouse.client.ClickHouseNode; |
8 | 8 | import com.clickhouse.client.ClickHouseNodeSelector; |
9 | 9 | import com.clickhouse.client.ClickHouseProtocol; |
10 | | -import com.clickhouse.client.ClickHouseRequest; |
11 | | -import com.clickhouse.client.ClickHouseResponse; |
12 | 10 | import com.clickhouse.client.api.Client; |
13 | 11 | import com.clickhouse.client.api.enums.Protocol; |
14 | 12 | import com.clickhouse.client.api.insert.InsertResponse; |
|
18 | 16 | import com.clickhouse.client.api.metrics.ServerMetrics; |
19 | 17 | import com.clickhouse.client.api.query.GenericRecord; |
20 | 18 | import com.clickhouse.client.config.ClickHouseClientOption; |
21 | | -import com.clickhouse.client.http.ClickHouseHttpClient; |
22 | | -import com.clickhouse.client.http.config.ClickHouseHttpOption; |
23 | | -import com.clickhouse.config.ClickHouseOption; |
24 | 19 | import com.clickhouse.data.ClickHouseFormat; |
25 | 20 | import com.github.tomakehurst.wiremock.WireMockServer; |
26 | | -import com.github.tomakehurst.wiremock.admin.model.ScenarioState; |
27 | 21 | import com.github.tomakehurst.wiremock.client.WireMock; |
28 | 22 | import com.github.tomakehurst.wiremock.common.ConsoleNotifier; |
29 | 23 | import com.github.tomakehurst.wiremock.core.WireMockConfiguration; |
30 | 24 | import com.github.tomakehurst.wiremock.http.Fault; |
31 | | -import org.apache.hc.client5.http.impl.Wire; |
32 | 25 | import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils; |
33 | 26 | import org.testng.Assert; |
34 | 27 | import org.testng.annotations.AfterMethod; |
|
39 | 32 | import java.io.ByteArrayOutputStream; |
40 | 33 | import java.io.IOException; |
41 | 34 | import java.io.PrintWriter; |
42 | | -import java.io.Serializable; |
43 | | -import java.net.ConnectException; |
44 | 35 | import java.util.ArrayList; |
45 | | -import java.util.HashMap; |
46 | 36 | import java.util.List; |
47 | | -import java.util.Map; |
48 | 37 | import java.util.UUID; |
49 | 38 | import java.util.concurrent.TimeUnit; |
50 | 39 |
|
@@ -156,6 +145,28 @@ public void insertRawData() throws Exception { |
156 | 145 | assertEquals(records.size(), 1000); |
157 | 146 | } |
158 | 147 |
|
| 148 | + |
| 149 | + @Test(groups = { "integration" }, enabled = true) |
| 150 | + public void insertRawDataSimple() throws Exception { |
| 151 | + insertRawDataSimple(1000); |
| 152 | + } |
| 153 | + public void insertRawDataSimple(int numberOfRecords) throws Exception { |
| 154 | + final String tableName = "raw_data_table"; |
| 155 | + createTable(String.format("CREATE TABLE IF NOT EXISTS %s (Id UInt32, event_ts Timestamp, name String, p1 Int64, p2 String) ENGINE = MergeTree() ORDER BY ()", tableName)); |
| 156 | + |
| 157 | + settings.setInputStreamCopyBufferSize(8198 * 2); |
| 158 | + ByteArrayOutputStream data = new ByteArrayOutputStream(); |
| 159 | + PrintWriter writer = new PrintWriter(data); |
| 160 | + for (int i = 0; i < numberOfRecords; i++) { |
| 161 | + writer.printf("%d\t%s\t%s\t%d\t%s\n", i, "2021-01-01 00:00:00", "name" + i, i, "p2"); |
| 162 | + } |
| 163 | + writer.flush(); |
| 164 | + InsertResponse response = client.insert(tableName, new ByteArrayInputStream(data.toByteArray()), |
| 165 | + ClickHouseFormat.TSV, settings).get(30, TimeUnit.SECONDS); |
| 166 | + OperationMetrics metrics = response.getMetrics(); |
| 167 | + assertEquals((int)response.getWrittenRows(), numberOfRecords ); |
| 168 | + } |
| 169 | + |
159 | 170 | @Test(groups = { "integration" }, enabled = true) |
160 | 171 | public void testNoHttpResponseFailure() { |
161 | 172 | WireMockServer faultyServer = new WireMockServer( WireMockConfiguration |
|
0 commit comments