Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ClickHouse smoke tests for Altinity #10651

Merged
merged 4 commits into from
Jan 19, 2022
Merged
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 docs/src/main/sphinx/connector/clickhouse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Requirements

To connect to a ClickHouse server, you need:

* ClickHouse version 20.8 or higher.
* ClickHouse (version 20.8 or higher) or Altinity (version 20.3 or higher).
* Network access from the Trino coordinator and workers to the ClickHouse
server. Port 8123 is the default port.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static DistributedQueryRunner createClickHouseQueryRunner(

queryRunner.installPlugin(new ClickHousePlugin());
queryRunner.createCatalog("clickhouse", "clickhouse", connectorProperties);
server.execute("CREATE DATABASE " + TPCH_SCHEMA);
queryRunner.execute("CREATE SCHEMA " + TPCH_SCHEMA);
copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
return queryRunner;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.plugin.clickhouse;

import com.google.common.collect.ImmutableMap;
import io.trino.testing.QueryRunner;

import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner;
import static io.trino.plugin.clickhouse.TestingClickHouseServer.ALTINITY_DEFAULT_IMAGE;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

public class TestAltinityConnectorSmokeTest
extends BaseClickHouseConnectorSmokeTest
{
@Override
protected QueryRunner createQueryRunner()
throws Exception
{
return createClickHouseQueryRunner(
closeAfterClass(new TestingClickHouseServer(ALTINITY_DEFAULT_IMAGE)),
ImmutableMap.of(),
ImmutableMap.<String, String>builder()
.put("clickhouse.map-string-as-varchar", "true") // To handle string types in TPCH tables as varchar instead of varbinary
.buildOrThrow(),
REQUIRED_TPCH_TABLES);
}

@Override
public void testRenameSchema()
{
// Override because RENAME DATABASE statement isn't supported in version < v20.7.2.30-stable
ebyhr marked this conversation as resolved.
Show resolved Hide resolved
assertThatThrownBy(super::testRenameSchema)
.hasMessageMatching("ClickHouse exception, code: 62,.* Syntax error.*\\n");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.plugin.clickhouse;

import com.google.common.collect.ImmutableMap;
import io.trino.testing.QueryRunner;

import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner;
import static io.trino.plugin.clickhouse.TestingClickHouseServer.ALTINITY_LATEST_IMAGE;

public class TestAltinityLatestConnectorSmokeTest
extends BaseClickHouseConnectorSmokeTest
{
@Override
protected QueryRunner createQueryRunner()
throws Exception
{
return createClickHouseQueryRunner(
closeAfterClass(new TestingClickHouseServer(ALTINITY_LATEST_IMAGE)),
ImmutableMap.of(),
ImmutableMap.<String, String>builder()
.put("clickhouse.map-string-as-varchar", "true") // To handle string types in TPCH tables as varchar instead of varbinary
.buildOrThrow(),
REQUIRED_TPCH_TABLES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected QueryRunner createQueryRunner()
clickHouseServer,
ImmutableMap.of(),
ImmutableMap.<String, String>builder()
.put("clickhouse.map-string-as-varchar", "true")
.put("clickhouse.map-string-as-varchar", "true") // To handle string types in TPCH tables as varchar instead of varbinary
.buildOrThrow(),
REQUIRED_TPCH_TABLES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.trino.testing.QueryRunner;

import static io.trino.plugin.clickhouse.ClickHouseQueryRunner.createClickHouseQueryRunner;
import static io.trino.plugin.clickhouse.TestingClickHouseServer.LATEST_VERSION;
import static io.trino.plugin.clickhouse.TestingClickHouseServer.CLICKHOUSE_LATEST_IMAGE;

public class TestClickHouseLatestConnectorSmokeTest
extends BaseClickHouseConnectorSmokeTest
Expand All @@ -27,10 +27,10 @@ protected QueryRunner createQueryRunner()
throws Exception
{
return createClickHouseQueryRunner(
closeAfterClass(new TestingClickHouseServer(LATEST_VERSION)),
closeAfterClass(new TestingClickHouseServer(CLICKHOUSE_LATEST_IMAGE)),
ImmutableMap.of(),
ImmutableMap.<String, String>builder()
.put("clickhouse.map-string-as-varchar", "true")
.put("clickhouse.map-string-as-varchar", "true") // To handle string types in TPCH tables as varchar instead of varbinary
.buildOrThrow(),
REQUIRED_TPCH_TABLES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,24 @@ public class TestingClickHouseServer
implements Closeable
{
private static final DockerImageName CLICKHOUSE_IMAGE = DockerImageName.parse("yandex/clickhouse-server");
public static final String LATEST_VERSION = "21.11.10.1";
public static final String DEFAULT_VERSION = "20.8";
public static final DockerImageName CLICKHOUSE_LATEST_IMAGE = CLICKHOUSE_IMAGE.withTag("21.11.10.1");
public static final DockerImageName CLICKHOUSE_DEFAULT_IMAGE = CLICKHOUSE_IMAGE.withTag("20.8");

// Altinity Stable Builds Life-Cycle Table https://docs.altinity.com/altinitystablebuilds/#altinity-stable-builds-life-cycle-table
private static final DockerImageName ALTINITY_IMAGE = DockerImageName.parse("altinity/clickhouse-server").asCompatibleSubstituteFor("yandex/clickhouse-server");
public static final DockerImageName ALTINITY_LATEST_IMAGE = ALTINITY_IMAGE.withTag("21.8.13.1.altinitystable");
public static final DockerImageName ALTINITY_DEFAULT_IMAGE = ALTINITY_IMAGE.withTag("20.3.12-aes"); // EOL is 24 June 2022

private final ClickHouseContainer dockerContainer;

public TestingClickHouseServer()
{
this(DEFAULT_VERSION);
this(CLICKHOUSE_DEFAULT_IMAGE);
}

public TestingClickHouseServer(String version)
public TestingClickHouseServer(DockerImageName image)
{
dockerContainer = (ClickHouseContainer) new ClickHouseContainer(CLICKHOUSE_IMAGE.withTag(version))
dockerContainer = (ClickHouseContainer) new ClickHouseContainer(image)
.withCopyFileToContainer(forClasspathResource("custom.xml"), "/etc/clickhouse-server/config.d/custom.xml")
.withStartupAttempts(10);

Expand Down