Search in sources :

Example 1 with ClusterMockStorageFixture

use of org.apache.drill.test.ClusterMockStorageFixture in project drill by apache.

the class TestInfoSchemaFilterPushDown method testLazySchemaRegistration.

/**
 * As reported in DRILL-8057, even queries against INFORMATION_SCHEMA that
 * included a filter that could be pushed down would be penalised by eager
 * schema registration executed on every enabled storage plugin instance.
 * This resulted in slow or even failed INFORMATION_SCHEMA schema queries
 * when some storage plugin was unresponsive, even if it was not needed for
 * the query being run.  This test checks that lazy schema registration is
 * working by installing a mock storage plugin to act as a canary.
 */
@Test
public void testLazySchemaRegistration() throws Exception {
    ClusterMockStorageFixture cluster = ClusterFixture.builder(dirTestWatcher).buildCustomMockStorage();
    // This mock storage plugin throws an exception from registerSchemas which
    // would have been enough to correctly make this test fail were it not that
    // the exception gets swallowed by StoragePluginRegistryImpl so we need to
    // inspect a counter instead.
    cluster.insertMockStorage("registerSchema canary", true);
    ClientFixture client = cluster.clientFixture();
    final String query = "SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_SCHEMA='INFORMATION_SCHEMA'";
    client.queryBuilder().sql(query).run();
    StoragePluginRegistry spr = cluster.drillbit().getContext().getStorage();
    MockBreakageStorage mbs = (MockBreakageStorage) spr.getPlugin("registerSchema canary");
    // no attempt to register schemas on the canary should have been made
    assertEquals(0, mbs.registerAttemptCount);
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) MockBreakageStorage(org.apache.drill.exec.store.mock.MockBreakageStorage) ClusterMockStorageFixture(org.apache.drill.test.ClusterMockStorageFixture) ClientFixture(org.apache.drill.test.ClientFixture) Test(org.junit.Test)

Aggregations

StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)1 MockBreakageStorage (org.apache.drill.exec.store.mock.MockBreakageStorage)1 ClientFixture (org.apache.drill.test.ClientFixture)1 ClusterMockStorageFixture (org.apache.drill.test.ClusterMockStorageFixture)1 Test (org.junit.Test)1