Search in sources :

Example 11 with OperatorFixture

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

the class TestQueryMemoryAlloc method testCustomFloor.

@Test
public void testCustomFloor() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    builder.systemOption(ExecConstants.PERCENT_MEMORY_PER_QUERY_KEY, 0.05);
    builder.systemOption(ExecConstants.MAX_QUERY_MEMORY_PER_NODE_KEY, 2 * ONE_GB);
    try (OperatorFixture fixture = builder.build()) {
        final OptionManager optionManager = fixture.getOptionManager();
        optionManager.setLocalOption(ExecConstants.PERCENT_MEMORY_PER_QUERY_KEY, 0.05);
        optionManager.setLocalOption(ExecConstants.MAX_QUERY_MEMORY_PER_NODE_KEY, 2 * ONE_GB);
        // Out-of-box memory, use query memory per node as floor.
        long mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 8 * ONE_GB);
        assertEquals(2 * ONE_GB, mem);
        // Up to 60 GB, query memory dominates.
        mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 60 * ONE_GB);
        assertEquals(3 * ONE_GB, mem);
        // After 60 GB, the percent dominates
        mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 100 * ONE_GB);
        assertEquals(5 * ONE_GB, mem);
    }
}
Also used : OperatorFixture(org.apache.drill.test.OperatorFixture) OptionManager(org.apache.drill.exec.server.options.OptionManager) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Example 12 with OperatorFixture

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

the class TestQueryMemoryAlloc method testOpMemory.

/**
 * Test with default options, various memory configs.
 * Since we can't change the actual CPUs on this node, use an
 * option to specify the number (rather than the usual 70% of
 * actual cores.)
 *
 * @throws Exception
 */
@Test
public void testOpMemory() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    builder.systemOption(ExecConstants.CPU_LOAD_AVERAGE_KEY, 0.7);
    builder.systemOption(ExecConstants.MAX_WIDTH_PER_NODE_KEY, 10);
    builder.systemOption(ExecConstants.MIN_MEMORY_PER_BUFFERED_OP_KEY, 40 * ONE_MB);
    try (OperatorFixture fixture = builder.build()) {
        final OptionManager optionManager = fixture.getOptionManager();
        optionManager.setLocalOption(ExecConstants.CPU_LOAD_AVERAGE_KEY, 0.7);
        optionManager.setLocalOption(ExecConstants.MAX_WIDTH_PER_NODE_KEY, 10);
        optionManager.setLocalOption(ExecConstants.MIN_MEMORY_PER_BUFFERED_OP_KEY, 40 * ONE_MB);
        // Enough memory to go above configured minimum.
        long opMinMem = MemoryAllocationUtilities.computeOperatorMemory(optionManager, 4 * ONE_GB, 2);
        assertEquals(4 * ONE_GB / 10 / 2, opMinMem);
        // Too little memory per operator. Use configured minimum.
        opMinMem = MemoryAllocationUtilities.computeOperatorMemory(optionManager, ONE_GB, 100);
        assertEquals(40 * ONE_MB, opMinMem);
    }
}
Also used : OperatorFixture(org.apache.drill.test.OperatorFixture) OptionManager(org.apache.drill.exec.server.options.OptionManager) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Example 13 with OperatorFixture

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

the class TestSortEmitOutcome method testSpillWithNoEmitOutcome.

/**
 * Verifies successful spilling in absence of EMIT outcome
 * @throws Exception
 */
