Skip to content

Add xpack.eql.enabled feature flag, disabled by default. Enabled for gradle run task and integration tests. #51370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/plugin/eql/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,17 +22,44 @@
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(
new ActionHandler<>(EqlSearchAction.INSTANCE, TransportEqlSearchAction.class)
);
}

/**
* 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,
Expand All @@ -39,7 +68,11 @@ public List<RestHandler> getRestHandlers(Settings settings,
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));
}
}
Original file line number Diff line number Diff line change
@@ -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)));
}
}