Search in sources :

Example 96 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class ThriftQueryRunner method createThriftQueryRunnerInternal.

private static DistributedQueryRunner createThriftQueryRunnerInternal(List<DriftServer> servers, int nodeCount, Map<String, String> properties) throws Exception {
    String addresses = servers.stream().map(server -> "localhost:" + driftServerPort(server)).collect(joining(","));
    Session defaultSession = testSessionBuilder().setCatalog("thrift").setSchema("tiny").build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(defaultSession).setNodeCount(nodeCount).setExtraProperties(properties).build();
    queryRunner.installPlugin(new ThriftPlugin());
    Map<String, String> connectorProperties = ImmutableMap.<String, String>builder().put("presto.thrift.client.addresses", addresses).put("presto.thrift.client.connect-timeout", "30s").put("presto-thrift.lookup-requests-concurrency", "2").build();
    queryRunner.createCatalog("thrift", "presto-thrift", connectorProperties);
    return queryRunner;
}
Also used : Logger(com.facebook.airlift.log.Logger) ThriftTpchService(com.facebook.presto.connector.thrift.server.ThriftTpchService) DriftServer(com.facebook.drift.server.DriftServer) ThriftCodecManager(com.facebook.drift.codec.ThriftCodecManager) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) QueryRunner(com.facebook.presto.testing.QueryRunner) ConnectorPlanOptimizerManager(com.facebook.presto.sql.planner.ConnectorPlanOptimizerManager) DriftNettyServerTransport(com.facebook.drift.transport.netty.server.DriftNettyServerTransport) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) ArrayList(java.util.ArrayList) StatsCalculator(com.facebook.presto.cost.StatsCalculator) ImmutableList(com.google.common.collect.ImmutableList) ThriftIndexedTpchService(com.facebook.presto.connector.thrift.server.ThriftIndexedTpchService) PageSourceManager(com.facebook.presto.split.PageSourceManager) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) QualifiedObjectName(com.facebook.presto.common.QualifiedObjectName) EventListener(com.facebook.presto.spi.eventlistener.EventListener) TransactionManager(com.facebook.presto.transaction.TransactionManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Session(com.facebook.presto.Session) NullMethodInvocationStatsFactory(com.facebook.drift.server.stats.NullMethodInvocationStatsFactory) DriftNettyServerTransportFactory(com.facebook.drift.transport.netty.server.DriftNettyServerTransportFactory) SplitManager(com.facebook.presto.split.SplitManager) TestingSession.testSessionBuilder(com.facebook.presto.testing.TestingSession.testSessionBuilder) Closeables.closeQuietly(com.facebook.airlift.testing.Closeables.closeQuietly) Plugin(com.facebook.presto.spi.Plugin) Collectors.joining(java.util.stream.Collectors.joining) DriftService(com.facebook.drift.server.DriftService) MaterializedResult(com.facebook.presto.testing.MaterializedResult) List(java.util.List) Lock(java.util.concurrent.locks.Lock) ThriftPlugin(com.facebook.presto.connector.thrift.ThriftPlugin) TestingAccessControlManager(com.facebook.presto.testing.TestingAccessControlManager) Logging(com.facebook.airlift.log.Logging) Optional(java.util.Optional) DriftNettyServerConfig(com.facebook.drift.transport.netty.server.DriftNettyServerConfig) Metadata(com.facebook.presto.metadata.Metadata) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) ThriftPlugin(com.facebook.presto.connector.thrift.ThriftPlugin) Session(com.facebook.presto.Session)

