Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ private String formatRowElement(Object value)
private final Session session;
private final String query;
private boolean ordered;
private boolean skipTypesCheck;

static AssertProvider<QueryAssert> newQueryAssert(String query, QueryRunner runner, Session session)
{
Expand Down Expand Up @@ -277,6 +278,12 @@ public QueryAssert ordered()
return this;
}

public QueryAssert skippingTypesCheck()
{
skipTypesCheck = true;
return this;
}

public QueryAssert matches(@Language("SQL") String query)
{
MaterializedResult expected = runner.execute(session, query);
Expand All @@ -286,7 +293,9 @@ public QueryAssert matches(@Language("SQL") String query)
public QueryAssert matches(MaterializedResult expected)
{
return satisfies(actual -> {
assertTypes(actual, expected.getTypes());
if (!skipTypesCheck) {
assertTypes(actual, expected.getTypes());
}

ListAssert<MaterializedRow> assertion = assertThat(actual.getMaterializedRows())
.as("Rows")
Expand All @@ -310,7 +319,9 @@ public QueryAssert containsAll(@Language("SQL") String query)
public QueryAssert containsAll(MaterializedResult expected)
{
return satisfies(actual -> {
assertTypes(actual, expected.getTypes());
if (!skipTypesCheck) {
assertTypes(actual, expected.getTypes());
}

assertThat(actual.getMaterializedRows())
.as("Rows")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 io.trino.testing.BaseConnectorSmokeTest;

public abstract class BaseJdbcConnectorSmokeTest
extends BaseConnectorSmokeTest {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,118 +14,25 @@
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 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
extends BaseJdbcConnectorSmokeTest
{
private Map<String, String> properties;

@Override
protected QueryRunner createQueryRunner()
throws Exception
{
properties = ImmutableMap.<String, String>builder()
Map<String, String> 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(REQUIRED_TPCH_TABLES, 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);
}

@Override
protected Optional<DataMappingTestSetup> filterCaseSensitiveDataMappingTestData(DataMappingTestSetup dataMappingTestSetup)
{
String typeBaseName = dataMappingTestSetup.getTrinoTypeName().replaceAll("\\([^()]*\\)", "");
switch (typeBaseName) {
case "char":
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
Expand Up @@ -14,14 +14,13 @@
package io.trino.plugin.mysql;

import com.google.common.collect.ImmutableMap;
import io.trino.plugin.jdbc.BaseJdbcConnectorSmokeTest;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.SqlExecutor;

import static io.trino.plugin.mysql.MySqlQueryRunner.createMySqlQueryRunner;

public class TestGlobalTransactionMySqlConnectorTest
// TODO(https://github.com/trinodb/trino/issues/7019) define shorter tests set that exercises various read and write scenarios (a.k.a. "a smoke test")
extends BaseMySqlConnectorTest
public class TestMySqlGlobalTransactionMyConnectorSmokeTest
extends BaseJdbcConnectorSmokeTest
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should it be TestGlobalTransactionMySqlConnectorSmokeTest or TestGlobalTransactionMySqlSmokeTest?
There is Smoke in class name for Oracle.

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.

TestMySqlGlobalTransactionMyConnectorSmokeTest

{
private TestingMySqlServer mysqlServer;

Expand All @@ -32,10 +31,4 @@ protected QueryRunner createQueryRunner()
mysqlServer = closeAfterClass(new TestingMySqlServer(true));
return createMySqlQueryRunner(mysqlServer, ImmutableMap.of(), ImmutableMap.of(), REQUIRED_TPCH_TABLES);
}

@Override
protected SqlExecutor getMySqlExecutor()
{
return mysqlServer::execute;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.oracle;

import io.trino.plugin.jdbc.BaseJdbcConnectorSmokeTest;
import io.trino.testing.TestingConnectorBehavior;
import org.testng.annotations.Test;

import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static org.assertj.core.api.Assertions.assertThat;

public abstract class BaseOracleConnectorSmokeTest
extends BaseJdbcConnectorSmokeTest
{
@Override
protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
{
switch (connectorBehavior) {
case SUPPORTS_CREATE_SCHEMA:
return false;

default:
return super.hasBehavior(connectorBehavior);
}
}

@Test
public void testCommentColumn()
{
String tableName = "test_comment_column_" + randomTableSuffix();

assertUpdate("CREATE TABLE " + tableName + "(a integer)");

// comment set
assertUpdate("COMMENT ON COLUMN " + tableName + ".a IS 'new comment'");
// without remarksReporting (default) Oracle does not return comments set
assertThat((String) computeActual("SHOW CREATE TABLE " + tableName).getOnlyValue()).doesNotContain("COMMENT 'new comment'");

assertUpdate("DROP TABLE " + tableName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
import com.google.common.collect.ImmutableMap;
import io.airlift.testing.Closeables;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.SqlExecutor;
import org.testng.annotations.AfterClass;

import java.io.IOException;

import static io.trino.plugin.oracle.TestingOracleServer.TEST_PASS;
import static io.trino.plugin.oracle.TestingOracleServer.TEST_USER;

public class TestRemarksReportingOraclePoolConnectorTest
extends BaseOracleConnectorTest
public class TestOraclePoolConnectorSmokeTest
extends BaseOracleConnectorSmokeTest
{
private TestingOracleServer oracleServer;

Expand All @@ -43,7 +42,7 @@ protected QueryRunner createQueryRunner()
.put("connection-password", TEST_PASS)
.put("allow-drop-table", "true")
.put("oracle.connection-pool.enabled", "true")
.put("oracle.remarks-reporting.enabled", "true")
.put("oracle.remarks-reporting.enabled", "false")
.build(),
REQUIRED_TPCH_TABLES);
}
Expand All @@ -55,10 +54,4 @@ public final void destroy()
Closeables.closeAll(oracleServer);
oracleServer = null;
}

@Override
protected SqlExecutor onOracle()
{
return oracleServer::execute;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.google.common.collect.ImmutableMap;
import io.airlift.testing.Closeables;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.SqlExecutor;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

Expand All @@ -27,8 +26,8 @@
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static org.assertj.core.api.Assertions.assertThat;

public class TestOraclePoolConnectorTest
extends BaseOracleConnectorTest
public class TestOraclePoolRemarksReportingConnectorSmokeTest
extends BaseOracleConnectorSmokeTest
{
private TestingOracleServer oracleServer;

Expand All @@ -46,7 +45,7 @@ protected QueryRunner createQueryRunner()
.put("connection-password", TEST_PASS)
.put("allow-drop-table", "true")
.put("oracle.connection-pool.enabled", "true")
.put("oracle.remarks-reporting.enabled", "false")
.put("oracle.remarks-reporting.enabled", "true")
.build(),
REQUIRED_TPCH_TABLES);
}
Expand All @@ -69,13 +68,9 @@ public void testCommentColumn()

// comment set
assertUpdate("COMMENT ON COLUMN " + tableName + ".a IS 'new comment'");
// without remarksReporting Oracle does not return comments set
assertThat((String) computeActual("SHOW CREATE TABLE " + tableName).getOnlyValue()).doesNotContain("COMMENT 'new comment'");
}
// with remarksReporting Oracle does not return comments set
assertThat((String) computeActual("SHOW CREATE TABLE " + tableName).getOnlyValue()).contains("COMMENT 'new comment'");

@Override
protected SqlExecutor onOracle()
{
return oracleServer::execute;
assertUpdate("DROP TABLE " + tableName);
}
}
Loading