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

Introduce BaseConnectorTest, merging AbstractTestDistributedQueries and AbstractTestIntegrationSmokeTest #6989

Merged
merged 7 commits into from
Feb 23, 2021
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
import static org.assertj.core.api.Assertions.assertThat;

public class TestAccumuloIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
@Override
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* 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.jdbc;

import com.google.common.collect.ImmutableMap;
import io.trino.testing.AbstractTestDistributedQueries;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.JdbcSqlExecutor;
import io.trino.testing.sql.TestTable;
import io.trino.tpch.TpchTable;
import org.testng.SkipException;

import java.util.Map;
import java.util.Optional;
import java.util.Properties;

import static io.trino.plugin.jdbc.H2QueryRunner.createH2QueryRunner;

public class TestJdbcCachingQueries
// TODO define shorter tests set that exercises various read and write scenarios (a.k.a. "a smoke test")
extends AbstractTestDistributedQueries
{
private Map<String, String> properties;

@Override
protected QueryRunner createQueryRunner()
throws Exception
{
properties = ImmutableMap.<String, String>builder()
.putAll(TestingH2JdbcModule.createProperties())
.put("metadata.cache-ttl", "10m")
.put("metadata.cache-missing", "true")
.put("allow-drop-table", "true")
.build();
return createH2QueryRunner(TpchTable.getTables(), properties);
}

@Override
protected boolean supportsDelete()
{
return false;
}

@Override
protected boolean supportsViews()
{
return false;
}

@Override
protected boolean supportsArrays()
{
return false;
}

@Override
protected boolean supportsCommentOnTable()
{
return false;
}

@Override
protected boolean supportsCommentOnColumn()
{
return false;
}

@Override
public void testLargeIn(int valuesCount)
{
throw new SkipException("This test should pass with H2, but takes too long (currently over a mninute) and is not that important");
}

@Override
protected TestTable createTableWithDefaultColumns()
{
return new TestTable(
getSqlExecutor(),
"tpch.table",
"(col_required BIGINT NOT NULL," +
"col_nullable BIGINT," +
"col_default BIGINT DEFAULT 43," +
"col_nonnull_default BIGINT NOT NULL DEFAULT 42," +
"col_required2 BIGINT NOT NULL)");
}

@Override
protected Optional<DataMappingTestSetup> filterDataMappingSmokeTestData(DataMappingTestSetup dataMappingTestSetup)
{
String typeBaseName = dataMappingTestSetup.getTrinoTypeName().replaceAll("\\([^()]*\\)", "");
switch (typeBaseName) {
case "boolean":
case "decimal":
case "char":
case "varbinary":
case "time":
case "timestamp":
case "timestamp with time zone":
return Optional.of(dataMappingTestSetup.asUnsupported());
}

return Optional.of(dataMappingTestSetup);
}

private JdbcSqlExecutor getSqlExecutor()
{
return new JdbcSqlExecutor(properties.get("connection-url"), new Properties());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* 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.jdbc;

import com.google.common.collect.ImmutableMap;
import io.trino.testing.BaseConnectorTest;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.JdbcSqlExecutor;
import io.trino.testing.sql.TestTable;
import io.trino.tpch.TpchTable;
import org.testng.SkipException;

import java.util.Map;
import java.util.Optional;
import java.util.Properties;

import static io.trino.plugin.jdbc.H2QueryRunner.createH2QueryRunner;

public class TestJdbcConnectorTest
extends BaseConnectorTest
{
private Map<String, String> properties;

@Override
protected QueryRunner createQueryRunner()
throws Exception
{
properties = ImmutableMap.<String, String>builder()
.putAll(TestingH2JdbcModule.createProperties())
.put("allow-drop-table", "true")
.build();
return createH2QueryRunner(TpchTable.getTables(), properties);
}

@Override
protected boolean supportsDelete()
{
return false;
}

@Override
protected boolean supportsViews()
{
return false;
}

@Override
protected boolean supportsArrays()
{
return false;
}

@Override
protected boolean supportsCommentOnTable()
{
return false;
}

@Override
protected boolean supportsCommentOnColumn()
{
return false;
}

@Override
public void testLargeIn(int valuesCount)
{
throw new SkipException("This test should pass with H2, but takes too long (currently over a mninute) and is not that important");
}

@Override
protected TestTable createTableWithDefaultColumns()
{
return new TestTable(
getSqlExecutor(),
"tpch.table",
"(col_required BIGINT NOT NULL," +
"col_nullable BIGINT," +
"col_default BIGINT DEFAULT 43," +
"col_nonnull_default BIGINT NOT NULL DEFAULT 42," +
"col_required2 BIGINT NOT NULL)");
}

@Override
protected Optional<DataMappingTestSetup> filterDataMappingSmokeTestData(DataMappingTestSetup dataMappingTestSetup)
{
String typeBaseName = dataMappingTestSetup.getTrinoTypeName().replaceAll("\\([^()]*\\)", "");
switch (typeBaseName) {
case "boolean":
case "decimal":
case "char":
case "varbinary":
case "time":
case "timestamp":
case "timestamp with time zone":
return Optional.of(dataMappingTestSetup.asUnsupported());
}

return Optional.of(dataMappingTestSetup);
}

private JdbcSqlExecutor getSqlExecutor()
{
return new JdbcSqlExecutor(properties.get("connection-url"), new Properties());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
import static java.lang.String.format;

public class TestJdbcIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private final Map<String, String> properties = TestingH2JdbcModule.createProperties();
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@

@Test
public class TestBigQueryIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private BigQuerySqlExecutor bigQuerySqlExecutor;
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@
import static org.testng.Assert.assertEquals;

public class TestCassandraIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private static final String KEYSPACE = "smoke_test";
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import static org.assertj.core.api.Assertions.assertThat;

public abstract class BaseDruidIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
protected static final String SELECT_FROM_ORDERS = "SELECT " +
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@
import static org.testng.Assert.assertTrue;

public abstract class BaseElasticsearchSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private final String image;
Original file line number Diff line number Diff line change
@@ -163,6 +163,7 @@
import static org.testng.FileAssert.assertFile;

public class TestHiveIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private static final DateTimeFormatter TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSSSS");
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@
import static org.testng.Assert.assertTrue;

public abstract class AbstractTestIcebergSmoke
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private static final Pattern WITH_CLAUSE_EXTRACTER = Pattern.compile(".*(WITH\\s*\\([^)]*\\))\\s*$", Pattern.DOTALL);
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@
import static org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG;

public class TestKafkaIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private TestingKafka testingKafka;
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
import static org.testng.Assert.assertTrue;

public abstract class AbstractKuduIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private TestingKuduServer kuduServer;
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
import static org.testng.Assert.assertTrue;

public class TestMemSqlIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
protected TestingMemSqlServer memSqlServer;
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@

@Test(singleThreaded = true)
public class TestMongoIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private MongoServer server;
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import static org.testng.Assert.assertTrue;

abstract class BaseMySqlIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
protected TestingMySqlServer mysqlServer;
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
import static org.testng.Assert.assertTrue;

public abstract class BaseOracleIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
@Test
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
import static org.testng.Assert.fail;

public class TestPhoenixIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
private TestingPhoenixServer testingPhoenixServer;
Original file line number Diff line number Diff line change
@@ -20,9 +20,11 @@
import io.trino.sql.planner.plan.FilterNode;
import io.trino.sql.planner.plan.MarkDistinctNode;
import io.trino.sql.planner.plan.ProjectNode;
import io.trino.testing.AbstractTestIntegrationSmokeTest;
import io.trino.testing.BaseConnectorTest;
Copy link
Member

Choose a reason for hiding this comment

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

nit: commit summary to long in Merge TestPostgreSql...

import io.trino.testing.QueryRunner;
import io.trino.testing.sql.JdbcSqlExecutor;
import io.trino.testing.sql.TestTable;
import io.trino.tpch.TpchTable;
import org.intellij.lang.annotations.Language;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -31,17 +33,12 @@
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static io.trino.SystemSessionProperties.USE_MARK_DISTINCT;
import static io.trino.plugin.postgresql.PostgreSqlQueryRunner.createPostgreSqlQueryRunner;
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static io.trino.tpch.TpchTable.CUSTOMER;
import static io.trino.tpch.TpchTable.NATION;
import static io.trino.tpch.TpchTable.ORDERS;
import static io.trino.tpch.TpchTable.REGION;
import static java.lang.String.format;
import static java.util.stream.Collectors.joining;
import static java.util.stream.IntStream.range;
@@ -50,8 +47,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

public class TestPostgreSqlIntegrationSmokeTest
extends AbstractTestIntegrationSmokeTest
public class TestPostgreSqlConnectorTest
extends BaseConnectorTest
{
protected TestingPostgreSqlServer postgreSqlServer;

@@ -64,7 +61,7 @@ protected QueryRunner createQueryRunner()
postgreSqlServer.close();
postgreSqlServer = null;
});
return createPostgreSqlQueryRunner(postgreSqlServer, Map.of(), Map.of(), List.of(CUSTOMER, NATION, ORDERS, REGION));
return createPostgreSqlQueryRunner(postgreSqlServer, Map.of(), Map.of(), TpchTable.getTables());
}

@BeforeClass
@@ -74,6 +71,44 @@ public void setExtensions()
execute("CREATE EXTENSION file_fdw");
}

@Override
protected boolean supportsDelete()
{
return false;
}

@Override
protected boolean supportsViews()
{
return false;
}

@Override
protected boolean supportsArrays()
{
// Arrays are supported conditionally. Check the defaults.
return new PostgreSqlConfig().getArrayMapping() != PostgreSqlConfig.ArrayMapping.DISABLED;
}

@Override
protected boolean supportsCommentOnTable()
{
return false;
}

@Override
protected TestTable createTableWithDefaultColumns()
{
return new TestTable(
new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties()),
"tpch.table",
"(col_required BIGINT NOT NULL," +
"col_nullable BIGINT," +
"col_default BIGINT DEFAULT 43," +
"col_nonnull_default BIGINT NOT NULL DEFAULT 42," +
"col_required2 BIGINT NOT NULL)");
}

