Search in sources :

Example 21 with OperatorFixture

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

the class TestBootstrapLoader method testBootstrapLoader.

@Test
public void testBootstrapLoader() throws Exception {
    try (OperatorFixture fixture = OperatorFixture.standardFixture(dirTestWatcher)) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        PluginBootstrapLoaderImpl loader = new PluginBootstrapLoaderImpl(context);
        Map<String, URL> pluginURLMap = new HashMap<>();
        StoragePlugins plugins = loader.loadBootstrapPlugins(pluginURLMap);
        // 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("cp"));
    // Cannot test contrib plugins here: they are not yet
    // available when this test is run. We'll trust the
    // classpath scanner.
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) HashMap(java.util.HashMap) OperatorFixture(org.apache.drill.test.OperatorFixture) URL(java.net.URL) Test(org.junit.Test)

Example 22 with OperatorFixture

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

the class AbstractGenericCopierTest method testCopyRecords.

@Test
public void testCopyRecords() throws Exception {
    try (OperatorFixture operatorFixture = new OperatorFixture.Builder(baseDirTestWatcher).build()) {
        final BufferAllocator allocator = operatorFixture.allocator();
        final BatchSchema batchSchema = createTestSchema(BatchSchema.SelectionVectorMode.NONE);
        final RowSet srcRowSet = createSrcRowSet(allocator);
        final VectorContainer destContainer = new VectorContainer(allocator, batchSchema);
        destContainer.setRecordCount(0);
        final RowSet expectedRowSet = createExpectedRowset(allocator);
        MockRecordBatch mockRecordBatch = null;
        try {
            mockRecordBatch = new MockRecordBatch.Builder().sendData(srcRowSet).build(operatorFixture.getFragmentContext());
            mockRecordBatch.next();
            final Copier copier = createCopier(mockRecordBatch, destContainer, null);
            copier.copyRecords(0, 3);
            new RowSetComparison(expectedRowSet).verify(DirectRowSet.fromContainer(destContainer));
        } finally {
            if (mockRecordBatch != null) {
                mockRecordBatch.close();
            }
            srcRowSet.clear();
            destContainer.clear();
            expectedRowSet.clear();
        }
    }
}
Also used : RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) BatchSchema(org.apache.drill.exec.record.BatchSchema) DirectRowSet(org.apache.drill.exec.physical.rowSet.DirectRowSet) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) OperatorFixture(org.apache.drill.test.OperatorFixture) MockRecordBatch(org.apache.drill.exec.physical.impl.MockRecordBatch) BufferAllocator(org.apache.drill.exec.memory.BufferAllocator) VectorContainer(org.apache.drill.exec.record.VectorContainer) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Example 23 with OperatorFixture

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

the class TestSortImpl method testNullInput.

/**
 * Test for null input (no input batches). Note that, in this case,
 * we never see a schema.
 * @throws Exception
 */
@Test
public void testNullInput() throws Exception {
    try (OperatorFixture fixture = OperatorFixture.standardFixture()) {
        SortTestFixture sortTest = new SortTestFixture(fixture);
        sortTest.run();
    }
}
Also used : OperatorFixture(org.apache.drill.test.OperatorFixture) DrillTest(org.apache.drill.test.DrillTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 24 with OperatorFixture

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

the class TestQueryMemoryAlloc method testDefaultOptions.

@Test
public void testDefaultOptions() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder();
    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 40 GB, query memory dominates.
        mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 40 * ONE_GB);
        assertEquals(2 * ONE_GB, mem);
        // After 40 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 25 with OperatorFixture

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

the class TestQueryMemoryAlloc method testCustomPercent.

@Test
public void testCustomPercent() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder();
    builder.systemOption(ExecConstants.PERCENT_MEMORY_PER_QUERY_KEY, 0.10);
    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.10);
        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 20 GB, query memory dominates.
        mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 20 * ONE_GB);
        assertEquals(2 * ONE_GB, mem);
        // After 20 GB, the percent dominates
        mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 30 * ONE_GB);
        assertEquals(3 * 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)

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