Search in sources :

Example 26 with OperatorFixture

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

the class TestBootstrapLoader method testDuplicateBootstrapEntries.

@Test
public void testDuplicateBootstrapEntries() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    String bootstrapFile = RESOURCE_BASE + "dup-bootstrap.json";
    builder.configBuilder().put(ExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILE, bootstrapFile);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        PluginBootstrapLoaderImpl loader = new PluginBootstrapLoaderImpl(context);
        StoragePlugins plugins = loader.loadBootstrapPlugins(new HashMap<>());
        // Duplicates noted in log; last one wins.
        StoragePluginConfig pluginConfig = plugins.getConfig("cp");
        assertNotNull(pluginConfig);
        assertTrue(pluginConfig instanceof FileSystemConfig);
        FileSystemConfig cpConfig = (FileSystemConfig) pluginConfig;
        assertNotNull(cpConfig.getFormats().get("tsv"));
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 27 with OperatorFixture

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

the class TestBootstrapLoader method testBootstrapLoaderWithFormats.

/**
 * Test a format bootstrap with a mock file. Can't use a real
 * file because those appear in modules not yet available when
 * this test runs.
 */
@Test
public void testBootstrapLoaderWithFormats() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    String bootstrapFile = RESOURCE_BASE + "mock-format-bootstrap.json";
    builder.configBuilder().put(ExecConstants.BOOTSTRAP_FORMAT_PLUGINS_FILE, bootstrapFile);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        PluginBootstrapLoader loader = new PluginBootstrapLoaderImpl(context);
        StoragePlugins plugins = loader.bootstrapPlugins();
        // bsv added to dfs
        StoragePluginConfig pluginConfig = plugins.getConfig("dfs");
        assertNotNull(pluginConfig);
        FileSystemConfig dfs = (FileSystemConfig) pluginConfig;
        assertNotNull(dfs.getFormats().get("bsv"));
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 28 with OperatorFixture

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

the class TestBootstrapLoader method testBootstrapLoaderWithUpgrades.

@Test
public void testBootstrapLoaderWithUpgrades() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    String bootstrapFile = RESOURCE_BASE + "mock-plugin-upgrade.json";
    builder.configBuilder().put(ExecConstants.UPGRADE_STORAGE_PLUGINS_FILE, bootstrapFile);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        PluginBootstrapLoader loader = new PluginBootstrapLoaderImpl(context);
        StoragePlugins plugins = loader.bootstrapPlugins();
        // dfs: removed psv
        StoragePluginConfig pluginConfig = plugins.getConfig("dfs");
        assertNotNull(pluginConfig);
        FileSystemConfig dfs = (FileSystemConfig) pluginConfig;
        assertNull(dfs.getFormats().get("psv"));
        assertNotNull(dfs.getFormats().get("csv"));
        // local added
        assertNotNull(plugins.getConfig("local"));
        // S3, bsv added
        pluginConfig = plugins.getConfig("s3");
        assertNotNull(pluginConfig);
        FileSystemConfig s3 = (FileSystemConfig) pluginConfig;
        assertNotNull(s3.getFormats().get("bsv"));
        // cp, left unchanged (not in upgrade file)
        assertNotNull(plugins.getConfig("cp"));
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 29 with OperatorFixture

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

the class TestBootstrapLoader method testBootstrapUpgrades.

@Test
public void testBootstrapUpgrades() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    String bootstrapFile = RESOURCE_BASE + "mock-plugin-upgrade.json";
    builder.configBuilder().put(ExecConstants.UPGRADE_STORAGE_PLUGINS_FILE, bootstrapFile);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        PluginBootstrapLoader loader = new PluginBootstrapLoaderImpl(context);
        StoragePlugins plugins = loader.updatedPlugins();
        assertNotNull(plugins);
        // dfs: removed psv
        StoragePluginConfig pluginConfig = plugins.getConfig("dfs");
        assertNotNull(pluginConfig);
        FileSystemConfig dfs = (FileSystemConfig) pluginConfig;
        assertNull(dfs.getFormats().get("psv"));
        assertNotNull(dfs.getFormats().get("csv"));
        // local added
        assertNotNull(plugins.getConfig("local"));
        // S3, bsv added
        pluginConfig = plugins.getConfig("s3");
        assertNotNull(pluginConfig);
        FileSystemConfig s3 = (FileSystemConfig) pluginConfig;
        assertNotNull(s3.getFormats().get("bsv"));
        // cp, left unchanged (not in upgrade file)
        assertNull(plugins.getConfig("cp"));
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 30 with OperatorFixture

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

the class TestClassicLocator method testClassList.

@Test
public void testClassList() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    // builder.configBuilder().put(ClassPathScanner.IMPLEMENTATIONS_SCAN_CACHE, false);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        ConnectorLocator locator = new ClassicConnectorLocator(context);
        locator.init();
        Set<Class<? extends StoragePluginConfig>> result = locator.configClasses();
        // Sanity check of known good class
        assertTrue(result.contains(FileSystemConfig.class));
        // System plugins do not appear
        assertFalse(result.contains(SystemTablePluginConfig.class));
        // Abstract classes do not appear
        assertFalse(result.contains(StoragePluginConfig.class));
        assertFalse(result.contains(AbstractSecuredStoragePluginConfig.class));
        // The private plugin class does not appear
        assertFalse(result.contains(StoragePluginFixtureConfig.class));
        // No intrinsic plugins
        assertNull(locator.get("dfs"));
        assertNull(locator.intrinsicPlugins());
        // Storable
        assertTrue(locator.storable());
        // Lookup by config
        assertSame(FileSystemPlugin.class, locator.connectorClassFor(FileSystemConfig.class));
        assertNull(locator.connectorClassFor(StoragePluginFixtureConfig.class));
        // No-op
        locator.close();
    }
}
Also used : SystemTablePluginConfig(org.apache.drill.exec.store.sys.SystemTablePluginConfig) AbstractSecuredStoragePluginConfig(org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) AbstractSecuredStoragePluginConfig(org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig) 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