@Test
public void testDropTable()
{
@@ -84,16 +119,6 @@ public void testDropTable()
assertFalse(getQueryRunner().tableExists(getSession(), "test_drop"));
}

@Test
public void testInsert()
throws Exception
{
execute("CREATE TABLE tpch.test_insert (x bigint, y varchar(100))");
assertUpdate("INSERT INTO test_insert VALUES (123, 'test')", 1);
assertQuery("SELECT * FROM test_insert", "SELECT 123 x, 'test' y");
assertUpdate("DROP TABLE test_insert");
}

@Test
public void testInsertInPresenceOfNotSupportedColumn()
throws Exception

This file was deleted.

Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@
import static org.testng.Assert.assertNotNull;

public class TestRaptorIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
@Override
Original file line number Diff line number Diff line change
@@ -15,15 +15,15 @@

import com.google.common.collect.ImmutableMap;
import io.trino.plugin.redis.util.RedisServer;
import io.trino.testing.AbstractTestQueries;
import io.trino.testing.BaseConnectorTest;
import io.trino.testing.QueryRunner;
import io.trino.tpch.TpchTable;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

@Test
public class TestRedisDistributed
extends AbstractTestQueries
import static io.trino.plugin.redis.RedisQueryRunner.createRedisQueryRunner;

public class TestRedisConnectorTest
extends BaseConnectorTest
{
private RedisServer redisServer;

@@ -32,12 +32,60 @@ protected QueryRunner createQueryRunner()
throws Exception
{
redisServer = new RedisServer();
return RedisQueryRunner.createRedisQueryRunner(redisServer, ImmutableMap.of(), "string", TpchTable.getTables());
return createRedisQueryRunner(redisServer, ImmutableMap.of(), "string", TpchTable.getTables());
}

@AfterClass(alwaysRun = true)
public void destroy()
{
redisServer.close();
}

@Override
protected boolean supportsCreateSchema()
{
return false;
}

@Override
protected boolean supportsCreateTable()
{
return false;
}

@Override
protected boolean supportsInsert()
{
return false;
}

@Override
protected boolean supportsDelete()
{
return false;
}

@Override
protected boolean supportsViews()
{
return false;
}

@Override
protected boolean supportsArrays()
{
return false;
}

@Override
protected boolean supportsCommentOnTable()
{
return false;
}

@Override
protected boolean supportsCommentOnColumn()
{
return false;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@
import static org.testng.Assert.assertTrue;

public class TestSqlServerIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
protected TestingSqlServer sqlServer;
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
import static io.trino.testing.QueryAssertions.assertContains;

public class TestThriftIntegrationSmokeTest
// TODO extend BaseConnectorTest
extends AbstractTestIntegrationSmokeTest
{
@Override
Original file line number Diff line number Diff line change
@@ -66,11 +66,28 @@
/**
* Generic test for connectors exercising connector's read and write capabilities.
*
* @see AbstractTestIntegrationSmokeTest
* @see BaseConnectorTest
* @deprecated Extend {@link BaseConnectorTest} instead.
*/
@Deprecated
public abstract class AbstractTestDistributedQueries
extends AbstractTestQueries
{
protected boolean supportsCreateSchema()
{
return true;
}

protected boolean supportsCreateTable()
{
return true;
}

protected boolean supportsInsert()
{
return true;
}

protected boolean supportsDelete()
{
return true;
@@ -159,6 +176,11 @@ public void testResetSession()
public void testCreateTable()
{
String tableName = "test_create_" + randomTableSuffix();
if (!supportsCreateTable()) {
assertQueryFails("CREATE TABLE " + tableName + " (a bigint, b double, c varchar)", "This connector does not support creating tables");
return;
}

assertUpdate("CREATE TABLE " + tableName + " (a bigint, b double, c varchar)");
assertTrue(getQueryRunner().tableExists(getSession(), tableName));
assertTableColumnNames(tableName, "a", "b", "c");
@@ -204,6 +226,10 @@ public void testCreateTable()
public void testCreateTableAsSelect()
{
String tableName = "test_ctas" + randomTableSuffix();
if (!supportsCreateTable()) {
assertQueryFails("CREATE TABLE IF NOT EXISTS " + tableName + " AS SELECT name, regionkey FROM nation", "This connector does not support creating tables with data");
return;
}
assertUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " AS SELECT name, regionkey FROM nation", "SELECT count(*) FROM nation");
assertTableColumnNames(tableName, "name", "regionkey");
assertUpdate("DROP TABLE " + tableName);
@@ -294,6 +320,8 @@ protected void assertCreateTableAsSelect(Session session, @Language("SQL") Strin
@Test
public void testRenameTable()
{
skipTestUnless(supportsCreateTable());

String tableName = "test_rename_" + randomTableSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT 123 x", 1);

@@ -324,14 +352,12 @@ public void testRenameTable()
@Test
public void testCommentTable()
{
String tableName = "test_comment_" + randomTableSuffix();
if (!supportsCommentOnTable()) {
assertUpdate("CREATE TABLE " + tableName + "(a integer)");
assertQueryFails("COMMENT ON TABLE " + tableName + " IS 'new comment'", "This connector does not support setting table comments");
assertUpdate("DROP TABLE " + tableName);
assertQueryFails("COMMENT ON TABLE nation IS 'new comment'", "This connector does not support setting table comments");
return;
}

String tableName = "test_comment_" + randomTableSuffix();
assertUpdate("CREATE TABLE " + tableName + "(a integer)");

// comment set
@@ -375,14 +401,12 @@ private String getTableComment(String tableName)
@Test
public void testCommentColumn()
{
String tableName = "test_comment_column_" + randomTableSuffix();
if (!supportsCommentOnColumn()) {
assertUpdate("CREATE TABLE " + tableName + "(a integer)");
assertQueryFails("COMMENT ON COLUMN " + tableName + ".a IS 'new comment'", "This connector does not support setting column comments");
assertUpdate("DROP TABLE " + tableName);
assertQueryFails("COMMENT ON COLUMN nation.nationkey IS 'new comment'", "This connector does not support setting column comments");
return;
}

String tableName = "test_comment_column_" + randomTableSuffix();
assertUpdate("CREATE TABLE " + tableName + "(a integer)");

// comment set
@@ -425,6 +449,8 @@ private String getColumnComment(String tableName, String columnName)
@Test
public void testRenameColumn()
{
skipTestUnless(supportsCreateTable());

String tableName = "test_rename_column_" + randomTableSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT 'some value' x", 1);

@@ -456,6 +482,8 @@ public void testRenameColumn()
@Test
public void testDropColumn()
{
skipTestUnless(supportsCreateTable());

String tableName = "test_drop_column_" + randomTableSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT 123 x, 456 y, 111 a", 1);

@@ -478,6 +506,8 @@ public void testDropColumn()
@Test
public void testAddColumn()
{
skipTestUnless(supportsCreateTable());

String tableName = "test_add_column_" + randomTableSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT CAST('first' AS varchar) x", 1);

@@ -514,6 +544,11 @@ public void testAddColumn()
@Test
public void testInsert()
{
if (!supportsInsert()) {
assertQueryFails("INSERT INTO nation(nationkey) VALUES (42)", "This connector does not support inserts");
return;
}

String query = "SELECT phone, custkey, acctbal FROM customer";

String tableName = "test_insert_" + randomTableSuffix();
@@ -554,6 +589,8 @@ public void testInsert()
@Test
public void testInsertUnicode()
{
skipTestUnless(supportsInsert());

String tableName = "test_insert_unicode_" + randomTableSuffix();

assertUpdate("CREATE TABLE " + tableName + "(test varchar)");
@@ -584,6 +621,8 @@ public void testInsertUnicode()
@Test
public void testInsertArray()
{
skipTestUnless(supportsInsert());

String tableName = "test_insert_array_" + randomTableSuffix();
if (!supportsArrays()) {
assertThatThrownBy(() -> query("CREATE TABLE " + tableName + " (a array(bigint))"))
@@ -604,18 +643,15 @@ public void testInsertArray()
@Test
public void testDelete()
{
// delete half the table, then delete the rest
String tableName = "test_delete_" + randomTableSuffix();

if (!supportsDelete()) {
assertUpdate("CREATE TABLE " + tableName + " AS SELECT * FROM orders WITH NO DATA", 0);
assertQueryFails("DELETE FROM " + tableName, "This connector does not support deletes");
assertUpdate("DROP TABLE " + tableName);
assertQueryFails("DELETE FROM nation", "This connector does not support deletes");
return;
}

String tableName = "test_delete_" + randomTableSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT * FROM orders", "SELECT count(*) FROM orders");

// delete half the table, then delete the rest
assertUpdate("DELETE FROM " + tableName + " WHERE orderkey % 2 = 0", "SELECT count(*) FROM orders WHERE orderkey % 2 = 0");
assertQuery("SELECT * FROM " + tableName, "SELECT * FROM orders WHERE orderkey % 2 <> 0");

@@ -956,6 +992,8 @@ public void testShowCreateView()
@Test
public void testQueryLoggingCount()
{
skipTestUnless(supportsCreateTable());

QueryManager queryManager = getDistributedQueryRunner().getCoordinator().getQueryManager();
executeExclusively(() -> {
assertEventually(
@@ -1011,9 +1049,12 @@ public void testShowSchemasFromOther()
assertTrue(result.getOnlyColumnAsSet().containsAll(ImmutableSet.of(INFORMATION_SCHEMA, "tiny", "sf1")));
}

// TODO move to to engine-only
@Test
public void testSymbolAliasing()
{
skipTestUnless(supportsCreateTable());

String tableName = "test_symbol_aliasing" + randomTableSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT 1 foo_1, 2 foo_2_4", 1);
assertQuery("SELECT foo_1, foo_2_4 FROM " + tableName, "SELECT 1, 2");
@@ -1024,6 +1065,9 @@ public void testSymbolAliasing()
@Flaky(issue = "https://github.com/trinodb/trino/issues/5172", match = "AssertionError: expected \\[.*\\] but found \\[.*\\]")
public void testWrittenStats()
{
skipTestUnless(supportsCreateTable());
skipTestUnless(supportsInsert());

String tableName = "test_written_stats_" + randomTableSuffix();
String sql = "CREATE TABLE " + tableName + " AS SELECT * FROM nation";
ResultWithQueryId<MaterializedResult> resultResultWithQueryId = getDistributedQueryRunner().executeWithQueryId(getSession(), sql);
@@ -1048,6 +1092,10 @@ public void testWrittenStats()
public void testCreateSchema()
{
String schemaName = "test_schema_create_" + randomTableSuffix();
if (!supportsCreateSchema()) {
assertQueryFails("CREATE SCHEMA " + schemaName, "This connector does not support creating schemas");
return;
}
assertThat(computeActual("SHOW SCHEMAS").getOnlyColumnAsSet()).doesNotContain(schemaName);
assertUpdate("CREATE SCHEMA " + schemaName);
assertThat(computeActual("SHOW SCHEMAS").getOnlyColumnAsSet()).contains(schemaName);
@@ -1059,6 +1107,8 @@ public void testCreateSchema()
@Test
public void testInsertForDefaultColumn()
{
skipTestUnless(supportsInsert());

try (TestTable testTable = createTableWithDefaultColumns()) {
assertUpdate(format("INSERT INTO %s (col_required, col_required2) VALUES (1, 10)", testTable.getName()), 1);
assertUpdate(format("INSERT INTO %s VALUES (2, 3, 4, 5, 6)", testTable.getName()), 1);
@@ -1069,11 +1119,16 @@ public void testInsertForDefaultColumn()
}
}

protected abstract TestTable createTableWithDefaultColumns();
protected TestTable createTableWithDefaultColumns()
{
throw new UnsupportedOperationException();
}

@Test(dataProvider = "testColumnNameDataProvider")
public void testColumnName(String columnName)
{
skipTestUnless(supportsCreateTable());

if (!requiresDelimiting(columnName)) {
testColumnName(columnName, false);
}
@@ -1173,6 +1228,8 @@ protected String dataMappingTableName(String trinoTypeName)
@Test(dataProvider = "testDataMappingSmokeTestDataProvider")
public void testDataMappingSmokeTest(DataMappingTestSetup dataMappingTestSetup)
{
skipTestUnless(supportsCreateTable());

String trinoTypeName = dataMappingTestSetup.getTrinoTypeName();
String sampleValueLiteral = dataMappingTestSetup.getSampleValueLiteral();
String highValueLiteral = dataMappingTestSetup.getHighValueLiteral();
Original file line number Diff line number Diff line change
@@ -32,12 +32,9 @@
import static org.testng.Assert.assertTrue;

/**
* Generic test for connectors exercising connector's read capabilities.
* This is also the base class for connector-specific tests (not generic),
* regardless whether they exercise read-only or read-write capabilities.
*
* @see AbstractTestDistributedQueries
* @deprecated Use {@link BaseConnectorTest} instead.
*/
@Deprecated
public abstract class AbstractTestIntegrationSmokeTest
extends AbstractTestQueryFramework
{
Original file line number Diff line number Diff line change
@@ -902,7 +902,7 @@ public void testScalarSubquery()
}

@Test
public void testPredicatePushdown()
public void testPredicate()
{
assertQuery("" +
"SELECT *\n" +

Large diffs are not rendered by default.