diff --git a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/TestKuduConnectorTest.java b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/TestKuduConnectorTest.java index b55c42b12718..a2f729d0523d 100644 --- a/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/TestKuduConnectorTest.java +++ b/plugin/trino-kudu/src/test/java/io/trino/plugin/kudu/TestKuduConnectorTest.java @@ -510,17 +510,12 @@ protected String errorMessageForInsertNegativeDate(String date) } @Override - public void testInsertRowConcurrently() + protected TestTable createTableWithOneIntegerColumn(String namePrefix) { - // TODO Support these test once kudu connector can create tables with default partitions - throw new SkipException("TODO"); - } - - @Override - public void testAddColumnConcurrently() - { - // TODO Support these test once kudu connector can create tables with default partitions - throw new SkipException("TODO"); + // TODO Remove this overriding method once kudu connector can create tables with default partitions + return new TestTable(getQueryRunner()::execute, namePrefix, + "(col integer WITH (primary_key=true)) " + + "WITH (partition_by_hash_columns = ARRAY['col'], partition_by_hash_buckets = 2)"); } @Test @@ -534,8 +529,24 @@ public void testWrittenStats() @Override public void testReadMetadataWithRelationsConcurrentModifications() { - // TODO Support these test once kudu connector can create tables with default partitions - throw new SkipException("TODO"); + try { + super.testReadMetadataWithRelationsConcurrentModifications(); + } + catch (Exception expected) { + // The test failure is not guaranteed + // TODO (https://github.com/trinodb/trino/issues/12974): shouldn't fail + assertThat(expected) + .hasMessageMatching(".* table .* was deleted: Table deleted at .* UTC"); + throw new SkipException("to be fixed"); + } + } + + @Override + protected String createTableSqlTemplateForConcurrentModifications() + { + // TODO Remove this overriding method once kudu connector can create tables with default partitions + return "CREATE TABLE %s(a integer WITH (primary_key=true)) " + + "WITH (partition_by_hash_columns = ARRAY['a'], partition_by_hash_buckets = 2)"; } @Test 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 96945db6a4a0..a7c9a6175c0c 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 @@ -1416,7 +1416,7 @@ protected void testReadMetadataWithRelationsConcurrentModifications(int readIter Runnable writeInitialized = writeTasksInitialized::countDown; Supplier done = () -> incompleteReadTasks.get() == 0; List> writeTasks = new ArrayList<>(); - writeTasks.add(createDropRepeatedly(writeInitialized, done, "concur_table", "CREATE TABLE %s(a integer)", "DROP TABLE %s")); + writeTasks.add(createDropRepeatedly(writeInitialized, done, "concur_table", createTableSqlTemplateForConcurrentModifications(), "DROP TABLE %s")); if (hasBehavior(SUPPORTS_CREATE_VIEW)) { writeTasks.add(createDropRepeatedly(writeInitialized, done, "concur_view", "CREATE VIEW %s AS SELECT 1 a", "DROP VIEW %s")); } @@ -1451,6 +1451,12 @@ protected void testReadMetadataWithRelationsConcurrentModifications(int readIter assertTrue(executor.awaitTermination(10, SECONDS)); } + @Language("SQL") + protected String createTableSqlTemplateForConcurrentModifications() + { + return "CREATE TABLE %s(a integer)"; + } + /** * Run {@code sql} query at least {@code minIterations} times and keep running until other tasks complete. * {@code incompleteReadTasks} is used for orchestrating end of execution. @@ -3008,7 +3014,7 @@ public void testInsertRowConcurrently() int threads = 4; CyclicBarrier barrier = new CyclicBarrier(threads); ExecutorService executor = newFixedThreadPool(threads); - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_insert", "(col integer)")) { + try (TestTable table = createTableWithOneIntegerColumn("test_insert")) { String tableName = table.getName(); List> futures = IntStream.range(0, threads) @@ -3076,7 +3082,7 @@ public void testAddColumnConcurrently() int threads = 4; CyclicBarrier barrier = new CyclicBarrier(threads); ExecutorService executor = newFixedThreadPool(threads); - try (TestTable table = new TestTable(getQueryRunner()::execute, "test_add_column", "(col integer)")) { + try (TestTable table = createTableWithOneIntegerColumn("test_add_column")) { String tableName = table.getName(); List>> futures = IntStream.range(0, threads) @@ -3128,6 +3134,11 @@ protected void verifyConcurrentAddColumnFailurePermissible(Exception e) throw new AssertionError("Unexpected concurrent add column failure", e); } + protected TestTable createTableWithOneIntegerColumn(String namePrefix) + { + return new TestTable(getQueryRunner()::execute, namePrefix, "(col integer)"); + } + @Test public void testUpdateWithPredicates() {