Search in sources :

Example 1 with ClusterFixture

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

the class TestValidationOptions method testOptions.

// To validate these tests, set breakpoints in ImplCreator
// and IteratorValidatorBatchIterator to see if the options
// work as expected.
@Test
public void testOptions() throws Exception {
    FixtureBuilder builder = ClusterFixture.builder().maxParallelization(1).configProperty(ExecConstants.ENABLE_ITERATOR_VALIDATION, false).configProperty(ExecConstants.ENABLE_VECTOR_VALIDATION, false).sessionOption(ExecConstants.ENABLE_ITERATOR_VALIDATION_OPTION, true).sessionOption(ExecConstants.ENABLE_VECTOR_VALIDATION_OPTION, true);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        boolean hasAssertions = false;
        assert hasAssertions = true;
        assertFalse(hasAssertions);
        String sql = "SELECT id_i, name_s10 FROM `mock`.`customers_10`";
        client.queryBuilder().sql(sql).run();
        client.alterSession(ExecConstants.ENABLE_VECTOR_VALIDATION, false);
        client.queryBuilder().sql(sql).run();
        client.alterSession(ExecConstants.ENABLE_ITERATOR_VALIDATION, false);
        client.queryBuilder().sql(sql).run();
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) FixtureBuilder(org.apache.drill.test.FixtureBuilder) ClientFixture(org.apache.drill.test.ClientFixture) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Example 2 with ClusterFixture

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

the class TestValidationOptions method testConfig.

/**
   * Config options override session options. Config options allow passing in
   * the setting at run time on the command line. This is a work-around for the
   * fact that the config system has no generic solution at present.
   *
   * @throws Exception if anything goes wrong
   */
@Test
public void testConfig() throws Exception {
    FixtureBuilder builder = ClusterFixture.builder().maxParallelization(1).configProperty(ExecConstants.ENABLE_ITERATOR_VALIDATION, true).configProperty(ExecConstants.ENABLE_VECTOR_VALIDATION, true).sessionOption(ExecConstants.ENABLE_ITERATOR_VALIDATION_OPTION, false).sessionOption(ExecConstants.ENABLE_VECTOR_VALIDATION_OPTION, false);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        boolean hasAssertions = false;
        assert hasAssertions = true;
        assertFalse(hasAssertions);
        String sql = "SELECT id_i, name_s10 FROM `mock`.`customers_10`";
        client.queryBuilder().sql(sql).run();
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) FixtureBuilder(org.apache.drill.test.FixtureBuilder) ClientFixture(org.apache.drill.test.ClientFixture) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Example 3 with ClusterFixture

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

the class TestSimpleExternalSort method mergeSortWithSv2.

/**
   * Tests the external sort using an in-memory sort. Relies on default memory
   * settings to be large enough to do the in-memory sort (there is,
   * unfortunately, no way to double-check that no spilling was done.)
   * This must be checked manually by setting a breakpoint in the in-memory
   * sort routine.
   *
   * @param testLegacy
   * @throws Exception
   */
private void mergeSortWithSv2(boolean testLegacy) throws Exception {
    try (ClusterFixture cluster = ClusterFixture.standardCluster();
        ClientFixture client = cluster.clientFixture()) {
        chooseImpl(client, testLegacy);
        List<QueryDataBatch> results = client.queryBuilder().physicalResource("xsort/one_key_sort_descending_sv2.json").results();
        assertEquals(500000, 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)

Example 4 with ClusterFixture

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

the class TestSimpleExternalSort method outOfMemoryExternalSort.

private void outOfMemoryExternalSort(boolean testLegacy) throws Throwable {
    FixtureBuilder builder = ClusterFixture.builder().configProperty("drill.memory.fragment.max", 50000000).configProperty("drill.memory.fragment.initial", 2000000).configProperty("drill.memory.operator.max", 30000000).configProperty("drill.memory.operator.initial", 2000000);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        chooseImpl(client, testLegacy);
        List<QueryDataBatch> results = client.queryBuilder().physicalResource("/xsort/oom_sort_test.json").results();
        assertEquals(10000000, client.countResults(results));
        long previousBigInt = Long.MAX_VALUE;
        int recordCount = 0;
        int batchCount = 0;
        for (QueryDataBatch b : results) {
            RecordBatchLoader loader = new RecordBatchLoader(client.allocator());
            if (b.getHeader().getRowCount() > 0) {
                batchCount++;
                loader.load(b.getHeader().getDef(), b.getData());
                @SuppressWarnings("resource") 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++) {
                    recordCount++;
                    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();
        }
        System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) FixtureBuilder(org.apache.drill.test.FixtureBuilder) SchemaPath(org.apache.drill.common.expression.SchemaPath) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) ClientFixture(org.apache.drill.test.ClientFixture) BigIntVector(org.apache.drill.exec.vector.BigIntVector)

Example 5 with ClusterFixture

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

the class TestSimpleExternalSort method sortOneKeyDescendingMergeSort.

private void sortOneKeyDescendingMergeSort(boolean testLegacy) throws Throwable {
    try (ClusterFixture cluster = ClusterFixture.standardCluster();
        ClientFixture client = cluster.clientFixture()) {
        chooseImpl(client, testLegacy);
        List<QueryDataBatch> results = client.queryBuilder().physicalResource("xsort/one_key_sort_descending.json").results();
        assertEquals(1000000, 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)

Aggregations

ClientFixture (org.apache.drill.test.ClientFixture)7 ClusterFixture (org.apache.drill.test.ClusterFixture)7 FixtureBuilder (org.apache.drill.test.FixtureBuilder)5 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)4 DrillTest (org.apache.drill.test.DrillTest)3 Test (org.junit.Test)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)1 BigIntVector (org.apache.drill.exec.vector.BigIntVector)1