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.
}
}
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();
}
}
}
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();
}
}
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);
}
}
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);
}
}
Aggregations