Search in sources :

Example 21 with ClientFixture

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

the class TestSimpleExternalSort method sortOneKeyDescendingMergeSort.

@Test
public void sortOneKeyDescendingMergeSort() throws Throwable {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        List<QueryDataBatch> results = client.queryBuilder().physicalResource("xsort/one_key_sort_descending.json").results();
        assertEquals(1_000_000, client.countResults(results));
        validateResults(client.allocator(), results);
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest) DrillTest(org.apache.drill.test.DrillTest)

Example 22 with ClientFixture

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

the class TestSimpleExternalSort method outOfMemoryExternalSort.

@Test
public void outOfMemoryExternalSort() throws Throwable {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty("drill.memory.fragment.max", 50_000_000).configProperty("drill.memory.fragment.initial", 2_000_000).configProperty("drill.memory.operator.max", 30_000_000).configProperty("drill.memory.operator.initial", 2_000_000);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        List<QueryDataBatch> results = client.queryBuilder().physicalResource("/xsort/oom_sort_test.json").results();
        assertEquals(10_000_000, client.countResults(results));
        long previousBigInt = Long.MAX_VALUE;
        for (QueryDataBatch b : results) {
            RecordBatchLoader loader = new RecordBatchLoader(client.allocator());
            if (b.getHeader().getRowCount() > 0) {
                loader.load(b.getHeader().getDef(), b.getData());
                BigIntVector c1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("blue", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
                BigIntVector.Accessor a1 = c1.getAccessor();
                for (int i = 0; i < c1.getAccessor().getValueCount(); i++) {
                    assertTrue(String.format("%d < %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i));
                    previousBigInt = a1.get(i);
                }
                assertTrue(String.format("%d == %d", a1.get(0), a1.get(a1.getValueCount() - 1)), a1.get(0) != a1.get(a1.getValueCount() - 1));
            }
            loader.clear();
            b.release();
        }
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) SchemaPath(org.apache.drill.common.expression.SchemaPath) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) BigIntVector(org.apache.drill.exec.vector.BigIntVector) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest) DrillTest(org.apache.drill.test.DrillTest)

Example 23 with ClientFixture

use of org.apache.drill.test.ClientFixture 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)

Example 24 with ClientFixture

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

the class TestOpenTSDBPlugin method testInformationSchemaWrongPluginConfig.

@Test
public void testInformationSchemaWrongPluginConfig() throws Exception {
    try (ClusterFixture cluster = ClusterFixture.bareBuilder(dirTestWatcher).build();
        ClientFixture client = cluster.clientFixture()) {
        int portNumber = QueryTestUtil.getFreePortNumber(10_000, 200);
        final StoragePluginRegistry pluginRegistry = cluster.drillbit().getContext().getStorage();
        OpenTSDBStoragePluginConfig storagePluginConfig = new OpenTSDBStoragePluginConfig(String.format("http://localhost:%s/", portNumber));
        storagePluginConfig.setEnabled(true);
        pluginRegistry.put(OpenTSDBStoragePluginConfig.NAME, storagePluginConfig);
        String query = "select * from information_schema.`views`";
        client.queryBuilder().sql(query).run();
    }
}
Also used : OpenTSDBStoragePluginConfig(org.apache.drill.exec.store.openTSDB.OpenTSDBStoragePluginConfig) ClusterFixture(org.apache.drill.test.ClusterFixture) StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) ClientFixture(org.apache.drill.test.ClientFixture) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 25 with ClientFixture

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

the class TestSemiJoin method testInClauseWithSemiJoinDisabled.

@Test
public void testInClauseWithSemiJoinDisabled() throws Exception {
    String sql = "select employee_id, full_name from cp.`employee.json` where employee_id in (select employee_id from cp.`employee.json` )";
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.SEMIJOIN.getOptionName(), false);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        String queryPlan = client.queryBuilder().sql(sql).explainText();
        assertTrue(!queryPlan.contains("semi-join: =[true]"));
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) OperatorTest(org.apache.drill.categories.OperatorTest) SlowTest(org.apache.drill.categories.SlowTest) Test(org.junit.Test)

Aggregations

ClientFixture (org.apache.drill.test.ClientFixture)122 Test (org.junit.Test)102 ClusterFixture (org.apache.drill.test.ClusterFixture)99 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)89 SlowTest (org.apache.drill.categories.SlowTest)46 OptionsTest (org.apache.drill.categories.OptionsTest)36 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)28 BaseTest (org.apache.drill.test.BaseTest)20 ClusterTest (org.apache.drill.test.ClusterTest)16 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)12 DrillTest (org.apache.drill.test.DrillTest)10 OperatorTest (org.apache.drill.categories.OperatorTest)8 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)7 RestClientFixture (org.apache.drill.test.RestClientFixture)4 ArrayList (java.util.ArrayList)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)3 BigIntVector (org.apache.drill.exec.vector.BigIntVector)3 File (java.io.File)2 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)2