Skip to content

Commit

Permalink
Upgrade oracle test version
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjian2664 committed Dec 20, 2024
1 parent af3a6f3 commit 4cdd6b5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ protected void verifyConcurrentAddColumnFailurePermissible(Exception e)
@Override
protected OptionalInt maxSchemaNameLength()
{
return OptionalInt.of(30);
return OptionalInt.of(128);
}

@Override
Expand All @@ -458,7 +458,7 @@ protected void verifySchemaNameLengthFailurePermissible(Throwable e)
@Override
protected OptionalInt maxTableNameLength()
{
return OptionalInt.of(30);
return OptionalInt.of(128);
}

@Override
Expand All @@ -470,7 +470,7 @@ protected void verifyTableNameLengthFailurePermissible(Throwable e)
@Override
protected OptionalInt maxColumnNameLength()
{
return OptionalInt.of(30);
return OptionalInt.of(128);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions plugin/trino-oracle/src/test/resources/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ 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;

-- disable audit log for reducing diskspace usage
ALTER SYSTEM SET audit_trail=NONE SCOPE=SPFILE;
4 changes: 4 additions & 0 deletions plugin/trino-oracle/src/test/resources/restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

echo "Restarting ORACLE"

# Disable listener logging by editing listener.ora for reducing disk space usage
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
Expand All @@ -4806,17 +4803,15 @@ 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(
"SELECT * FROM " + table.getName(),
"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);
Expand Down Expand Up @@ -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() + " " +
Expand All @@ -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" +
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 4cdd6b5

Please sign in to comment.