Search in sources :

Example 26 with TestingConnectorContext

use of io.trino.testing.TestingConnectorContext in project TiBigData by tidb-incubator.

the class ConnectorsPluginTest method testCreateConnector.

@Test
public void testCreateConnector() {
    Plugin plugin = new ConnectorsPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("tidb", ConfigUtils.getProperties(), new TestingConnectorContext());
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) ConnectorsPlugin(io.tidb.bigdata.trino.ConnectorsPlugin) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Plugin(io.trino.spi.Plugin) ConnectorsPlugin(io.tidb.bigdata.trino.ConnectorsPlugin) Test(org.junit.Test) IntegrationTest(io.tidb.bigdata.test.IntegrationTest)

Example 27 with TestingConnectorContext

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

the class TestJmxStats method testJmxStatsExposure.

@Test
public void testJmxStatsExposure() throws Exception {
    Plugin plugin = new JdbcPlugin("base-jdbc", new TestingH2JdbcModule());
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "jdbc:driver:"), new TestingConnectorContext());
    MBeanServer mbeanServer = getPlatformMBeanServer();
    Set<ObjectName> objectNames = mbeanServer.queryNames(new ObjectName("io.trino.plugin.jdbc:*"), null);
    assertTrue(objectNames.containsAll(ImmutableSet.of(new ObjectName("io.trino.plugin.jdbc:type=ConnectionFactory,name=test"), new ObjectName("io.trino.plugin.jdbc:type=JdbcClient,name=test"))));
    for (ObjectName objectName : objectNames) {
        MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
        assertNotEquals(mbeanInfo.getAttributes().length, 0, format("Object %s doesn't expose JMX stats", objectName.getCanonicalName()));
    }
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) MBeanInfo(javax.management.MBeanInfo) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Plugin(io.trino.spi.Plugin) ManagementFactory.getPlatformMBeanServer(java.lang.management.ManagementFactory.getPlatformMBeanServer) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.testng.annotations.Test)

Example 28 with TestingConnectorContext

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

the class AbstractTestDeltaLakeCreateTableStatistics method getAddFileEntries.

protected List<AddFileEntry> getAddFileEntries(String tableName) throws IOException {
    TestingConnectorContext context = new TestingConnectorContext();
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
    TransactionLogAccess transactionLogAccess = new TransactionLogAccess(context.getTypeManager(), new CheckpointSchemaManager(context.getTypeManager()), new DeltaLakeConfig(), new FileFormatDataSourceStats(), hdfsEnvironment, new ParquetReaderConfig(), new DeltaLakeConfig());
    return transactionLogAccess.getActiveFiles(transactionLogAccess.loadSnapshot(new SchemaTableName(SCHEMA, tableName), new Path(format("s3://%s/%s", bucketName, tableName)), SESSION), SESSION);
}
Also used : Path(org.apache.hadoop.fs.Path) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) HdfsConfig(io.trino.plugin.hive.HdfsConfig) TransactionLogAccess(io.trino.plugin.deltalake.transactionlog.TransactionLogAccess) FileFormatDataSourceStats(io.trino.plugin.hive.FileFormatDataSourceStats) TestingConnectorContext(io.trino.testing.TestingConnectorContext) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) HdfsConfiguration(io.trino.plugin.hive.HdfsConfiguration) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) SchemaTableName(io.trino.spi.connector.SchemaTableName) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) CheckpointSchemaManager(io.trino.plugin.deltalake.transactionlog.checkpoint.CheckpointSchemaManager) ParquetReaderConfig(io.trino.plugin.hive.parquet.ParquetReaderConfig)

Example 29 with TestingConnectorContext

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

the class TestCassandraConnector method setup.

@BeforeClass
public void setup() throws Exception {
    this.server = new CassandraServer();
    String keyspace = "test_connector";
    createTestTables(server.getSession(), keyspace, DATE);
    CassandraConnectorFactory connectorFactory = new CassandraConnectorFactory();
    Connector connector = connectorFactory.create("test", ImmutableMap.of("cassandra.contact-points", server.getHost(), "cassandra.native-protocol-port", Integer.toString(server.getPort())), new TestingConnectorContext());
    metadata = connector.getMetadata(SESSION, CassandraTransactionHandle.INSTANCE);
    assertInstanceOf(metadata, CassandraMetadata.class);
    splitManager = connector.getSplitManager();
    assertInstanceOf(splitManager, CassandraSplitManager.class);
    recordSetProvider = connector.getRecordSetProvider();
    assertInstanceOf(recordSetProvider, CassandraRecordSetProvider.class);
    database = keyspace;
    table = new SchemaTableName(database, TABLE_ALL_TYPES.toLowerCase(ENGLISH));
    tableForDelete = new SchemaTableName(database, TABLE_DELETE_DATA.toLowerCase(ENGLISH));
    tableTuple = new SchemaTableName(database, TABLE_TUPLE_TYPE.toLowerCase(ENGLISH));
    tableUdt = new SchemaTableName(database, TABLE_USER_DEFINED_TYPE.toLowerCase(ENGLISH));
}
Also used : Connector(io.trino.spi.connector.Connector) TestingConnectorContext(io.trino.testing.TestingConnectorContext) SchemaTableName(io.trino.spi.connector.SchemaTableName) BeforeClass(org.testng.annotations.BeforeClass)

Example 30 with TestingConnectorContext

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

the class TestIcebergPlugin method testSystemAccessControl.

@Test
public void testSystemAccessControl() {
    ConnectorFactory connectorFactory = getConnectorFactory();
    Connector connector = connectorFactory.create("test", ImmutableMap.<String, String>builder().put("iceberg.catalog.type", "HIVE_METASTORE").put("hive.metastore.uri", "thrift://foo:1234").put("iceberg.security", "system").buildOrThrow(), new TestingConnectorContext());
    assertThatThrownBy(connector::getAccessControl).isInstanceOf(UnsupportedOperationException.class);
    connector.shutdown();
}
Also used : Connector(io.trino.spi.connector.Connector) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) 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