Search in sources :

Example 21 with TestingPrestoServer

use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.

the class TestPrestoDriver method setup.

@BeforeClass
public void setup() throws Exception {
    Logging.initialize();
    server = new TestingPrestoServer();
    server.installPlugin(new TpchPlugin());
    server.createCatalog(TEST_CATALOG, "tpch");
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    Catalog bogusTestingCatalog = createBogusTestingCatalog(TESTING_CATALOG);
    server.getCatalogManager().registerCatalog(bogusTestingCatalog);
    SessionPropertyManager sessionPropertyManager = server.getMetadata().getSessionPropertyManager();
    sessionPropertyManager.addConnectorSessionProperties(bogusTestingCatalog.getConnectorId(), TEST_CATALOG_PROPERTIES);
    waitForNodeRefresh(server);
    setupTestTables();
    executorService = newCachedThreadPool(daemonThreadsNamed("test-%s"));
}
Also used : BlackHolePlugin(com.facebook.presto.plugin.blackhole.BlackHolePlugin) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) Catalog(com.facebook.presto.metadata.Catalog) TestingSession.createBogusTestingCatalog(com.facebook.presto.testing.TestingSession.createBogusTestingCatalog) BeforeClass(org.testng.annotations.BeforeClass)

Example 22 with TestingPrestoServer

use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.

the class TestJdbcConnection method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    Logging.initialize();
    Module systemTables = binder -> newSetBinder(binder, SystemTable.class).addBinding().to(ExtraCredentialsSystemTable.class).in(Scopes.SINGLETON);
    server = new TestingPrestoServer(ImmutableList.of(systemTables));
    server.installPlugin(new HiveHadoop2Plugin());
    server.createCatalog("hive", "hive-hadoop2", ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", server.getBaseDataDir().resolve("hive").toFile().toURI().toString()).put("hive.security", "sql-standard").build());
    try (Connection connection = createConnection();
        Statement statement = connection.createStatement()) {
        statement.execute("SET ROLE admin");
        statement.execute("CREATE SCHEMA default");
        statement.execute("CREATE SCHEMA fruit");
    }
}
Also used : Module(com.google.inject.Module) Connection(java.sql.Connection) DataProvider(org.testng.annotations.DataProvider) VarcharType.createUnboundedVarcharType(com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) InMemoryRecordSet(com.facebook.presto.spi.InMemoryRecordSet) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) SQLException(java.sql.SQLException) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) HiveHadoop2Plugin(com.facebook.presto.hive.HiveHadoop2Plugin) ResultSet(java.sql.ResultSet) Map(java.util.Map) Multibinder.newSetBinder(com.google.inject.multibindings.Multibinder.newSetBinder) SystemTable(com.facebook.presto.spi.SystemTable) Assert.assertFalse(org.testng.Assert.assertFalse) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata) AfterClass(org.testng.annotations.AfterClass) ImmutableSet(com.google.common.collect.ImmutableSet) Properties(java.util.Properties) ALL_NODES(com.facebook.presto.spi.SystemTable.Distribution.ALL_NODES) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) Set(java.util.Set) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Assert.assertNotNull(org.testng.Assert.assertNotNull) PreparedStatement(java.sql.PreparedStatement) Scopes(com.google.inject.Scopes) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) StandardCharsets(java.nio.charset.StandardCharsets) String.format(java.lang.String.format) TestPrestoDriver.closeQuietly(com.facebook.presto.jdbc.TestPrestoDriver.closeQuietly) ConnectorSession(com.facebook.presto.spi.ConnectorSession) RecordCursor(com.facebook.presto.spi.RecordCursor) URLEncoder(java.net.URLEncoder) List(java.util.List) Logging(com.facebook.airlift.log.Logging) Statement(java.sql.Statement) Assert.assertTrue(org.testng.Assert.assertTrue) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DriverManager(java.sql.DriverManager) Joiner(com.google.common.base.Joiner) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) Connection(java.sql.Connection) HiveHadoop2Plugin(com.facebook.presto.hive.HiveHadoop2Plugin) SystemTable(com.facebook.presto.spi.SystemTable) Module(com.google.inject.Module) BeforeClass(org.testng.annotations.BeforeClass)

