Search in sources :

Example 6 with SettingsFilter

use of org.opensearch.common.settings.SettingsFilter in project OpenSearch by opensearch-project.

the class RenamedTimeoutRequestParameterTests method testClusterGetSettings.

public void testClusterGetSettings() throws IOException {
    final SettingsFilter filter = new SettingsFilter(Collections.singleton("foo.filtered"));
    RestClusterGetSettingsAction action = new RestClusterGetSettingsAction(null, null, filter);
    Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBodyWithBothParams(), client));
    assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
    assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
Also used : RestClusterGetSettingsAction(org.opensearch.rest.action.admin.cluster.RestClusterGetSettingsAction) OpenSearchParseException(org.opensearch.OpenSearchParseException) IOException(java.io.IOException) SettingsFilter(org.opensearch.common.settings.SettingsFilter)

Example 7 with SettingsFilter

use of org.opensearch.common.settings.SettingsFilter in project OpenSearch by opensearch-project.

the class RenamedTimeoutRequestParameterTests method testClusterReroute.

public void testClusterReroute() throws IOException {
    final SettingsFilter filter = new SettingsFilter(Collections.singleton("foo.filtered"));
    RestClusterRerouteAction action = new RestClusterRerouteAction(filter);
    Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBodyWithBothParams(), client));
    assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
    assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
Also used : RestClusterRerouteAction(org.opensearch.rest.action.admin.cluster.RestClusterRerouteAction) OpenSearchParseException(org.opensearch.OpenSearchParseException) IOException(java.io.IOException) SettingsFilter(org.opensearch.common.settings.SettingsFilter)

Example 8 with SettingsFilter

use of org.opensearch.common.settings.SettingsFilter in project OpenSearch by opensearch-project.

the class RenamedTimeoutRequestParameterTests method testGetRepositories.

public void testGetRepositories() {
    final SettingsFilter filter = new SettingsFilter(Collections.singleton("foo.filtered"));
    RestGetRepositoriesAction action = new RestGetRepositoriesAction(filter);
    Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
    assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
    assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
Also used : RestGetRepositoriesAction(org.opensearch.rest.action.admin.cluster.RestGetRepositoriesAction) OpenSearchParseException(org.opensearch.OpenSearchParseException) IOException(java.io.IOException) SettingsFilter(org.opensearch.common.settings.SettingsFilter)

Example 9 with SettingsFilter

use of org.opensearch.common.settings.SettingsFilter in project OpenSearch by opensearch-project.

the class RenamedTimeoutRequestParameterTests method testClusterState.

public void testClusterState() throws IOException {
    final SettingsFilter filter = new SettingsFilter(Collections.singleton("foo.filtered"));
    RestClusterStateAction action = new RestClusterStateAction(filter);
    Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBodyWithBothParams(), client));
    assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
    assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
}
Also used : RestClusterStateAction(org.opensearch.rest.action.admin.cluster.RestClusterStateAction) OpenSearchParseException(org.opensearch.OpenSearchParseException) IOException(java.io.IOException) SettingsFilter(org.opensearch.common.settings.SettingsFilter)

Example 10 with SettingsFilter

use of org.opensearch.common.settings.SettingsFilter in project OpenSearch by opensearch-project.

the class RestClusterGetSettingsActionTests method runTestFilterSettingsTest.

private void runTestFilterSettingsTest(final BiConsumer<Metadata.Builder, Settings> md, final Function<ClusterGetSettingsResponse, Settings> s) {
    final Metadata.Builder mdBuilder = new Metadata.Builder();
    final Settings settings = Settings.builder().put("foo.filtered", "bar").put("foo.non_filtered", "baz").build();
    md.accept(mdBuilder, settings);
    final ClusterState.Builder builder = new ClusterState.Builder(ClusterState.EMPTY_STATE).metadata(mdBuilder);
    final SettingsFilter filter = new SettingsFilter(Collections.singleton("foo.filtered"));
    final Setting.Property[] properties = { Setting.Property.Dynamic, Setting.Property.Filtered, Setting.Property.NodeScope };
    final Set<Setting<?>> settingsSet = Stream.concat(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS.stream(), Stream.concat(Stream.of(Setting.simpleString("foo.filtered", properties)), Stream.of(Setting.simpleString("foo.non_filtered", properties)))).collect(Collectors.toSet());
    final ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, settingsSet);
    final ClusterGetSettingsResponse response = RestClusterGetSettingsAction.response(builder.build(), randomBoolean(), filter, clusterSettings, Settings.EMPTY);
    assertFalse(s.apply(response).hasValue("foo.filtered"));
    assertTrue(s.apply(response).hasValue("foo.non_filtered"));
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) ClusterGetSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse) ClusterSettings(org.opensearch.common.settings.ClusterSettings) Setting(org.opensearch.common.settings.Setting) Metadata(org.opensearch.cluster.metadata.Metadata) SettingsFilter(org.opensearch.common.settings.SettingsFilter) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings)

Aggregations

SettingsFilter (org.opensearch.common.settings.SettingsFilter)10 IOException (java.io.IOException)6 Settings (org.opensearch.common.settings.Settings)6 IndexNameExpressionResolver (org.opensearch.cluster.metadata.IndexNameExpressionResolver)5 IndexScopedSettings (org.opensearch.common.settings.IndexScopedSettings)5 ThreadPool (org.opensearch.threadpool.ThreadPool)5 OpenSearchParseException (org.opensearch.OpenSearchParseException)4 ClusterSettings (org.opensearch.common.settings.ClusterSettings)4 SettingsModule (org.opensearch.common.settings.SettingsModule)4 TestThreadPool (org.opensearch.threadpool.TestThreadPool)4 Supplier (java.util.function.Supplier)3 ActionFilters (org.opensearch.action.support.ActionFilters)3 ClusterState (org.opensearch.cluster.ClusterState)3 ActionPlugin (org.opensearch.plugins.ActionPlugin)3 RestController (org.opensearch.rest.RestController)3 RestHandler (org.opensearch.rest.RestHandler)3 UsageService (org.opensearch.usage.UsageService)3 Collections (java.util.Collections)2 Collections.emptyList (java.util.Collections.emptyList)2 Collections.emptySet (java.util.Collections.emptySet)2