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