diff --git a/.github/workflows/cloud-cleanup.yml b/.github/workflows/cloud-cleanup.yml index 603c99dc0..c74447b66 100644 --- a/.github/workflows/cloud-cleanup.yml +++ b/.github/workflows/cloud-cleanup.yml @@ -34,7 +34,7 @@ jobs: CLICKHOUSE_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT_PROD }} CLICKHOUSE_USER: default CLICKHOUSE_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT_PROD }} - # Longer than a cloud.yml job can run (timeout-minutes: 20), so a running job keeps its databases. + # Longer than a cloud.yml job can run (timeout-minutes: 30), so a running job keeps its databases. TTL_MINUTES: 60 DRY_RUN: ${{ inputs.dry_run || false }} steps: diff --git a/.github/workflows/cloud.yml b/.github/workflows/cloud.yml index 1bb8e2c43..62f5ae7bd 100644 --- a/.github/workflows/cloud.yml +++ b/.github/workflows/cloud.yml @@ -20,7 +20,8 @@ jobs: matrix: project: ["client-v2", "jdbc-v2"] fail-fast: false - timeout-minutes: 20 + # client-v2 runs about 18-20 minutes against Cloud + timeout-minutes: 30 name: ${{ matrix.project }} + ClickHouse Cloud env: TEST_CLICKHOUSE_CONTAINER: none diff --git a/clickhouse-client/src/test/java/com/clickhouse/client/BaseIntegrationTest.java b/clickhouse-client/src/test/java/com/clickhouse/client/BaseIntegrationTest.java index ea98fee96..cb58de4bd 100644 --- a/clickhouse-client/src/test/java/com/clickhouse/client/BaseIntegrationTest.java +++ b/clickhouse-client/src/test/java/com/clickhouse/client/BaseIntegrationTest.java @@ -6,6 +6,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Collections; import java.util.Locale; import java.util.Map; @@ -62,6 +63,16 @@ protected boolean isCloud() { return ClickHouseServerForTest.isCloud(); } + /** + * Server settings that make a query see the inserts of earlier requests. On ClickHouse Cloud, each + * request can go to another replica, and that replica can answer before it has the new data. + * Empty outside ClickHouse Cloud: there, the cluster test environment waits for every replica + * on insert ({@code insert_quorum}). + */ + protected Map readYourWritesSettings() { + return isCloud() ? Collections.singletonMap("select_sequential_consistency", "1") : Collections.emptyMap(); + } + protected String getConnectionProtocol() { if (isCloud()) { return "https"; diff --git a/client-v2/src/test/java/com/clickhouse/client/HttpTransportTests.java b/client-v2/src/test/java/com/clickhouse/client/HttpTransportTests.java index 9f939adda..de5101976 100644 --- a/client-v2/src/test/java/com/clickhouse/client/HttpTransportTests.java +++ b/client-v2/src/test/java/com/clickhouse/client/HttpTransportTests.java @@ -2922,6 +2922,10 @@ private static void assertQueryWasInterrupted(Client client, String queryId) thr @Test(groups = {"integration"}) public void testStickyReplica() { + if (isCloud()) { + // https://clickhouse.com/docs/products/cloud/features/infrastructure/replica-aware-routing + throw new SkipException("Replica-aware routing is not enabled on the Cloud test service"); + } final String replicaKey = UUID.randomUUID().toString(); QuerySettings stickyReplica = new QuerySettings().httpHeader(ClickHouseHttpProto.HEADER_REPLICA_TAG, replicaKey); diff --git a/client-v2/src/test/java/com/clickhouse/client/ParameterizedQueryTest.java b/client-v2/src/test/java/com/clickhouse/client/ParameterizedQueryTest.java index cac85da33..2386a0dbf 100644 --- a/client-v2/src/test/java/com/clickhouse/client/ParameterizedQueryTest.java +++ b/client-v2/src/test/java/com/clickhouse/client/ParameterizedQueryTest.java @@ -275,7 +275,7 @@ private int[] queryInstant(String tableName, String fieldName, String operator, private Client.Builder newClient() { ClickHouseNode node = getServer(ClickHouseProtocol.HTTP); boolean isSecure = isCloud(); - return new Client.Builder() + Client.Builder builder = new Client.Builder() .addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), isSecure) .setUsername("default") .setPassword(ClickHouseServerForTest.getPassword()) @@ -283,6 +283,8 @@ private Client.Builder newClient() { .setDefaultDatabase(ClickHouseServerForTest.getDatabase()) .serverSetting(ServerSettings.WAIT_ASYNC_INSERT, "1") .serverSetting(ServerSettings.ASYNC_INSERT, "0"); + readYourWritesSettings().forEach(builder::serverSetting); + return builder; } private void prepareDataSet(String table, List columns, List> valueGenerators, diff --git a/client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java b/client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java index 4f68d2cb5..38f7d63a3 100644 --- a/client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java +++ b/client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java @@ -84,17 +84,7 @@ public DataTypeTests() { @BeforeMethod(groups = {"integration"}) public void setUp() throws IOException { - ClickHouseNode node = getServer(ClickHouseProtocol.HTTP); - client = new Client.Builder() - .addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), isCloud()) - .setUsername(ClickHouseServerForTest.getUsername()) - .setPassword(ClickHouseServerForTest.getPassword()) - .setDefaultDatabase(ClickHouseServerForTest.getDatabase()) - .compressClientRequest(useClientCompression) - .useHttpCompression(useHttpCompression) - .serverSetting(ServerSettings.WAIT_END_OF_QUERY, "1") - .serverSetting(ServerSettings.WAIT_ASYNC_INSERT, "1") - .build(); + client = newClient().build(); } @AfterMethod(groups = {"integration"}) @@ -3684,14 +3674,16 @@ private boolean isVersionMatch(String versionExpression) { private Client.Builder newClient() { ClickHouseNode node = getServer(ClickHouseProtocol.HTTP); - return new Client.Builder() + Client.Builder builder = new Client.Builder() .addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), isCloud()) - .setUsername("default") + .setUsername(ClickHouseServerForTest.getUsername()) .setPassword(ClickHouseServerForTest.getPassword()) .setDefaultDatabase(ClickHouseServerForTest.getDatabase()) .compressClientRequest(useClientCompression) .useHttpCompression(useHttpCompression) .serverSetting(ServerSettings.WAIT_END_OF_QUERY, "1") .serverSetting(ServerSettings.WAIT_ASYNC_INSERT, "1"); + readYourWritesSettings().forEach(builder::serverSetting); + return builder; } } diff --git a/client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java b/client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java index 3d48ceeb5..688d9733f 100644 --- a/client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java +++ b/client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java @@ -1149,7 +1149,10 @@ public void testIntegerDataTypes() { @Test(groups = {"integration"}) public void testFloatDataTypes() { - final boolean usesPreciseFloatParsing = isVersionMatch("[26.7,)"); + // precise_float_parsing is on by default from 26.7, but a server can turn it off (the ClickHouse Cloud + // service of cloud.yml has it off) + final boolean usesPreciseFloatParsing = client.queryAll( + "SELECT toUInt8(getSetting('precise_float_parsing')) AS precise").get(0).getInteger("precise") == 1; final float expectedMaxFloat32 = usesPreciseFloatParsing ? Float.MAX_VALUE : 3.4028233E38F; final double expectedMinFloat64 = usesPreciseFloatParsing ? Double.MIN_VALUE : 0.0D; @@ -2273,7 +2276,7 @@ public void testGetColumnsByIndex() throws Exception { protected Client.Builder newClient() { ClickHouseNode node = getServer(ClickHouseProtocol.HTTP); boolean isSecure = isCloud(); - return new Client.Builder() + Client.Builder builder = new Client.Builder() .addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), isSecure) .setUsername("default") .setPassword(ClickHouseServerForTest.getPassword()) @@ -2284,6 +2287,8 @@ protected Client.Builder newClient() { .setDefaultDatabase(ClickHouseServerForTest.getDatabase()) .serverSetting(ServerSettings.WAIT_ASYNC_INSERT, "1") .serverSetting(ServerSettings.ASYNC_INSERT, "0"); + readYourWritesSettings().forEach(builder::serverSetting); + return builder; } @Test(groups = {"integration"}) diff --git a/jdbc-v2/src/test/java/com/clickhouse/jdbc/JdbcIntegrationTest.java b/jdbc-v2/src/test/java/com/clickhouse/jdbc/JdbcIntegrationTest.java index 7b66a95fb..d5577a8c0 100644 --- a/jdbc-v2/src/test/java/com/clickhouse/jdbc/JdbcIntegrationTest.java +++ b/jdbc-v2/src/test/java/com/clickhouse/jdbc/JdbcIntegrationTest.java @@ -56,6 +56,7 @@ public Connection getJdbcConnection(Properties properties) throws SQLException { } info.putIfAbsent(ClientConfigProperties.DATABASE.getKey(), getDatabase()); + readYourWritesSettings().forEach((name, value) -> info.putIfAbsent(DriverProperties.serverSetting(name), value)); return new ConnectionImpl(getEndpointString(), info); }