@Test
public void testSpillWithNoEmitOutcome() throws Exception {
    final OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    // Configuration that forces Sort to spill after buffering 2 incoming batches with data
    builder.configBuilder().put(ExecConstants.EXTERNAL_SORT_BATCH_LIMIT, 2);
    final OperatorFixture fixture_local = builder.build();
    final RowSet.SingleRowSet local_nonEmptyInputRowSet1 = fixture_local.rowSetBuilder(inputSchema).addRow(3, 30, "item3").addRow(2, 20, "item2").build();
    final RowSet.SingleRowSet local_nonEmptyInputRowSet2 = fixture_local.rowSetBuilder(inputSchema).addRow(1, 10, "item1").build();
    final RowSet.SingleRowSet local_nonEmptyInputRowSet3 = fixture_local.rowSetBuilder(inputSchema).addRow(4, 40, "item4").build();
    inputContainer.add(local_nonEmptyInputRowSet1.container());
    inputContainer.add(local_nonEmptyInputRowSet2.container());
    inputContainer.add(local_nonEmptyInputRowSet3.container());
    inputOutcomes.add(OK_NEW_SCHEMA);
    inputOutcomes.add(OK);
    inputOutcomes.add(OK);
    final PhysicalOperator mockPopConfig_local = new MockStorePOP(null);
    final OperatorContext opContext_local = fixture_local.getFragmentContext().newOperatorContext(mockPopConfig_local);
    final MockRecordBatch mockInputBatch = new MockRecordBatch(fixture_local.getFragmentContext(), opContext_local, inputContainer, inputOutcomes, local_nonEmptyInputRowSet1.container().getSchema());
    final ExternalSortBatch sortBatch_local = new ExternalSortBatch(sortPopConfig, fixture_local.getFragmentContext(), mockInputBatch);
    assertTrue(sortBatch_local.next() == OK_NEW_SCHEMA);
    assertTrue(sortBatch_local.next() == OK_NEW_SCHEMA);
    assertTrue(sortBatch_local.getRecordCount() == 4);
    assertTrue(sortBatch_local.getSchema().getSelectionVectorMode() == BatchSchema.SelectionVectorMode.NONE);
    assertTrue(sortBatch_local.next() == NONE);
    // Release memory for row sets
    local_nonEmptyInputRowSet1.clear();
    local_nonEmptyInputRowSet2.clear();
    local_nonEmptyInputRowSet3.clear();
    sortBatch_local.close();
    fixture_local.close();
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) MockStorePOP(org.apache.drill.exec.store.mock.MockStorePOP) OperatorContext(org.apache.drill.exec.ops.OperatorContext) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) OperatorFixture(org.apache.drill.test.OperatorFixture) MockRecordBatch(org.apache.drill.exec.physical.impl.MockRecordBatch) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 14 with OperatorFixture

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

the class PerformanceTool method main.

public static void main(String[] args) {
    try (OperatorFixture fixture = OperatorFixture.standardFixture(null)) {
        for (int i = 0; i < 2; i++) {
            logger.info((i == 0) ? "Warmup" : "Test run");
            new RequiredVectorTester(fixture).runTest();
            new RequiredWriterTester(fixture).runTest();
            new NullableVectorTester(fixture).runTest();
            new NullableWriterTester(fixture).runTest();
            new RepeatedVectorTester(fixture).runTest();
            new ArrayWriterTester(fixture).runTest();
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        logger.error("Exception", e);
    }
}
Also used : OperatorFixture(org.apache.drill.test.OperatorFixture)

Example 15 with OperatorFixture

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

the class TestClassicLocator method testBootstrap.

@Test
public void testBootstrap() throws Exception {
    try (OperatorFixture fixture = OperatorFixture.standardFixture(dirTestWatcher)) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        ConnectorLocator locator = new ClassicConnectorLocator(context);
        locator.init();
        StoragePlugins plugins = locator.bootstrapPlugins();
        // Sanity test. Change this if the bootstrap file changes.
        // No need to test contents; here we assume serialization works.
        // See FormatPluginSerDeTest
        assertNotNull(plugins.getConfig("dfs"));
        assertNotNull(plugins.getConfig("s3"));
        assertNotNull(plugins.getConfig(StoragePluginTestUtils.CP_PLUGIN_NAME));
        // No-op
        locator.close();
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Aggregations

OperatorFixture (org.apache.drill.test.OperatorFixture)39 Test (org.junit.Test)36 DrillTest (org.apache.drill.test.DrillTest)20 OperatorTest (org.apache.drill.categories.OperatorTest)14 OptionManager (org.apache.drill.exec.server.options.OptionManager)8 StoragePlugins (org.apache.drill.exec.planner.logical.StoragePlugins)7 BatchSchema (org.apache.drill.exec.record.BatchSchema)7 StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)6 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)5 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)5 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)4 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)4 IOException (java.io.IOException)2 AbstractSecuredStoragePluginConfig (org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig)2 BufferAllocator (org.apache.drill.exec.memory.BufferAllocator)2 OperatorContext (org.apache.drill.exec.ops.OperatorContext)2 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)2 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)2 VectorContainer (org.apache.drill.exec.record.VectorContainer)2 MockStorePOP (org.apache.drill.exec.store.mock.MockStorePOP)2