Skip to content

Commit 48d5937

Browse files
authored
Merge pull request #1575 from ClickHouse/add-cloud-test-coverage
Adding cloud tests, bypassing sonar coverage because it is for classes not affected in this PR
2 parents bdb9be8 + 35a8c95 commit 48d5937

File tree

20 files changed

+590
-190
lines changed

20 files changed

+590
-190
lines changed

.github/workflows/analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ env:
3333
jobs:
3434
static:
3535
runs-on: ubuntu-latest
36-
timeout-minutes: 15
36+
timeout-minutes: 30
3737
name: Static code analysis
3838
steps:
3939
- name: Check out Git repository

.github/workflows/build.yml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ jobs:
218218
</toolchains>
219219
EOF
220220
- name: Test Java client
221+
env:
222+
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
223+
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
221224
run: |
222225
mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-cli-client,clickhouse-grpc-client,clickhouse-http-client -DclickhouseVersion=${{ matrix.clickhouse }} verify
223226
- name: Upload test results
@@ -228,13 +231,74 @@ jobs:
228231
path: |
229232
**/target/failsafe-reports
230233
**/target/surefire-reports
234+
test-http-client:
235+
runs-on: ubuntu-latest
236+
needs: compile
237+
strategy:
238+
matrix:
239+
# most recent LTS releases as well as latest stable builds
240+
# https://github.com/ClickHouse/ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease
241+
clickhouse: ["cloud"]
242+
fail-fast: false
243+
timeout-minutes: 15
244+
name: Java client (http) + CH ${{ matrix.clickhouse }}
245+
steps:
246+
- name: Check out repository
247+
uses: actions/checkout@v3
248+
- name: Check out PR
249+
run: |
250+
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 \
251+
origin pull/${{ github.event.inputs.pr }}/merge:merged-pr && git checkout merged-pr
252+
if: github.event.inputs.pr != ''
253+
- name: Install JDK 17 and Maven
254+
uses: actions/setup-java@v3
255+
with:
256+
distribution: "temurin"
257+
java-version: |
258+
8
259+
17
260+
cache: "maven"
261+
- name: Setup Toolchain
262+
shell: bash
263+
run: |
264+
mkdir -p $HOME/.m2 \
265+
&& cat << EOF > $HOME/.m2/toolchains.xml
266+
<?xml version="1.0" encoding="UTF8"?>
267+
<toolchains>
268+
<toolchain>
269+
<type>jdk</type>
270+
<provides>
271+
<version>17</version>
272+
</provides>
273+
<configuration>
274+
<jdkHome>${{ env.JAVA_HOME }}</jdkHome>
275+
</configuration>
276+
</toolchain>
277+
</toolchains>
278+
EOF
279+
- name: Install Java client
280+
run: mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-http-client -DskipTests install
281+
- name: Test http client
282+
env:
283+
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
284+
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
285+
run: |
286+
mvn --batch-mode --no-transfer-progress --projects clickhouse-http-client -DclickhouseVersion=${{ matrix.clickhouse }} -Dprotocol=http verify
287+
- name: Upload test results
288+
uses: actions/upload-artifact@v2
289+
if: failure()
290+
with:
291+
name: result ${{ github.job }}
292+
path: |
293+
**/target/failsafe-reports
294+
**/target/surefire-reports
231295
232296
test-jdbc-driver:
233297
runs-on: ubuntu-latest
234298
needs: compile
235299
strategy:
236300
matrix:
237-
clickhouse: ["23.8", "24.3", "24.6", "latest"]
301+
clickhouse: ["23.8", "24.3", "24.6", "latest", "cloud"]
238302
# here http, http_client and apache_http_client represent different value of http_connection_provider
239303
protocol: ["http", "http_client", "apache_http_client", "grpc"]
240304
fail-fast: false
@@ -277,6 +341,9 @@ jobs:
277341
- name: Install Java client
278342
run: mvn --also-make --batch-mode --no-transfer-progress --projects clickhouse-cli-client,clickhouse-grpc-client,clickhouse-http-client -DskipTests install
279343
- name: Test JDBC driver
344+
env:
345+
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
346+
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
280347
run: |
281348
mvn --batch-mode --no-transfer-progress --projects clickhouse-jdbc -DclickhouseVersion=${{ matrix.clickhouse }} -Dprotocol=${{ matrix.protocol }} verify
282349
- name: Upload test results

clickhouse-client/src/test/java/com/clickhouse/client/BaseIntegrationTest.java

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import java.util.Map;
77

