Search in sources :

Example 1 with ExtraCredentialConfig

use of io.trino.plugin.jdbc.credential.ExtraCredentialConfig in project trino by trinodb.

the class TestCachingJdbcClient method testDifferentIdentityKeys.

@Test
public void testDifferentIdentityKeys() {
    CachingJdbcClient cachingJdbcClient = new CachingJdbcClient(database.getJdbcClient(), SESSION_PROPERTIES_PROVIDERS, new ExtraCredentialsBasedIdentityCacheMapping(new ExtraCredentialConfig().setUserCredentialName("user").setPasswordCredentialName("password")), FOREVER, true, 10000);
    ConnectorSession alice = createUserSession("alice");
    ConnectorSession bob = createUserSession("bob");
    JdbcTableHandle table = createTable(new SchemaTableName(schema, "table"));
    assertTableNamesCache(cachingJdbcClient).loads(2).misses(2).afterRunning(() -> {
        assertThat(cachingJdbcClient.getTableNames(alice, Optional.empty())).contains(table.getRequiredNamedRelation().getSchemaTableName());
        assertThat(cachingJdbcClient.getTableNames(bob, Optional.empty())).contains(table.getRequiredNamedRelation().getSchemaTableName());
    });
    assertTableNamesCache(cachingJdbcClient).hits(2).afterRunning(() -> {
        assertThat(cachingJdbcClient.getTableNames(alice, Optional.empty())).contains(table.getRequiredNamedRelation().getSchemaTableName());
        assertThat(cachingJdbcClient.getTableNames(bob, Optional.empty())).contains(table.getRequiredNamedRelation().getSchemaTableName());
    });
    // Drop tables by not using caching jdbc client
    jdbcClient.dropTable(SESSION, table);
}
Also used : ExtraCredentialConfig(io.trino.plugin.jdbc.credential.ExtraCredentialConfig) ConnectorSession(io.trino.spi.connector.ConnectorSession) TestingConnectorSession(io.trino.testing.TestingConnectorSession) SchemaTableName(io.trino.spi.connector.SchemaTableName) Test(org.testng.annotations.Test)

Aggregations

ExtraCredentialConfig (io.trino.plugin.jdbc.credential.ExtraCredentialConfig)1 ConnectorSession (io.trino.spi.connector.ConnectorSession)1 SchemaTableName (io.trino.spi.connector.SchemaTableName)1 TestingConnectorSession (io.trino.testing.TestingConnectorSession)1 Test (org.testng.annotations.Test)1