Search in sources :

Example 6 with ClusterFixtureBuilder

use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.

the class TestValidationOptions method testDefaults.

/**
 * Should do no validation with all-default options.
 *
 * @throws Exception
 */
@Test
public void testDefaults() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).maxParallelization(1);
    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) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Example 7 with ClusterFixtureBuilder

use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.

the class TestSimpleExternalSort method outOfMemoryExternalSort.

private void outOfMemoryExternalSort(boolean testLegacy) 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).configProperty(ExecConstants.EXTERNAL_SORT_DISABLE_MANAGED, testLegacy);
    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(10_000_000, 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) 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)

Example 8 with ClusterFixtureBuilder

use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.

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 {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.EXTERNAL_SORT_DISABLE_MANAGED, false);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        chooseImpl(client, testLegacy);
        List<QueryDataBatch> results = client.queryBuilder().physicalResource("xsort/one_key_sort_descending_sv2.json").results();
        assertEquals(500_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)

Example 9 with ClusterFixtureBuilder

use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.

the class TestSimpleExternalSort method sortOneKeyDescendingMergeSort.

private void sortOneKeyDescendingMergeSort(boolean testLegacy) throws Throwable {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.EXTERNAL_SORT_DISABLE_MANAGED, false);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        chooseImpl(client, testLegacy);
        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)

Example 10 with ClusterFixtureBuilder

use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.

the class TestConfigLinkage method testSessionPrecedence.

/* Test if altering session option takes precedence over system option */
@Test
public void testSessionPrecedence() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).systemOption(ExecConstants.SLICE_TARGET, 100000);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        client.queryBuilder().sql("ALTER SESSION SET `planner.slice_target` = 10000").run();
        String slice_target = client.queryBuilder().sql("SELECT val FROM sys.%s where name='planner.slice_target' and optionScope = 'SESSION'", SystemTable.OPTION_VAL.getTableName()).singletonString();
        assertEquals(slice_target, "10000");
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest) SlowTest(org.apache.drill.categories.SlowTest)

Aggregations

ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)156 ClusterFixture (org.apache.drill.test.ClusterFixture)102 Test (org.junit.Test)93 ClientFixture (org.apache.drill.test.ClientFixture)89 BeforeClass (org.junit.BeforeClass)47 SlowTest (org.apache.drill.categories.SlowTest)44 OptionsTest (org.apache.drill.categories.OptionsTest)34 BaseTest (org.apache.drill.test.BaseTest)27 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 DrillTest (org.apache.drill.test.DrillTest)14 OperatorTest (org.apache.drill.categories.OperatorTest)8 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)8 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)6 StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)5 PluginException (org.apache.drill.exec.store.StoragePluginRegistry.PluginException)5 File (java.io.File)4 ResourceManagerTest (org.apache.drill.categories.ResourceManagerTest)4 DefaultResourceManager (org.apache.drill.exec.work.foreman.rm.DefaultResourceManager)4 DistributedResourceManager (org.apache.drill.exec.work.foreman.rm.DistributedResourceManager)4 ResourceManager (org.apache.drill.exec.work.foreman.rm.ResourceManager)4