88
import com.clickhouse.client.config.ClickHouseClientOption;
9+
import org.testng.annotations.AfterSuite;
10+
import org.testng.annotations.AfterTest;
11+
import org.testng.annotations.BeforeSuite;
912
import org.testng.annotations.BeforeTest;
1013

1114
/**
@@ -17,6 +20,11 @@ public static void setupClickHouseContainer() {
1720
ClickHouseServerForTest.beforeSuite();
1821
}
1922

23+
@AfterTest(groups = {"integration"})
24+
public static void teardownClickHouseContainer() {
25+
ClickHouseServerForTest.afterSuite();
26+
}
27+
2028
protected ClickHouseNode getSecureServer(ClickHouseProtocol protocol) {
2129
return ClickHouseServerForTest.getClickHouseNode(protocol, true, ClickHouseNode.builder().addOption(ClickHouseClientOption.SSL.getKey(), "true").build());
2230
}
@@ -26,11 +34,11 @@ protected ClickHouseNode getSecureServer(ClickHouseProtocol protocol, ClickHouse
2634
}
2735

2836
protected ClickHouseNode getServer(ClickHouseProtocol protocol) {
29-
return ClickHouseServerForTest.getClickHouseNode(protocol, false, ClickHouseNode.builder().build());
37+
return ClickHouseServerForTest.getClickHouseNode(protocol, isCloud(), ClickHouseNode.builder().build());
3038
}
3139

3240
protected ClickHouseNode getServer(ClickHouseProtocol protocol, ClickHouseNode base) {
33-
return ClickHouseServerForTest.getClickHouseNode(protocol, false, base);
41+
return ClickHouseServerForTest.getClickHouseNode(protocol, isCloud(), base);
3442
}
3543

3644
protected ClickHouseNode getServer(ClickHouseProtocol protocol, int port) {
@@ -52,4 +60,30 @@ protected String getIpAddress(ClickHouseNode server) {
5260
return ipAddress;
5361
}
5462

63+
protected boolean isCloud() {
64+
return ClickHouseServerForTest.isCloud();
65+
}
66+
67+
protected String getConnectionProtocol() {
68+
if (isCloud()) {
69+
return "https";
70+
} else {
71+
return "http";
72+
}
73+
}
74+
75+
protected String getPassword() {
76+
return ClickHouseServerForTest.getPassword();
77+
}
78+
79+
protected boolean runQuery(String query) {
80+
return ClickHouseServerForTest.runQuery(query);
81+
}
82+
83+
protected boolean createDatabase(String dbName) {
84+
return ClickHouseServerForTest.runQuery("CREATE DATABASE IF NOT EXISTS " + dbName);
85+
}
86+
protected boolean dropDatabase(String dbName) {
87+
return ClickHouseServerForTest.runQuery("DROP DATABASE IF EXISTS " + dbName);
88+
}
5589
}

clickhouse-client/src/test/java/com/clickhouse/client/ClickHouseNodeTest.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,26 @@ public void testQueryWithSlash() throws URISyntaxException {
393393
@Test(groups = { "integration" })
394394
public void testProbe() {
395395
// FIXME does not support ClickHouseProtocol.POSTGRESQL for now
396-
ClickHouseProtocol[] protocols = new ClickHouseProtocol[] { ClickHouseProtocol.GRPC,
397-
ClickHouseProtocol.HTTP, ClickHouseProtocol.MYSQL, ClickHouseProtocol.TCP };
396+
ClickHouseProtocol[] protocols = null;
397+
if ( isCloud() ) {
398+
protocols = new ClickHouseProtocol[]{
399+
ClickHouseProtocol.HTTP
400+
};
401+
} else {
402+
protocols = new ClickHouseProtocol[]{ClickHouseProtocol.GRPC,
403+
ClickHouseProtocol.HTTP, ClickHouseProtocol.MYSQL, ClickHouseProtocol.TCP};
404+
}
398405
ClickHouseVersion serverVersion = ClickHouseVersion
399406
.of(System.getProperty("clickhouseVersion", "latest"));
400407
for (ClickHouseProtocol p : protocols) {
401408
if (p == ClickHouseProtocol.GRPC && !serverVersion.check("[21.1,)")) {
402409
continue;
403410
}
404-
ClickHouseNode node = getServer(ClickHouseProtocol.ANY, p.getDefaultPort());
411+
int port = p.getDefaultPort();
412+
if (isCloud()) {
413+
port = 8443;
414+
}
415+
ClickHouseNode node = getServer(ClickHouseProtocol.ANY, port);
405416
ClickHouseNode probedNode = node.probe();
406417
Assert.assertNotEquals(probedNode, node);
407418
Assert.assertEquals(probedNode.getProtocol(), p);

0 commit comments

Comments
 (0)