Example 97 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TpcdsQueryRunner method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties, Map<String, String> coordinatorProperties) throws Exception {
    Session session = testSessionBuilder().setSource("test").setCatalog("tpcds").setSchema("sf1").build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(4).setExtraProperties(extraProperties).setCoordinatorProperties(coordinatorProperties).build();
    try {
        queryRunner.installPlugin(new TpcdsPlugin());
        queryRunner.createCatalog("tpcds", "tpcds");
        return queryRunner;
    } catch (Exception e) {
        queryRunner.close();
        throw e;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) Session(com.facebook.presto.Session)

Example 98 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TestPostgreSqlIntegrationSmokeTest method testCharTrailingSpace.

@Test
public void testCharTrailingSpace() throws Exception {
    execute("CREATE TABLE tpch.char_trailing_space (x char(10))");
    assertUpdate("INSERT INTO char_trailing_space VALUES ('test')", 1);
    assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test'", "VALUES 'test'");
    assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test  '", "VALUES 'test'");
    assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test        '", "VALUES 'test'");
    assertEquals(getQueryRunner().execute("SELECT * FROM char_trailing_space WHERE x = char ' test'").getRowCount(), 0);
    Map<String, String> properties = ImmutableMap.of("deprecated.legacy-char-to-varchar-coercion", "true");
    Map<String, String> connectorProperties = ImmutableMap.of("connection-url", postgreSqlServer.getJdbcUrl());
    try (QueryRunner queryRunner = new DistributedQueryRunner(getSession(), 3, properties)) {
        queryRunner.installPlugin(new PostgreSqlPlugin());
        queryRunner.createCatalog("postgresql", "postgresql", connectorProperties);
        assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test'").getRowCount(), 0);
        assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test  '").getRowCount(), 0);
        assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test       '").getRowCount(), 0);
        MaterializedResult result = queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test      '");
        assertEquals(result.getRowCount(), 1);
        assertEquals(result.getMaterializedRows().get(0).getField(0), "test      ");
    }
    assertUpdate("DROP TABLE char_trailing_space");
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) MaterializedResult(com.facebook.presto.testing.MaterializedResult) QueryRunner(com.facebook.presto.testing.QueryRunner) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) Test(org.testng.annotations.Test) AbstractTestIntegrationSmokeTest(com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)

Example 99 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class RedisQueryRunner method createRedisQueryRunner.

public static DistributedQueryRunner createRedisQueryRunner(EmbeddedRedis embeddedRedis, String dataFormat, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = new DistributedQueryRunner(createSession(), 2);
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        embeddedRedis.start();
        Map<SchemaTableName, RedisTableDescription> tableDescriptions = createTpchTableDescriptions(queryRunner.getCoordinator().getMetadata(), tables, dataFormat);
        installRedisPlugin(embeddedRedis, queryRunner, tableDescriptions);
        TestingPrestoClient prestoClient = queryRunner.getRandomClient();
        log.info("Loading data...");
        long startTime = System.nanoTime();
        for (TpchTable<?> table : tables) {
            loadTpchTable(embeddedRedis, prestoClient, table, dataFormat);
        }
        log.info("Loading complete in %s", nanosSince(startTime).toString(SECONDS));
        embeddedRedis.destroyJedisPool();
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner, embeddedRedis);
        throw e;
    }
}
Also used : TestingPrestoClient(com.facebook.presto.tests.TestingPrestoClient) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Example 100 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TestRaptorIntegrationSmokeTestMySql method createRaptorMySqlQueryRunner.

private static DistributedQueryRunner createRaptorMySqlQueryRunner(String mysqlUrl) throws Exception {
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession("tpch"), 2);
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    queryRunner.installPlugin(new RaptorPlugin());
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().toFile();
    Map<String, String> raptorProperties = ImmutableMap.<String, String>builder().put("metadata.db.type", "mysql").put("metadata.db.url", mysqlUrl).put("storage.data-directory", new File(baseDir, "data").toURI().toString()).put("storage.max-shard-rows", "2000").put("backup.provider", "file").put("raptor.startup-grace-period", "10s").put("backup.directory", new File(baseDir, "backup").getAbsolutePath()).build();
    queryRunner.createCatalog("raptor", "raptor", raptorProperties);
    copyTables(queryRunner, "tpch", createSession(), false);
    return queryRunner;
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) File(java.io.File) RaptorPlugin(com.facebook.presto.raptor.RaptorPlugin)

Aggregations

DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)111 Test (org.testng.annotations.Test)36 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)33 Session (com.facebook.presto.Session)26 QueryId (com.facebook.presto.spi.QueryId)19 Logger (com.facebook.airlift.log.Logger)15 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)14 MaterializedResult (com.facebook.presto.testing.MaterializedResult)13 QueryRunner (com.facebook.presto.testing.QueryRunner)13 ImmutableMap (com.google.common.collect.ImmutableMap)10 ResourceGroupManagerPlugin (com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin)9 ArrayList (java.util.ArrayList)8 File (java.io.File)7 BeforeClass (org.testng.annotations.BeforeClass)7 JettyHttpClient (com.facebook.airlift.http.client.jetty.JettyHttpClient)6 FileResourceGroupConfigurationManagerFactory (com.facebook.presto.resourceGroups.FileResourceGroupConfigurationManagerFactory)6 H2ResourceGroupsDao (com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao)6 Path (java.nio.file.Path)6 Future (java.util.concurrent.Future)6 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)5