Skip to content

Commit

Permalink
Change assertions to explicitly check for existence of table
Browse files Browse the repository at this point in the history
Counting number of tables leads to flakiness in case of parallel test
execution.
  • Loading branch information
hashhar committed Aug 31, 2021
1 parent f7f261f commit b5bd364
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.google.common.primitives.Ints;
import io.trino.Session;
import io.trino.execution.QueryStats;
import io.trino.metadata.QualifiedObjectName;
import io.trino.operator.OperatorStats;
import io.trino.plugin.base.metrics.LongCount;
import io.trino.spi.QueryId;
Expand Down Expand Up @@ -48,6 +47,7 @@
import static io.trino.testing.assertions.Assert.assertEquals;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

public class TestMemoryConnectorTest
Expand Down Expand Up @@ -516,14 +516,12 @@ public void testCreateTableInNonDefaultSchema()
@Test
public void testCreateTableAndViewInNotExistSchema()
{
int tablesBeforeCreate = listMemoryTables().size();

assertQueryFails("CREATE TABLE schema3.test_table3 (x date)", "Schema schema3 not found");
assertFalse(getQueryRunner().tableExists(getSession(), "schema3.test_table3"));
assertQueryFails("CREATE VIEW schema4.test_view4 AS SELECT 123 x", "Schema schema4 not found");
assertFalse(getQueryRunner().tableExists(getSession(), "schema4.test_view4"));
assertQueryFails("CREATE OR REPLACE VIEW schema5.test_view5 AS SELECT 123 x", "Schema schema5 not found");

int tablesAfterCreate = listMemoryTables().size();
assertEquals(tablesBeforeCreate, tablesAfterCreate);
assertFalse(getQueryRunner().tableExists(getSession(), "schema5.test_view5"));
}

@Test
Expand Down Expand Up @@ -563,11 +561,6 @@ public void testRenameView()
assertUpdate("DROP SCHEMA test_different_schema");
}

private List<QualifiedObjectName> listMemoryTables()
{
return getQueryRunner().listTables(getSession(), "memory", "default");
}

private void assertQueryResult(@Language("SQL") String sql, Object... expected)
{
MaterializedResult rows = computeActual(sql);
Expand Down

0 comments on commit b5bd364

Please sign in to comment.