Search in sources :

Example 1 with CountingMockConnector

use of io.trino.testing.CountingMockConnector in project trino by trinodb.

the class TestTrinoDatabaseMetaData method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    Logging.initialize();
    server = TestingTrinoServer.create();
    server.installPlugin(new TpchPlugin());
    server.createCatalog(TEST_CATALOG, "tpch");
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    server.installPlugin(new HivePlugin());
    server.createCatalog("hive", "hive", ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", server.getBaseDataDir().resolve("hive").toAbsolutePath().toString()).put("hive.security", "sql-standard").buildOrThrow());
    countingMockConnector = new CountingMockConnector();
    server.installPlugin(countingMockConnector.getPlugin());
    server.createCatalog(COUNTING_CATALOG, "mock", ImmutableMap.of());
    server.waitForNodeRefresh(Duration.ofSeconds(10));
    try (Connection connection = createConnection();
        Statement statement = connection.createStatement()) {
        statement.executeUpdate("CREATE SCHEMA blackhole.blackhole");
    }
    try (Connection connection = createConnection()) {
        connection.setCatalog("hive");
        try (Statement statement = connection.createStatement()) {
            statement.execute("SET ROLE admin IN hive");
            statement.execute("CREATE SCHEMA default");
            statement.execute("CREATE TABLE default.test_table (a varchar)");
            statement.execute("CREATE VIEW default.test_view AS SELECT * FROM hive.default.test_table");
        }
    }
}
Also used : CountingMockConnector(io.trino.testing.CountingMockConnector) BlackHolePlugin(io.trino.plugin.blackhole.BlackHolePlugin) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) HivePlugin(io.trino.plugin.hive.HivePlugin) Statement(java.sql.Statement) Connection(java.sql.Connection) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

BlackHolePlugin (io.trino.plugin.blackhole.BlackHolePlugin)1 HivePlugin (io.trino.plugin.hive.HivePlugin)1 TpchPlugin (io.trino.plugin.tpch.TpchPlugin)1 CountingMockConnector (io.trino.testing.CountingMockConnector)1 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 BeforeClass (org.testng.annotations.BeforeClass)1