Search in sources :

Example 41 with TestingConnectorContext

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

the class TestHiveConnectorFactory method assertCreateConnector.

private static void assertCreateConnector(String metastoreUri) {
    Map<String, String> config = ImmutableMap.<String, String>builder().put("hive.metastore.uri", metastoreUri).buildOrThrow();
    Connector connector = new HiveConnectorFactory("hive").create("hive-test", config, new TestingConnectorContext());
    ConnectorTransactionHandle transaction = connector.beginTransaction(READ_UNCOMMITTED, true, true);
    assertInstanceOf(connector.getMetadata(SESSION, transaction), ClassLoaderSafeConnectorMetadata.class);
    assertInstanceOf(connector.getSplitManager(), ClassLoaderSafeConnectorSplitManager.class);
    assertInstanceOf(connector.getPageSourceProvider(), ConnectorPageSourceProvider.class);
    connector.commit(transaction);
}
Also used : Connector(io.trino.spi.connector.Connector) ConnectorTransactionHandle(io.trino.spi.connector.ConnectorTransactionHandle) TestingConnectorContext(io.trino.testing.TestingConnectorContext)

Example 42 with TestingConnectorContext

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

the class TestHivePlugin method testImmutablePartitionsAndInsertOverwriteMutuallyExclusive.

@Test
public void testImmutablePartitionsAndInsertOverwriteMutuallyExclusive() {
    ConnectorFactory connectorFactory = getHiveConnectorFactory();
    assertThatThrownBy(() -> connectorFactory.create("test", ImmutableMap.<String, String>builder().put("hive.insert-existing-partitions-behavior", "APPEND").put("hive.immutable-partitions", "true").put("hive.metastore.uri", "thrift://foo:1234").buildOrThrow(), new TestingConnectorContext())).hasMessageContaining("insert-existing-partitions-behavior cannot be APPEND when immutable-partitions is true");
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 43 with TestingConnectorContext

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

the class TestHivePlugin method testCreateConnector.

@Test
public void testCreateConnector() {
    ConnectorFactory factory = getHiveConnectorFactory();
    // simplest possible configuration
    factory.create("test", ImmutableMap.of("hive.metastore.uri", "thrift://foo:1234"), new TestingConnectorContext()).shutdown();
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 44 with TestingConnectorContext

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

the class TestHivePlugin method testGcsAccessTokenAndHiveCachingMutuallyExclusive.

@Test
public void testGcsAccessTokenAndHiveCachingMutuallyExclusive() {
    ConnectorFactory connectorFactory = getHiveConnectorFactory();
    assertThatThrownBy(() -> connectorFactory.create("test", ImmutableMap.<String, String>builder().put("hive.gcs.use-access-token", "true").put("hive.cache.enabled", "true").put("hive.metastore.uri", "thrift://foo:1234").put("hive.cache.location", tempDirectory.toString()).buildOrThrow(), new TestingConnectorContext())).hasMessageContaining("Use of GCS access token is not compatible with Hive caching");
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 45 with TestingConnectorContext

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

the class TestHivePlugin method testFileBasedAccessControl.

@Test
public void testFileBasedAccessControl() throws Exception {
    ConnectorFactory connectorFactory = getHiveConnectorFactory();
    File tempFile = File.createTempFile("test-hive-plugin-access-control", ".json");
    tempFile.deleteOnExit();
    Files.write(tempFile.toPath(), "{}".getBytes(UTF_8));
    connectorFactory.create("test", ImmutableMap.<String, String>builder().put("hive.metastore.uri", "thrift://foo:1234").put("hive.security", "file").put("security.config-file", tempFile.getAbsolutePath()).buildOrThrow(), new TestingConnectorContext()).shutdown();
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

TestingConnectorContext (io.trino.testing.TestingConnectorContext)64 ConnectorFactory (io.trino.spi.connector.ConnectorFactory)56 Test (org.testng.annotations.Test)53 Plugin (io.trino.spi.Plugin)22 Connector (io.trino.spi.connector.Connector)14 HdfsEnvironment (io.trino.plugin.hive.HdfsEnvironment)5 TypeManager (io.trino.spi.type.TypeManager)5 File (java.io.File)4 Path (java.nio.file.Path)4 BeforeClass (org.testng.annotations.BeforeClass)4 TransactionLogAccess (io.trino.plugin.deltalake.transactionlog.TransactionLogAccess)3 CheckpointSchemaManager (io.trino.plugin.deltalake.transactionlog.checkpoint.CheckpointSchemaManager)3 FileFormatDataSourceStats (io.trino.plugin.hive.FileFormatDataSourceStats)3 HdfsConfig (io.trino.plugin.hive.HdfsConfig)3 HdfsConfiguration (io.trino.plugin.hive.HdfsConfiguration)3 HdfsConfigurationInitializer (io.trino.plugin.hive.HdfsConfigurationInitializer)3 HiveHdfsConfiguration (io.trino.plugin.hive.HiveHdfsConfiguration)3 NodeVersion (io.trino.plugin.hive.NodeVersion)3 NoHdfsAuthentication (io.trino.plugin.hive.authentication.NoHdfsAuthentication)3 ParquetReaderConfig (io.trino.plugin.hive.parquet.ParquetReaderConfig)3