use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.
the class TestConfigLinkage method testScopeAlterSystem.
/* Test if the option is altered at SYSTEM scope and the scope is actually SYSTEM */
@Test
public void testScopeAlterSystem() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
client.queryBuilder().sql("ALTER SYSTEM set `planner.slice_target`= 10000").run();
String scope = client.queryBuilder().sql("SELECT optionScope from sys.%s where name='planner.slice_target'", SystemTable.OPTION_VAL.getTableName()).singletonString();
Assert.assertEquals("SYSTEM", scope);
}
}
use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.
the class TestConfigLinkage method testSessionOption.
/* Test if session option takes precedence */
@Test
public void testSessionOption() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).sessionOption(ExecConstants.SLICE_TARGET, 10);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String slice_target = client.queryBuilder().sql("SELECT val FROM sys.%s where name='planner.slice_target' and optionScope = 'SESSION'", SystemTable.OPTION_VAL.getTableName()).singletonString();
assertEquals(slice_target, "10");
}
}
use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.
the class TestConfigLinkage method testInternalSystemOption.
@Test
public void testInternalSystemOption() throws Exception {
OptionDefinition optionDefinition = createMockPropOptionDefinition();
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).putDefinition(optionDefinition).configProperty(ExecConstants.bootDefaultFor(MOCK_PROPERTY), "a").systemOption(MOCK_PROPERTY, "blah");
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String mockProp = client.queryBuilder().sql("SELECT string_val FROM sys.%s where name='%s'", SystemTable.INTERNAL_OPTIONS.getTableName(), MOCK_PROPERTY).singletonString();
String mockProp2 = client.queryBuilder().sql("SELECT val FROM sys.%s where name='%s'", SystemTable.INTERNAL_OPTIONS_VAL.getTableName(), MOCK_PROPERTY).singletonString();
assertEquals("blah", mockProp);
assertEquals("blah", mockProp2);
}
}
use of org.apache.drill.test.ClusterFixtureBuilder in project drill by axbaretto.
the class TestConfigLinkage method testDefaultInternalValue.
@Test
public void testDefaultInternalValue() throws Exception {
OptionDefinition optionDefinition = createMockPropOptionDefinition();
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.bootDefaultFor(MOCK_PROPERTY), "a").putDefinition(optionDefinition);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String mockProp = client.queryBuilder().sql("SELECT string_val FROM sys.%s where name='%s'", SystemTable.INTERNAL_OPTIONS.getTableName(), MOCK_PROPERTY).singletonString();
String mockProp2 = client.queryBuilder().sql("SELECT val FROM sys.%s where name='%s'", SystemTable.INTERNAL_OPTIONS_VAL.getTableName(), MOCK_PROPERTY).singletonString();
assertEquals("a", mockProp);
assertEquals("a", mockProp2);
}
}
use of org.apache.drill.test.ClusterFixtureBuilder in project drill by apache.
the class TestPluginRegistry method testEnabledState.
/**
* Tests the dedicated setEnabled() method to cleanly update the
* enabled status of a plugin by name.
*/
@Test
public void testEnabledState() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
try (ClusterFixture cluster = builder.build()) {
StoragePluginRegistry registry = cluster.storageRegistry();
// Disable an enabled plugin
StoragePluginConfig config = registry.getStoredConfig(CP_PLUGIN_NAME);
assertTrue(config.isEnabled());
// Enable/disable has traditionally been done by changing
// the plugin outside of the registry, which leads to obvious
// race conditions.
// Tests synchronized version.
registry.setEnabled(CP_PLUGIN_NAME, true);
StoragePluginConfig savedConfig = registry.getStoredConfig(CP_PLUGIN_NAME);
assertEquals(config, savedConfig);
assertTrue(savedConfig.isEnabled());
registry.setEnabled(CP_PLUGIN_NAME, false);
savedConfig = registry.getStoredConfig(CP_PLUGIN_NAME);
assertEquals(config, savedConfig);
assertFalse(savedConfig.isEnabled());
// OK to disable twice
registry.setEnabled(CP_PLUGIN_NAME, false);
savedConfig = registry.getStoredConfig(CP_PLUGIN_NAME);
assertEquals(config, savedConfig);
assertFalse(savedConfig.isEnabled());
// Disabled plugins appear in the stored config map
Map<String, StoragePluginConfig> configMap = registry.storedConfigs();
assertTrue(configMap.containsKey(CP_PLUGIN_NAME));
assertEquals(config, configMap.get(CP_PLUGIN_NAME));
// Re-enable
registry.setEnabled(CP_PLUGIN_NAME, true);
savedConfig = registry.getStoredConfig(CP_PLUGIN_NAME);
assertEquals(config, savedConfig);
assertTrue(savedConfig.isEnabled());
// Error if plugin does not exist
try {
registry.setEnabled("foo", true);
fail();
} catch (PluginException e) {
// expected
}
try {
registry.setEnabled("foo", false);
fail();
} catch (PluginException e) {
// expected
}
// Error to mess with a system plugins
try {
registry.setEnabled(SYS_PLUGIN_NAME, true);
fail();
} catch (PluginException e) {
// expected
}
try {
registry.setEnabled(SYS_PLUGIN_NAME, false);
fail();
} catch (PluginException e) {
// expected
}
}
}
Aggregations