diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorSmokeTest.java new file mode 100644 index 000000000000..460a158e7977 --- /dev/null +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseConnectorSmokeTest.java @@ -0,0 +1,33 @@ +/* + * 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 io.trino.plugin.jdbc.BaseJdbcConnectorSmokeTest; +import io.trino.testing.TestingConnectorBehavior; + +public abstract class BaseClickHouseConnectorSmokeTest + extends BaseJdbcConnectorSmokeTest +{ + @Override + protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) + { + switch (connectorBehavior) { + case SUPPORTS_RENAME_SCHEMA: + case SUPPORTS_DELETE: + return false; + default: + return super.hasBehavior(connectorBehavior); + } + } +} diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java index 1233ae8b8f2f..ca59a48e54c3 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/ClickHouseQueryRunner.java @@ -61,6 +61,7 @@ public static DistributedQueryRunner createClickHouseQueryRunner( connectorProperties = new HashMap<>(ImmutableMap.copyOf(connectorProperties)); connectorProperties.putIfAbsent("connection-url", server.getJdbcUrl()); + connectorProperties.putIfAbsent("allow-drop-table", "true"); queryRunner.installPlugin(new ClickHousePlugin()); queryRunner.createCatalog("clickhouse", "clickhouse", connectorProperties); diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java new file mode 100644 index 000000000000..0765947504f9 --- /dev/null +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorSmokeTest.java @@ -0,0 +1,36 @@ +/* + * 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; + +public class TestClickHouseConnectorSmokeTest + extends BaseClickHouseConnectorSmokeTest +{ + @Override + protected QueryRunner createQueryRunner() + throws Exception + { + return createClickHouseQueryRunner( + closeAfterClass(new TestingClickHouseServer()), + ImmutableMap.of(), + ImmutableMap.builder() + .put("clickhouse.map-string-as-varchar", "true") + .build(), + REQUIRED_TPCH_TABLES); + } +} diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java index 175429264494..74ce54884fd8 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java @@ -64,7 +64,6 @@ protected QueryRunner createQueryRunner() ImmutableMap.of(), ImmutableMap.builder() .put("clickhouse.map-string-as-varchar", "true") - .put("allow-drop-table", "true") .build(), REQUIRED_TPCH_TABLES); } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java new file mode 100644 index 000000000000..ee09805389fd --- /dev/null +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorSmokeTest.java @@ -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.LATEST_VERSION; + +public class TestClickHouseLatestConnectorSmokeTest + extends BaseClickHouseConnectorSmokeTest +{ + @Override + protected QueryRunner createQueryRunner() + throws Exception + { + return createClickHouseQueryRunner( + closeAfterClass(new TestingClickHouseServer(LATEST_VERSION)), + ImmutableMap.of(), + ImmutableMap.builder() + .put("clickhouse.map-string-as-varchar", "true") + .build(), + REQUIRED_TPCH_TABLES); + } +} diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java index f557271ea086..5abf907da696 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java @@ -105,7 +105,6 @@ protected QueryRunner createQueryRunner() ImmutableMap.builder() .put("metadata.cache-ttl", "10m") .put("metadata.cache-missing", "true") - .put("allow-drop-table", "true") .build(), ImmutableList.of()); } diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java index 7bf507169145..117831a3719d 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java @@ -14,6 +14,7 @@ package io.trino.plugin.clickhouse; import org.testcontainers.containers.ClickHouseContainer; +import org.testcontainers.utility.DockerImageName; import java.io.Closeable; import java.sql.Connection; @@ -27,13 +28,19 @@ public class TestingClickHouseServer implements Closeable { - private static final String CLICKHOUSE_IMAGE = "yandex/clickhouse-server:20.8"; + 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"; private final ClickHouseContainer dockerContainer; public TestingClickHouseServer() { - // Use 2nd stable version - dockerContainer = (ClickHouseContainer) new ClickHouseContainer(CLICKHOUSE_IMAGE) + this(DEFAULT_VERSION); + } + + public TestingClickHouseServer(String version) + { + dockerContainer = (ClickHouseContainer) new ClickHouseContainer(CLICKHOUSE_IMAGE.withTag(version)) .withCopyFileToContainer(forClasspathResource("custom.xml"), "/etc/clickhouse-server/config.d/custom.xml") .withStartupAttempts(10);