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