Example 23 with TestingPrestoServer

use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.

the class TestJdbcResultSet method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    Logging.initialize();
    server = new TestingPrestoServer();
}
Also used : TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) BeforeClass(org.testng.annotations.BeforeClass)

Example 24 with TestingPrestoServer

use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.

the class TestPrestoDriverAuth method setup.

@BeforeClass
public void setup() throws Exception {
    Logging.initialize();
    URL resource = getClass().getClassLoader().getResource("33.privateKey");
    assertNotNull(resource, "key directory not found");
    File keyDir = new File(resource.getFile()).getAbsoluteFile().getParentFile();
    defaultKey = getMimeDecoder().decode(asCharSource(new File(keyDir, "default-key.key"), US_ASCII).read().getBytes(US_ASCII));
    hmac222 = getMimeDecoder().decode(asCharSource(new File(keyDir, "222.key"), US_ASCII).read().getBytes(US_ASCII));
    privateKey33 = PemReader.loadPrivateKey(new File(keyDir, "33.privateKey"), Optional.empty());
    server = new TestingPrestoServer(true, ImmutableMap.<String, String>builder().put("http-server.authentication.type", "JWT").put("http.authentication.jwt.key-file", new File(keyDir, "${KID}.key").toString()).put("http-server.https.enabled", "true").put("http-server.https.keystore.path", getResource("localhost.keystore").getPath()).put("http-server.https.keystore.key", "changeit").build(), null, null, new SqlParserOptions(), ImmutableList.of());
    server.installPlugin(new TpchPlugin());
    server.createCatalog(TEST_CATALOG, "tpch");
    waitForNodeRefresh(server);
}
Also used : SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) File(java.io.File) URL(java.net.URL) BeforeClass(org.testng.annotations.BeforeClass)

Example 25 with TestingPrestoServer

use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.

the class TestHiveRecoverableExecution method waitUntilAllNodesAreHealthy.

private static void waitUntilAllNodesAreHealthy(DistributedQueryRunner queryRunner, Duration timeout) throws TimeoutException, InterruptedException {
    TestingPrestoServer coordinator = queryRunner.getCoordinator();
    long deadline = System.currentTimeMillis() + timeout.toMillis();
    while (System.currentTimeMillis() < deadline) {
        AllNodes allNodes = coordinator.refreshNodes();
        if (allNodes.getActiveNodes().size() == queryRunner.getNodeCount()) {
            return;
        }
        sleep(1000);
    }
    throw new TimeoutException(format("one of the nodes is still missing after: %s", timeout));
}
Also used : AllNodes(com.facebook.presto.metadata.AllNodes) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)47 Test (org.testng.annotations.Test)19 BeforeClass (org.testng.annotations.BeforeClass)16 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)13 ArrayList (java.util.ArrayList)9 JettyHttpClient (com.facebook.airlift.http.client.jetty.JettyHttpClient)7 FileResourceGroupConfigurationManagerFactory (com.facebook.presto.resourceGroups.FileResourceGroupConfigurationManagerFactory)6 NodeState (com.facebook.presto.spi.NodeState)6 QueryId (com.facebook.presto.spi.QueryId)6 Future (java.util.concurrent.Future)6 ServerInfoResource (com.facebook.presto.server.ServerInfoResource)5 BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)4 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 Response (javax.ws.rs.core.Response)4 Request (com.facebook.airlift.http.client.Request)3 TaskManager (com.facebook.presto.execution.TaskManager)3 BlackHolePlugin (com.facebook.presto.plugin.blackhole.BlackHolePlugin)3 TestShutdownAction (com.facebook.presto.server.testing.TestingPrestoServer.TestShutdownAction)3