Search in sources :

Example 91 with ClusterFixtureBuilder

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);
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 92 with ClusterFixtureBuilder

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");
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 93 with ClusterFixtureBuilder

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);
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 94 with ClusterFixtureBuilder

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);
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 95 with ClusterFixtureBuilder

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
        }
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) PluginException(org.apache.drill.exec.store.StoragePluginRegistry.PluginException) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test)

Aggregations

ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)156 ClusterFixture (org.apache.drill.test.ClusterFixture)102 Test (org.junit.Test)93 ClientFixture (org.apache.drill.test.ClientFixture)89 BeforeClass (org.junit.BeforeClass)47 SlowTest (org.apache.drill.categories.SlowTest)44 OptionsTest (org.apache.drill.categories.OptionsTest)34 BaseTest (org.apache.drill.test.BaseTest)27 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 DrillTest (org.apache.drill.test.DrillTest)14 OperatorTest (org.apache.drill.categories.OperatorTest)8 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)8 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)6 StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)5 PluginException (org.apache.drill.exec.store.StoragePluginRegistry.PluginException)5 File (java.io.File)4 ResourceManagerTest (org.apache.drill.categories.ResourceManagerTest)4 DefaultResourceManager (org.apache.drill.exec.work.foreman.rm.DefaultResourceManager)4 DistributedResourceManager (org.apache.drill.exec.work.foreman.rm.DistributedResourceManager)4 ResourceManager (org.apache.drill.exec.work.foreman.rm.ResourceManager)4