From d4b697e4f6f964b0c5daa246e53653fd941f7767 Mon Sep 17 00:00:00 2001 From: chenjian2664 Date: Tue, 17 Dec 2024 16:59:30 +0800 Subject: [PATCH] Upgrade oracle test version --- .../plugin/jdbc/BaseJdbcConnectorTest.java | 12 ++++------ .../oracle/BaseOracleConnectorTest.java | 6 ++--- .../plugin/oracle/TestingOracleServer.java | 6 ++--- .../trino-oracle/src/test/resources/init.sql | 1 + .../src/test/resources/restart.sh | 4 ++++ .../trino/testing/BaseConnectorSmokeTest.java | 3 +-- .../io/trino/testing/BaseConnectorTest.java | 22 ++++++------------- 7 files changed, 23 insertions(+), 31 deletions(-) diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java index 59e9c9d75f5e..01e73b200d46 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcConnectorTest.java @@ -1909,8 +1909,7 @@ public void testConstantUpdateWithVarcharGreaterAndLowerPredicate() public void testDeleteWithBigintEqualityPredicate() { skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE) && hasBehavior(SUPPORTS_ROW_LEVEL_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_delete_bigint", "AS SELECT * FROM region")) { + try (TestTable table = new TestTable(getQueryRunner()::execute, "test_delete_with_bigint_equality_predicate", "AS SELECT * FROM region")) { assertUpdate("DELETE FROM " + table.getName() + " WHERE regionkey = 1", 1); assertQuery( "SELECT regionkey, name FROM " + table.getName(), @@ -1926,8 +1925,7 @@ public void testDeleteWithBigintEqualityPredicate() public void testDeleteWithVarcharEqualityPredicate() { skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE) && hasBehavior(SUPPORTS_ROW_LEVEL_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_delete_varchar", "(col varchar(1))", ImmutableList.of("'a'", "'A'", "null"))) { + try (TestTable table = new TestTable(getQueryRunner()::execute, "test_delete_varchar_equality_predicate", "(col varchar(1))", ImmutableList.of("'a'", "'A'", "null"))) { if (!hasBehavior(SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_EQUALITY)) { assertQueryFails("DELETE FROM " + table.getName() + " WHERE col = 'A'", MODIFYING_ROWS_MESSAGE); return; @@ -1942,8 +1940,7 @@ public void testDeleteWithVarcharEqualityPredicate() public void testDeleteWithVarcharInequalityPredicate() { skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE) && hasBehavior(SUPPORTS_ROW_LEVEL_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = createTestTableForWrites("test_delete_varchar", "(col varchar(1), pk int)", ImmutableList.of("'a', 0", "'A', 1", "null, 2"), "pk")) { + try (TestTable table = createTestTableForWrites("test_delete_with_varchar_inequality", "(col varchar(1), pk int)", ImmutableList.of("'a', 0", "'A', 1", "null, 2"), "pk")) { if (!hasBehavior(SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY) && !hasBehavior(SUPPORTS_MERGE)) { assertQueryFails("DELETE FROM " + table.getName() + " WHERE col != 'A'", MODIFYING_ROWS_MESSAGE); return; @@ -1958,8 +1955,7 @@ public void testDeleteWithVarcharInequalityPredicate() public void testDeleteWithVarcharGreaterAndLowerPredicate() { skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE) && hasBehavior(SUPPORTS_ROW_LEVEL_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = createTestTableForWrites("test_delete_varchar", "(col varchar(1), pk int)", ImmutableList.of("'0', 0", "'a', 1", "'A', 2", "'b', 3", "null, 4"), "pk")) { + try (TestTable table = createTestTableForWrites("test_delete_varchar_greater_lower_predicate", "(col varchar(1), pk int)", ImmutableList.of("'0', 0", "'a', 1", "'A', 2", "'b', 3", "null, 4"), "pk")) { if (!hasBehavior(SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY) && !hasBehavior(SUPPORTS_MERGE)) { assertQueryFails("DELETE FROM " + table.getName() + " WHERE col < 'A'", MODIFYING_ROWS_MESSAGE); assertQueryFails("DELETE FROM " + table.getName() + " WHERE col > 'A'", MODIFYING_ROWS_MESSAGE); diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java index b85473807bf6..98fd6033c731 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java @@ -446,7 +446,7 @@ protected void verifyConcurrentAddColumnFailurePermissible(Exception e) @Override protected OptionalInt maxSchemaNameLength() { - return OptionalInt.of(30); + return OptionalInt.of(128); } @Override @@ -458,7 +458,7 @@ protected void verifySchemaNameLengthFailurePermissible(Throwable e) @Override protected OptionalInt maxTableNameLength() { - return OptionalInt.of(30); + return OptionalInt.of(128); } @Override @@ -470,7 +470,7 @@ protected void verifyTableNameLengthFailurePermissible(Throwable e) @Override protected OptionalInt maxColumnNameLength() { - return OptionalInt.of(30); + return OptionalInt.of(128); } @Override diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestingOracleServer.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestingOracleServer.java index 8b089c5ce314..20ec1195eb3c 100644 --- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestingOracleServer.java +++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestingOracleServer.java @@ -73,11 +73,10 @@ public TestingOracleServer() private void createContainer() { - OracleContainer container = new OracleContainer("gvenzl/oracle-xe:11.2.0.2-full") + OracleContainer container = new OracleContainer("gvenzl/oracle-xe:18.4.0-slim") .withCopyFileToContainer(MountableFile.forClasspathResource("init.sql"), "/container-entrypoint-initdb.d/01-init.sql") .withCopyFileToContainer(MountableFile.forClasspathResource("restart.sh"), "/container-entrypoint-initdb.d/02-restart.sh") - .withCopyFileToContainer(MountableFile.forHostPath(createConfigureScript()), "/container-entrypoint-initdb.d/03-create-users.sql") - .usingSid(); + .withCopyFileToContainer(MountableFile.forHostPath(createConfigureScript()), "/container-entrypoint-initdb.d/03-create-users.sql"); try { this.cleanup = startOrReuse(container); this.container = container; @@ -95,6 +94,7 @@ private Path createConfigureScript() File tempFile = File.createTempFile("init-", ".sql"); Files.write(Joiner.on("\n").join( + "ALTER SESSION SET CONTAINER = XEPDB1;", format("CREATE TABLESPACE %s DATAFILE 'test_db.dat' SIZE 100M ONLINE;", TEST_TABLESPACE), format("CREATE USER %s IDENTIFIED BY %s DEFAULT TABLESPACE %s;", TEST_USER, TEST_PASS, TEST_TABLESPACE), format("GRANT UNLIMITED TABLESPACE TO %s;", TEST_USER), diff --git a/plugin/trino-oracle/src/test/resources/init.sql b/plugin/trino-oracle/src/test/resources/init.sql index 3d948b303b64..2c683fa5dce0 100644 --- a/plugin/trino-oracle/src/test/resources/init.sql +++ b/plugin/trino-oracle/src/test/resources/init.sql @@ -6,3 +6,4 @@ to fix this we have to change the number of processes of SPFILE */ ALTER SYSTEM SET processes=1000 SCOPE=SPFILE; ALTER SYSTEM SET disk_asynch_io = FALSE SCOPE = SPFILE; +ALTER SYSTEM SET audit_trail=NONE SCOPE=SPFILE; diff --git a/plugin/trino-oracle/src/test/resources/restart.sh b/plugin/trino-oracle/src/test/resources/restart.sh index 1b62c9040cee..c8b842abb999 100755 --- a/plugin/trino-oracle/src/test/resources/restart.sh +++ b/plugin/trino-oracle/src/test/resources/restart.sh @@ -2,6 +2,10 @@ echo "Restarting ORACLE" +# Disable listener logging by editing listener.ora +sed -i '/^LOGGING_LISTENER/d' $ORACLE_HOME/network/admin/listener.ora +echo "LOGGING_LISTENER = OFF" >> $ORACLE_HOME/network/admin/listener.ora + lsnrctl reload && \ sqlplus -s / as sysdba << EOF -- Exit on any errors diff --git a/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorSmokeTest.java b/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorSmokeTest.java index b491e6ab375c..7c9157f0e8ff 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorSmokeTest.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorSmokeTest.java @@ -277,8 +277,7 @@ public void testDeleteAllDataFromTable() public void testRowLevelDelete() { assumeTrue(hasBehavior(SUPPORTS_CREATE_TABLE) && hasBehavior(SUPPORTS_ROW_LEVEL_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_row_delete", "AS SELECT * FROM region")) { + try (TestTable table = new TestTable(getQueryRunner()::execute, "test_row_level_delete", "AS SELECT * FROM region")) { assertUpdate("DELETE FROM " + table.getName() + " WHERE regionkey = 2", 1); assertThat(query("SELECT * FROM " + table.getName() + " WHERE regionkey = 2")) .returnsEmptyResult(); diff --git a/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java b/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java index e53c808fa9bf..cafd6c54323d 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java @@ -3463,8 +3463,7 @@ public void testCreateTable() assertQueryFails("CREATE TABLE " + tableName + " (a bad_type)", ".* Unknown type 'bad_type' for column 'a'"); assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); - // TODO (https://github.com/trinodb/trino/issues/5901) revert to longer name when Oracle version is updated - tableName = "test_cr_not_exists_" + randomNameSuffix(); + tableName = "test_create_not_exists_" + randomNameSuffix(); assertUpdate("CREATE TABLE " + tableName + " (a bigint, b varchar(50), c double)"); assertThat(getQueryRunner().tableExists(getSession(), tableName)).isTrue(); assertTableColumnNames(tableName, "a", "b", "c"); @@ -4345,8 +4344,7 @@ protected void testCommentColumnName(String columnName, boolean delimited) { String nameInSql = toColumnNameInSql(columnName, delimited); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_comment_column", "(" + nameInSql + " integer)")) { + try (TestTable table = new TestTable(getQueryRunner()::execute, "test_comment_column_name", "(" + nameInSql + " integer)")) { assertUpdate("COMMENT ON COLUMN " + table.getName() + "." + nameInSql + " IS 'test comment'"); assertThat(getColumnComment(table.getName(), columnName.replace("'", "''").toLowerCase(ENGLISH))).isEqualTo("test comment"); } @@ -4787,7 +4785,6 @@ public void testDeleteWithComplexPredicate() { skipTestUnless(hasBehavior(SUPPORTS_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated try (TestTable table = createTestTableForWrites("test_delete_complex_", "AS SELECT * FROM nation", "nationkey")) { // delete half the table, then delete the rest assertUpdate("DELETE FROM " + table.getName() + " WHERE nationkey % 2 = 0", "SELECT count(*) FROM nation WHERE nationkey % 2 = 0"); @@ -4806,8 +4803,7 @@ public void testDeleteWithSubquery() // TODO (https://github.com/trinodb/trino/issues/13210) Migrate these tests to AbstractTestEngineOnlyQueries skipTestUnless(hasBehavior(SUPPORTS_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = createTestTableForWrites("test_delete_subquery", "AS SELECT * FROM nation", "nationkey")) { + try (TestTable table = createTestTableForWrites("test_delete_with_subquery", "AS SELECT * FROM nation", "nationkey")) { // delete using a subquery assertUpdate("DELETE FROM " + table.getName() + " WHERE regionkey IN (SELECT regionkey FROM region WHERE name LIKE 'A%')", 15); assertQuery( @@ -4815,8 +4811,7 @@ public void testDeleteWithSubquery() "SELECT * FROM nation WHERE regionkey IN (SELECT regionkey FROM region WHERE name NOT LIKE 'A%')"); } - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = createTestTableForWrites("test_delete_subquery", "AS SELECT * FROM orders", "orderkey")) { + try (TestTable table = createTestTableForWrites("test_delete_with_subquery", "AS SELECT * FROM orders", "orderkey")) { // delete using a scalar and EXISTS subquery assertUpdate("DELETE FROM " + table.getName() + " WHERE orderkey = (SELECT orderkey FROM orders ORDER BY orderkey LIMIT 1)", 1); assertUpdate("DELETE FROM " + table.getName() + " WHERE orderkey = (SELECT orderkey FROM orders WHERE false)", 0); @@ -4869,8 +4864,7 @@ public void testDeleteWithSemiJoin() { skipTestUnless(hasBehavior(SUPPORTS_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = createTestTableForWrites("test_delete_semijoin", "AS SELECT * FROM nation", "nationkey")) { + try (TestTable table = createTestTableForWrites("test_delete_with_semijoin", "AS SELECT * FROM nation", "nationkey")) { // delete with multiple SemiJoin assertUpdate( "DELETE FROM " + table.getName() + " " + @@ -4884,8 +4878,7 @@ public void testDeleteWithSemiJoin() " OR regionkey IN (SELECT regionkey FROM region WHERE length(comment) >= 50)"); } - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = createTestTableForWrites("test_delete_semijoin", "AS SELECT * FROM orders", "orderkey")) { + try (TestTable table = createTestTableForWrites("test_delete_with_semijoin", "AS SELECT * FROM orders", "orderkey")) { // delete with SemiJoin null handling assertUpdate( "DELETE FROM " + table.getName() + "\n" + @@ -4953,8 +4946,7 @@ public void testDeleteAllDataFromTable() public void testRowLevelDelete() { skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE_WITH_DATA) && hasBehavior(SUPPORTS_ROW_LEVEL_DELETE)); - // TODO (https://github.com/trinodb/trino/issues/5901) Use longer table name once Oracle version is updated - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_row_delete", "AS SELECT * FROM region")) { + try (TestTable table = new TestTable(getQueryRunner()::execute, "test_row_level_delete", "AS SELECT * FROM region")) { assertUpdate("DELETE FROM " + table.getName() + " WHERE regionkey = 2", 1); assertQuery("SELECT count(*) FROM " + table.getName(), "VALUES 4"); }