Search in sources :

Example 16 with OperatorFixture

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

the class TestClassicLocator method testPrivateConnector.

@Test
public void testPrivateConnector() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    // See note above.
    // builder.configBuilder().put(ClassPathScanner.IMPLEMENTATIONS_SCAN_CACHE, false);
    builder.configBuilder().put(ExecConstants.PRIVATE_CONNECTORS, Collections.singletonList(StoragePluginFixture.class.getName()));
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        ConnectorLocator locator = new ClassicConnectorLocator(context);
        locator.init();
        Set<Class<? extends StoragePluginConfig>> result = locator.configClasses();
        // Now the private connector does appear.
        assertTrue(result.contains(StoragePluginFixtureConfig.class));
        // Create a plugin instance given a config
        StoragePluginFixtureConfig config = new StoragePluginFixtureConfig("some-mode");
        StoragePlugin plugin = locator.create("myplugin", config);
        assertNotNull(plugin);
        assertTrue(plugin instanceof StoragePluginFixture);
        // No-op
        locator.close();
    }
}
Also used : AbstractSecuredStoragePluginConfig(org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 17 with OperatorFixture

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

the class TestSystemPluginLocator method testSystemLocator.

// Uses a null Drillbit context. This is benign for the current
// set of system plugins. If this test fails, check if a system
// plugin uses the Drillbit context. Eventually, we'll use a different
// context for plugins. But, if the crash happens sooner, change this
// to a cluster test so a DrillbitContext is available.
@Test
public void testSystemLocator() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    try (OperatorFixture fixture = builder.build()) {
        PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
        ConnectorLocator locator = new SystemPluginLocator(context);
        locator.init();
        // No bootstrap or upgrade configs
        assertNull(locator.bootstrapPlugins());
        assertNull(locator.updatedPlugins());
        // No user-creatable configs
        assertNull(locator.configClasses());
        // Test intrinsic plugins
        assertNotNull(locator.get("sys"));
        Collection<StoragePlugin> intrinsics = locator.intrinsicPlugins();
        assertNotNull(intrinsics);
        assertTrue(intrinsics.contains(locator.get("sys")));
        // System plugins are not storable
        assertFalse(locator.storable());
        // Map from config to impl class
        assertSame(SystemTablePlugin.class, locator.connectorClassFor(SystemTablePluginConfig.class));
        // No-op
        locator.close();
    }
}
Also used : SystemTablePluginConfig(org.apache.drill.exec.store.sys.SystemTablePluginConfig) OperatorFixture(org.apache.drill.test.OperatorFixture) Test(org.junit.Test)

Example 18 with OperatorFixture

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

the class TestBootstrapLoader method testMissingBootstrapFile.

@Test
public void testMissingBootstrapFile() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    // Note: file does not actually exist, which is intentional.
    String bootstrapFile = RESOURCE_BASE + "missing-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);
        try {
            loader.loadBootstrapPlugins(new HashMap<>());
            fail();
        } catch (IOException e) {
            assertTrue(e.getMessage().contains("Cannot find"));
            assertTrue(e.getMessage().contains(bootstrapFile));
        }
    }
}
Also used : OperatorFixture(org.apache.drill.test.OperatorFixture) IOException(java.io.IOException) Test(org.junit.Test)

Example 19 with OperatorFixture

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

the class TestBootstrapLoader method testFailedBootstrapLoad.

/**
 * Few things are as frustrating as tracking down plugin errors. Here we ensure
 * that the bootstrap loader explains where to look by naming the failed file
 * if bootstrap fails.
 */
@Test
public void testFailedBootstrapLoad() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    String bootstrapFile = RESOURCE_BASE + "bogus-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);
        try {
            loader.loadBootstrapPlugins(new HashMap<>());
            fail();
        } catch (IOException e) {
            // Resource URL
            assertTrue(e.getMessage().contains(bootstrapFile));
            // Jackson-provided bad key
            assertTrue(e.getCause().getMessage().contains("imABadBoy"));
        }
    }
}
Also used : OperatorFixture(org.apache.drill.test.OperatorFixture) IOException(java.io.IOException) Test(org.junit.Test)

Example 20 with OperatorFixture

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

the class TestBootstrapLoader method testMissingBootstrapUpgrades.

@Test
public void testMissingBootstrapUpgrades() throws Exception {
    OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    // Note: file does not actually exist, which is intentional.
    String bootstrapFile = RESOURCE_BASE + "missing-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();
        assertNull(plugins);
    }
}
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