Search in sources :

Example 16 with TestingPrestoServer

use of io.prestosql.server.testing.TestingPrestoServer in project hetu-core by openlookeng.

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").toAbsolutePath().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) TestPrestoDriver.closeQuietly(io.prestosql.jdbc.TestPrestoDriver.closeQuietly) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ALL_NODES(io.prestosql.spi.connector.SystemTable.Distribution.ALL_NODES) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) InMemoryRecordSet(io.prestosql.spi.connector.InMemoryRecordSet) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) SQLException(java.sql.SQLException) ImmutableList(com.google.common.collect.ImmutableList) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) TableMetadataBuilder.tableMetadataBuilder(io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) ResultSet(java.sql.ResultSet) Map(java.util.Map) Logging(io.airlift.log.Logging) Multibinder.newSetBinder(com.google.inject.multibindings.Multibinder.newSetBinder) RecordCursor(io.prestosql.spi.connector.RecordCursor) Assert.assertFalse(org.testng.Assert.assertFalse) AfterClass(org.testng.annotations.AfterClass) ImmutableSet(com.google.common.collect.ImmutableSet) SystemTable(io.prestosql.spi.connector.SystemTable) ImmutableMap(com.google.common.collect.ImmutableMap) HiveHadoop2Plugin(io.prestosql.plugin.hive.HiveHadoop2Plugin) TupleDomain(io.prestosql.spi.predicate.TupleDomain) BeforeClass(org.testng.annotations.BeforeClass) Assert.fail(org.testng.Assert.fail) Set(java.util.Set) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer) PreparedStatement(java.sql.PreparedStatement) Scopes(com.google.inject.Scopes) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) String.format(java.lang.String.format) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) Statement(java.sql.Statement) ConnectorTransactionHandle(io.prestosql.spi.connector.ConnectorTransactionHandle) Assert.assertTrue(org.testng.Assert.assertTrue) DriverManager(java.sql.DriverManager) Joiner(com.google.common.base.Joiner) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer) Connection(java.sql.Connection) HiveHadoop2Plugin(io.prestosql.plugin.hive.HiveHadoop2Plugin) SystemTable(io.prestosql.spi.connector.SystemTable) Module(com.google.inject.Module) BeforeClass(org.testng.annotations.BeforeClass)

Example 17 with TestingPrestoServer

use of io.prestosql.server.testing.TestingPrestoServer in project hetu-core by openlookeng.

the class TestJdbcResultSet method setupServer.

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

Example 18 with TestingPrestoServer

use of io.prestosql.server.testing.TestingPrestoServer in project hetu-core by openlookeng.

the class TestJdbcWarnings method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    server = new TestingPrestoServer(ImmutableMap.<String, String>builder().put("testing-warning-collector.add-warnings", "true").put("testing-warning-collector.preloaded-warnings", String.valueOf(PRELOADED_WARNINGS)).build());
    server.installPlugin(new TpchPlugin());
    server.createCatalog("tpch", "tpch");
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    waitForNodeRefresh(server);
}
Also used : BlackHolePlugin(io.prestosql.plugin.blackhole.BlackHolePlugin) TpchPlugin(io.prestosql.plugin.tpch.TpchPlugin) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer) BeforeClass(org.testng.annotations.BeforeClass)

Example 19 with TestingPrestoServer

use of io.prestosql.server.testing.TestingPrestoServer in project hetu-core by openlookeng.

the class TestProxyServer method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    byte[] sharedSecret = Base64.getMimeEncoder().encode("test secret".getBytes(US_ASCII));
    sharedSecretFile = Files.createTempFile("secret", "txt");
    Files.write(sharedSecretFile, sharedSecret);
    Logging.initialize();
    server = new TestingPrestoServer();
    server.installPlugin(new TpchPlugin());
    server.createCatalog("tpch", "tpch");
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    server.refreshNodes();
    Bootstrap app = new Bootstrap(new TestingNodeModule("test"), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(), new TestingJmxModule(), new ProxyModule());
    Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperty("proxy.uri", server.getBaseUrl().toString()).setRequiredConfigurationProperty("proxy.shared-secret-file", sharedSecretFile.toString()).quiet().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    httpServerInfo = injector.getInstance(HttpServerInfo.class);
    executorService = newCachedThreadPool(daemonThreadsNamed("test-%s"));
    setupTestTable();
}
Also used : TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) TpchPlugin(io.prestosql.plugin.tpch.TpchPlugin) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer) JaxrsModule(io.airlift.jaxrs.JaxrsModule) JsonModule(io.airlift.json.JsonModule) TestingJmxModule(io.airlift.jmx.testing.TestingJmxModule) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) BlackHolePlugin(io.prestosql.plugin.blackhole.BlackHolePlugin) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) HttpServerInfo(io.airlift.http.server.HttpServerInfo) BeforeClass(org.testng.annotations.BeforeClass)

Example 20 with TestingPrestoServer

use of io.prestosql.server.testing.TestingPrestoServer in project hetu-core by openlookeng.

the class TestDataCenterClientAuth method setup.

@BeforeClass
public void setup() throws Exception {
    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(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());
    server.installPlugin(new TpchPlugin());
    server.createCatalog("tpch", "tpch");
}
Also used : TpchPlugin(io.prestosql.plugin.tpch.TpchPlugin) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer) File(java.io.File) URL(java.net.URL) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TestingPrestoServer (io.prestosql.server.testing.TestingPrestoServer)36 BeforeClass (org.testng.annotations.BeforeClass)17 Test (org.testng.annotations.Test)11 TpchPlugin (io.prestosql.plugin.tpch.TpchPlugin)8 ArrayList (java.util.ArrayList)8 BlackHolePlugin (io.prestosql.plugin.blackhole.BlackHolePlugin)5 BasicQueryInfo (io.prestosql.server.BasicQueryInfo)5 DistributedQueryRunner (io.prestosql.tests.DistributedQueryRunner)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 JettyHttpClient (io.airlift.http.client.jetty.JettyHttpClient)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 QueryId (io.prestosql.spi.QueryId)3 CatalogName (io.prestosql.spi.connector.CatalogName)3 HashMap (java.util.HashMap)3 Future (java.util.concurrent.Future)3 QueryManager (io.prestosql.execution.QueryManager)2 TaskManager (io.prestosql.execution.TaskManager)2 NodeStateChangeHandler (io.prestosql.server.NodeStateChangeHandler)2 File (java.io.File)2 URL (java.net.URL)2