|
25 | 25 | import java.util.stream.Collectors;
|
26 | 26 |
|
27 | 27 | import com.clickhouse.client.ClickHouseClientBuilder.Agent;
|
| 28 | +import com.clickhouse.client.config.ClickHouseBufferingMode; |
28 | 29 | import com.clickhouse.client.config.ClickHouseClientOption;
|
29 | 30 | import com.clickhouse.client.config.ClickHouseRenameMethod;
|
30 | 31 | import com.clickhouse.client.config.ClickHouseSslMode;
|
@@ -93,11 +94,27 @@ protected ClickHouseNode getSecureServer() {
|
93 | 94 |
|
94 | 95 | @DataProvider(name = "compressionMatrix")
|
95 | 96 | protected Object[][] getCompressionMatrix() {
|
96 |
| - return new Object[][] { |
97 |
| - new Object[] { false, false }, |
98 |
| - new Object[] { true, false }, |
99 |
| - new Object[] { true, true }, |
100 |
| - new Object[] { false, true } }; |
| 97 | + ClickHouseFormat[] formats = new ClickHouseFormat[] { |
| 98 | + ClickHouseFormat.RowBinaryWithNamesAndTypes, |
| 99 | + ClickHouseFormat.TabSeparatedWithNamesAndTypes |
| 100 | + }; |
| 101 | + ClickHouseBufferingMode[] modes = new ClickHouseBufferingMode[] { |
| 102 | + ClickHouseBufferingMode.RESOURCE_EFFICIENT, |
| 103 | + ClickHouseBufferingMode.PERFORMANCE |
| 104 | + }; |
| 105 | + boolean[] bools = new boolean[] { true, false }; |
| 106 | + Object[][] array = new Object[formats.length * modes.length * 2 * 2][4]; |
| 107 | + int i = 0; |
| 108 | + for (ClickHouseFormat format : formats) { |
| 109 | + for (ClickHouseBufferingMode mode : modes) { |
| 110 | + for (boolean compress : bools) { |
| 111 | + for (boolean decompress : bools) { |
| 112 | + array[i++] = new Object[] { format, mode, compress, decompress }; |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + return array; |
101 | 118 | }
|
102 | 119 |
|
103 | 120 | @DataProvider(name = "renameMethods")
|
@@ -187,47 +204,44 @@ public void testOpenCloseClient() throws Exception {
|
187 | 204 | }
|
188 | 205 |
|
189 | 206 | @Test(dataProvider = "compressionMatrix", groups = { "integration" })
|
190 |
| - public void testCompression(boolean compressRequest, boolean compressResponse) |
191 |
| - throws ClickHouseException { |
| 207 | + public void testCompression(ClickHouseFormat format, ClickHouseBufferingMode bufferingMode, |
| 208 | + boolean compressRequest, boolean compressResponse) throws ClickHouseException { |
192 | 209 | ClickHouseNode server = getServer();
|
193 | 210 | String uuid = UUID.randomUUID().toString();
|
194 |
| - for (ClickHouseFormat format : new ClickHouseFormat[] { |
195 |
| - ClickHouseFormat.RowBinaryWithNamesAndTypes, |
196 |
| - ClickHouseFormat.TabSeparatedWithNamesAndTypes }) { |
197 |
| - try (ClickHouseClient client = getClient()) { |
198 |
| - ClickHouseRequest<?> request = client.connect(server) |
199 |
| - .format(format) |
200 |
| - .compressServerResponse(compressResponse) |
201 |
| - .decompressClientRequest(compressRequest); |
202 |
| - boolean hasResult = false; |
203 |
| - try (ClickHouseResponse resp = request |
204 |
| - .query("select :uuid").params(ClickHouseStringValue.of(uuid)).executeAndWait()) { |
205 |
| - Assert.assertEquals(resp.firstRecord().getValue(0).asString(), uuid); |
206 |
| - hasResult = true; |
207 |
| - } |
208 |
| - Assert.assertTrue(hasResult, "Should have at least one result"); |
| 211 | + try (ClickHouseClient client = getClient()) { |
| 212 | + ClickHouseRequest<?> request = client.connect(server) |
| 213 | + .format(format) |
| 214 | + .option(ClickHouseClientOption.RESPONSE_BUFFERING, bufferingMode) |
| 215 | + .compressServerResponse(compressResponse) |
| 216 | + .decompressClientRequest(compressRequest); |
| 217 | + boolean hasResult = false; |
| 218 | + try (ClickHouseResponse resp = request |
| 219 | + .query("select :uuid").params(ClickHouseStringValue.of(uuid)).executeAndWait()) { |
| 220 | + Assert.assertEquals(resp.firstRecord().getValue(0).asString(), uuid); |
| 221 | + hasResult = true; |
| 222 | + } |
| 223 | + Assert.assertTrue(hasResult, "Should have at least one result"); |
209 | 224 |
|
210 |
| - // empty results |
211 |
| - try (ClickHouseResponse resp = request |
212 |
| - .query("create database if not exists system") |
213 |
| - .executeAndWait()) { |
214 |
| - ClickHouseResponseSummary summary = resp.getSummary(); |
215 |
| - Assert.assertEquals(summary.getReadRows(), 0L); |
216 |
| - Assert.assertEquals(summary.getWrittenRows(), 0L); |
217 |
| - } |
| 225 | + // empty results |
| 226 | + try (ClickHouseResponse resp = request |
| 227 | + .query("create database if not exists system") |
| 228 | + .executeAndWait()) { |
| 229 | + ClickHouseResponseSummary summary = resp.getSummary(); |
| 230 | + Assert.assertEquals(summary.getReadRows(), 0L); |
| 231 | + Assert.assertEquals(summary.getWrittenRows(), 0L); |
| 232 | + } |
218 | 233 |
|
219 |
| - // let's also check if failures can be captured successfully as well |
220 |
| - ClickHouseException exp = null; |
221 |
| - try (ClickHouseResponse resp = request |
222 |
| - .use(uuid) |
223 |
| - .query("select currentUser(), timezone(), version(), getSetting('readonly') readonly FORMAT RowBinaryWithNamesAndTypes") |
224 |
| - .executeAndWait()) { |
225 |
| - Assert.fail("Query should fail"); |
226 |
| - } catch (ClickHouseException e) { |
227 |
| - exp = e; |
228 |
| - } |
229 |
| - Assert.assertEquals(exp.getErrorCode(), 81); |
| 234 | + // let's also check if failures can be captured successfully as well |
| 235 | + ClickHouseException exp = null; |
| 236 | + try (ClickHouseResponse resp = request |
| 237 | + .use(uuid) |
| 238 | + .query("select currentUser(), timezone(), version(), getSetting('readonly') readonly FORMAT RowBinaryWithNamesAndTypes") |
| 239 | + .executeAndWait()) { |
| 240 | + Assert.fail("Query should fail"); |
| 241 | + } catch (ClickHouseException e) { |
| 242 | + exp = e; |
230 | 243 | }
|
| 244 | + Assert.assertEquals(exp.getErrorCode(), 81); |
231 | 245 | }
|
232 | 246 | }
|
233 | 247 |
|
|
0 commit comments