Search in sources :

Example 1 with UpdateSettingsPlan

use of io.crate.planner.node.ddl.UpdateSettingsPlan in project crate by crate.

the class DependencyCarrierDDLTest method testClusterUpdateSettingsTask.

@Test
public void testClusterUpdateSettingsTask() throws Exception {
    final String persistentSetting = "stats.enabled";
    final String transientSetting = "bulk.request_timeout";
    // Update persistent only
    List<Assignment<Symbol>> persistentSettings = List.of(new Assignment<>(Literal.of(persistentSetting), List.of(Literal.of(false))));
    UpdateSettingsPlan node = new UpdateSettingsPlan(persistentSettings, true);
    PlannerContext plannerContext = mock(PlannerContext.class);
    Bucket objects = executePlan(node, plannerContext);
    assertThat(objects, contains(isRow(1L)));
    assertEquals("false", client().admin().cluster().prepareState().execute().actionGet().getState().metadata().persistentSettings().get(persistentSetting));
    // Update transient only
    List<Assignment<Symbol>> transientSettings = List.of(new Assignment<>(Literal.of(transientSetting), List.of(Literal.of("123s"))));
    node = new UpdateSettingsPlan(transientSettings, false);
    objects = executePlan(node, plannerContext);
    assertThat(objects, contains(isRow(1L)));
    assertEquals("123s", client().admin().cluster().prepareState().execute().actionGet().getState().metadata().transientSettings().get(transientSetting));
}
Also used : Assignment(io.crate.sql.tree.Assignment) PlannerContext(io.crate.planner.PlannerContext) Bucket(io.crate.data.Bucket) UpdateSettingsPlan(io.crate.planner.node.ddl.UpdateSettingsPlan) Test(org.junit.Test)

Example 2 with UpdateSettingsPlan

use of io.crate.planner.node.ddl.UpdateSettingsPlan in project crate by crate.

the class PlannerTest method testSetPlan.

@Test
public void testSetPlan() throws Exception {
    UpdateSettingsPlan plan = e.plan("set GLOBAL PERSISTENT stats.jobs_log_size=1024");
    assertThat(plan.settings(), contains(new Assignment<>(Literal.of("stats.jobs_log_size"), List.of(Literal.of(1024)))));
    assertThat(plan.isPersistent(), is(true));
    plan = e.plan("set GLOBAL TRANSIENT stats.enabled=false,stats.jobs_log_size=0");
    assertThat(plan.settings().size(), is(2));
    assertThat(plan.isPersistent(), is(false));
}
Also used : Assignment(io.crate.sql.tree.Assignment) UpdateSettingsPlan(io.crate.planner.node.ddl.UpdateSettingsPlan) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Aggregations

UpdateSettingsPlan (io.crate.planner.node.ddl.UpdateSettingsPlan)2 Assignment (io.crate.sql.tree.Assignment)2 Test (org.junit.Test)2 Bucket (io.crate.data.Bucket)1 PlannerContext (io.crate.planner.PlannerContext)1 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)1