mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Add xpack.eql.enabled feature flag, disabled by default. Enabled only for integration tests. (#51370)
Related to https://github.com/elastic/elasticsearch/issues/49581
This commit is contained in:
parent
d049de5b72
commit
d8f1735e39
@ -9,6 +9,7 @@ dependencies {
|
||||
|
||||
testClusters.integTest {
|
||||
testDistribution = 'DEFAULT'
|
||||
setting 'xpack.eql.enabled', 'true'
|
||||
setting 'xpack.license.self_generated.type', 'basic'
|
||||
setting 'xpack.monitoring.collection.enabled', 'true'
|
||||
}
|
||||
|
@ -5,12 +5,14 @@
|
||||
*/
|
||||
package org.elasticsearch.xpack.eql.plugin;
|
||||
|
||||
import org.elasticsearch.Build;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.IndexScopedSettings;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.plugins.ActionPlugin;
|
||||
@ -20,10 +22,19 @@ import org.elasticsearch.rest.RestHandler;
|
||||
import org.elasticsearch.xpack.eql.action.EqlSearchAction;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class EqlPlugin extends Plugin implements ActionPlugin {
|
||||
|
||||
public static final Setting<Boolean> EQL_ENABLED_SETTING = Setting.boolSetting(
|
||||
"xpack.eql.enabled",
|
||||
false,
|
||||
Setting.Property.NodeScope
|
||||
);
|
||||
|
||||
|
||||
@Override
|
||||
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
|
||||
return Arrays.asList(
|
||||
@ -31,6 +42,24 @@ public class EqlPlugin extends Plugin implements ActionPlugin {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings defined by EQL plugin.
|
||||
*
|
||||
* @return the settings
|
||||
*/
|
||||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
if (isSnapshot()) {
|
||||
return List.of(EQL_ENABLED_SETTING);
|
||||
} else {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isSnapshot() {
|
||||
return Build.CURRENT.isSnapshot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RestHandler> getRestHandlers(Settings settings,
|
||||
RestController restController,
|
||||
@ -39,7 +68,11 @@ public class EqlPlugin extends Plugin implements ActionPlugin {
|
||||
SettingsFilter settingsFilter,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
Supplier<DiscoveryNodes> nodesInCluster) {
|
||||
return Arrays.asList(
|
||||
new RestEqlSearchAction(restController));
|
||||
|
||||
boolean enabled = EQL_ENABLED_SETTING.get(settings);
|
||||
if (!enabled) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.asList(new RestEqlSearchAction(restController));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.xpack.eql.plugin;
|
||||
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
public class EqlPluginTests extends ESTestCase {
|
||||
public void testEnabledSettingRegisteredInSnapshotBuilds() {
|
||||
final EqlPlugin plugin = new EqlPlugin() {
|
||||
|
||||
@Override
|
||||
protected boolean isSnapshot() {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
assertThat(plugin.getSettings(), hasItem(EqlPlugin.EQL_ENABLED_SETTING));
|
||||
}
|
||||
|
||||
public void testEnabledSettingNotRegisteredInNonSnapshotBuilds() {
|
||||
final EqlPlugin plugin = new EqlPlugin() {
|
||||
|
||||
@Override
|
||||
protected boolean isSnapshot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
assertThat(plugin.getSettings(), not(hasItem(EqlPlugin.EQL_ENABLED_SETTING)));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user