Search in sources :

Example 1 with TestingConnectorContext

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

the class TestPostgreSqlPlugin method testCreateConnector.

@Test
public void testCreateConnector() {
    Plugin plugin = new PostgreSqlPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext());
}
Also used : ConnectorFactory(io.prestosql.spi.connector.ConnectorFactory) TestingConnectorContext(io.prestosql.testing.TestingConnectorContext) Plugin(io.prestosql.spi.Plugin) Test(org.testng.annotations.Test)

Example 2 with TestingConnectorContext

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

the class TestMySqlPlugin method testCreateConnector.

@Test
public void testCreateConnector() {
    Plugin plugin = new MySqlPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "jdbc:mysql://test"), new TestingConnectorContext());
}
Also used : ConnectorFactory(io.prestosql.spi.connector.ConnectorFactory) TestingConnectorContext(io.prestosql.testing.TestingConnectorContext) Plugin(io.prestosql.spi.Plugin) Test(org.testng.annotations.Test)

Example 3 with TestingConnectorContext

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

the class TestThriftPlugin method testPlugin.

@Test
public void testPlugin() {
    ThriftPlugin plugin = loadPlugin(ThriftPlugin.class);
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    assertInstanceOf(factory, ThriftConnectorFactory.class);
    Map<String, String> config = ImmutableMap.of("presto.thrift.client.addresses", "localhost:7779");
    Connector connector = factory.create("test", config, new TestingConnectorContext());
    assertNotNull(connector);
    assertInstanceOf(connector, ThriftConnector.class);
}
Also used : Connector(io.prestosql.spi.connector.Connector) ConnectorFactory(io.prestosql.spi.connector.ConnectorFactory) TestingConnectorContext(io.prestosql.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 4 with TestingConnectorContext

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

the class TestSqlServerPlugin method testCreateConnector.

@Test
public void testCreateConnector() {
    Plugin plugin = new SqlServerPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext());
}
Also used : ConnectorFactory(io.prestosql.spi.connector.ConnectorFactory) TestingConnectorContext(io.prestosql.testing.TestingConnectorContext) Plugin(io.prestosql.spi.Plugin) Test(org.testng.annotations.Test)

Example 5 with TestingConnectorContext

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

the class TestTransactionManager method testAbortedTransactionWorkflow.

@Test
public void testAbortedTransactionWorkflow() {
    try (IdleCheckExecutor executor = new IdleCheckExecutor()) {
        CatalogManager catalogManager = new CatalogManager();
        TransactionManager transactionManager = InMemoryTransactionManager.create(new TransactionManagerConfig(), executor.getExecutor(), catalogManager, finishingExecutor);
        Connector c1 = new TpchConnectorFactory().create(CATALOG, ImmutableMap.of(), new TestingConnectorContext());
        registerConnector(catalogManager, transactionManager, CATALOG, CATALOG_NAME, c1);
        TransactionId transactionId = transactionManager.beginTransaction(false);
        assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId);
        assertFalse(transactionInfo.isAutoCommitContext());
        assertTrue(transactionInfo.getCatalogNames().isEmpty());
        assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
        ConnectorMetadata metadata = transactionManager.getOptionalCatalogMetadata(transactionId, CATALOG).get().getMetadata();
        metadata.listSchemaNames(TEST_SESSION.toConnectorSession(CATALOG_NAME));
        transactionInfo = transactionManager.getTransactionInfo(transactionId);
        assertEquals(transactionInfo.getCatalogNames(), ImmutableList.of(CATALOG_NAME, INFORMATION_SCHEMA_ID, SYSTEM_TABLES_ID));
        assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
        getFutureValue(transactionManager.asyncAbort(transactionId));
        assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    }
}
Also used : Connector(io.prestosql.spi.connector.Connector) InformationSchemaConnector(io.prestosql.connector.informationschema.InformationSchemaConnector) SystemConnector(io.prestosql.connector.system.SystemConnector) TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) TestingConnectorContext(io.prestosql.testing.TestingConnectorContext) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata) CatalogManager(io.prestosql.metadata.CatalogManager) Test(org.testng.annotations.Test)

Aggregations

TestingConnectorContext (io.prestosql.testing.TestingConnectorContext)22 Test (org.testng.annotations.Test)16 ConnectorFactory (io.prestosql.spi.connector.ConnectorFactory)11 Connector (io.prestosql.spi.connector.Connector)9 Plugin (io.prestosql.spi.Plugin)8 InformationSchemaConnector (io.prestosql.connector.informationschema.InformationSchemaConnector)4 SystemConnector (io.prestosql.connector.system.SystemConnector)4 TpchConnectorFactory (io.prestosql.plugin.tpch.TpchConnectorFactory)4 ConnectorContext (io.prestosql.spi.connector.ConnectorContext)4 CatalogManager (io.prestosql.metadata.CatalogManager)3 ConnectorMetadata (io.prestosql.spi.connector.ConnectorMetadata)3 ConnectorTransactionHandle (io.prestosql.spi.connector.ConnectorTransactionHandle)2 ManagedLedgerConfig (org.apache.bookkeeper.mledger.ManagedLedgerConfig)2 MockedPulsarServiceBaseTest (org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)2 TopicName (org.apache.pulsar.common.naming.TopicName)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Catalog (io.prestosql.metadata.Catalog)1 InMemoryNodeManager (io.prestosql.metadata.InMemoryNodeManager)1 Metadata (io.prestosql.metadata.Metadata)1 CatalogName (io.prestosql.spi.connector.CatalogName)1