Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cloud-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;

Expand Down Expand Up @@ -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<String, String> readYourWritesSettings() {
return isCloud() ? Collections.singletonMap("select_sequential_consistency", "1") : Collections.emptyMap();
}

protected String getConnectionProtocol() {
if (isCloud()) {
return "https";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,16 @@ 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())
.compressClientRequest(false)
.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<String> columns, List<Supplier<Object>> valueGenerators,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down Expand Up @@ -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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataTypeTests client misses Cloud setting

Medium Severity

readYourWritesSettings is applied only in newClient, but setUp builds the shared client with a separate Client.Builder and never calls that helper. Most DataTypeTests methods, including insert-then-select helpers like writeReadVerify, use that setUp client, so Cloud replica lag can still hide rows written by the previous request.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit faefbf6. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ac5f565: setUp now builds the shared client with newClient(), so it gets readYourWritesSettings() too.

.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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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())
Expand All @@ -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"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading