Skip to content

Migrate x-pack-deprecation REST tests #131444

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:jira");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:pagerduty");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:slack");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:early-deprecation-rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:downsample:qa:with-security");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:enrich:qa:rest");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:enrich:qa:rest-with-advanced-security");
Expand Down
38 changes: 38 additions & 0 deletions x-pack/plugin/deprecation/qa/build.gradle
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
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

apply plugin: 'elasticsearch.internal-java-rest-test'
// Necessary to use tests in Serverless
apply plugin: 'elasticsearch.internal-test-artifact'

dependencies {
javaRestTestImplementation project(path: ':x-pack:plugin:deprecation:qa:common')
javaRestTestImplementation("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
javaRestTestImplementation("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")

clusterPlugins project(':x-pack:plugin:deprecation:qa::early-deprecation-plugin')
clusterPlugins project(':x-pack:plugin:deprecation:qa::deprecation-plugin')
}

tasks.named('javaRestTest') {
// Tried to just include deprecation, data-streams and ml, but apparently some other non
// immediately apparent plugin is needed
// Example failing build scan: https://gradle-enterprise.elastic.co/s/rxaz3vi2a3tao
usesDefaultDistribution("the .logs.deprecated index can not be written or read with a minimal plugin set")
}

restResources {
restApi {
include '_common', 'indices', 'index'
}
}

// Test clusters run with security disabled
tasks.named("javaRestTest") {
buildParams.withFipsEnabledOnly(it)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.deprecation;

import org.elasticsearch.common.settings.Setting;

public class DeprecationSettings {
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE1 = Setting.boolSetting(
"test.setting.deprecated.true1",
true,
Setting.Property.NodeScope,
Setting.Property.DeprecatedWarning,
Setting.Property.Dynamic
);
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE2 = Setting.boolSetting(
"test.setting.deprecated.true2",
true,
Setting.Property.NodeScope,
Setting.Property.DeprecatedWarning,
Setting.Property.Dynamic
);
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE3 = Setting.boolSetting(
"test.setting.deprecated.true3",
true,
Setting.Property.NodeScope,
Setting.Property.Deprecated,
Setting.Property.Dynamic
);
public static final Setting<Boolean> TEST_NOT_DEPRECATED_SETTING = Setting.boolSetting(
"test.setting.not_deprecated",
false,
Setting.Property.NodeScope,
Setting.Property.Dynamic
);

public static final String DEPRECATED_ENDPOINT = "[/_test_cluster/deprecated_settings] exists for deprecated tests";
public static final String DEPRECATED_USAGE = "[deprecated_settings] usage is deprecated. use [settings] instead";
public static final String DEPRECATED_WARN_USAGE =
"[deprecated_warn_settings] usage is deprecated but won't be breaking in next version";
public static final String COMPATIBLE_API_USAGE = "You are using a compatible API for this request";
}
20 changes: 20 additions & 0 deletions x-pack/plugin/deprecation/qa/deprecation-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

apply plugin: 'elasticsearch.base-internal-es-plugin'
apply plugin: 'elasticsearch.build'

esplugin {
name = 'deprecation-plugin'
description = 'Deprecated query plugin'
classname ='org.elasticsearch.xpack.deprecation.plugin.TestDeprecationPlugin'
}

dependencies {
compileOnly project(":server")
implementation project(':x-pack:plugin:deprecation:qa::common')
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

package org.elasticsearch.xpack.deprecation;
package org.elasticsearch.xpack.deprecation.plugin;

import org.apache.lucene.search.Query;
import org.elasticsearch.TransportVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.deprecation;
package org.elasticsearch.xpack.deprecation.plugin;

import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.logging.DeprecationCategory;
Expand All @@ -26,6 +26,14 @@

import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.COMPATIBLE_API_USAGE;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.DEPRECATED_ENDPOINT;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.DEPRECATED_USAGE;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.DEPRECATED_WARN_USAGE;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE1;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE2;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE3;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_NOT_DEPRECATED_SETTING;

/**
* Enables testing {@code DeprecationRestHandler} via integration tests by guaranteeing a deprecated REST endpoint.
Expand All @@ -36,34 +44,6 @@
public class TestDeprecationHeaderRestAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(TestDeprecationHeaderRestAction.class);

public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE1 = Setting.boolSetting(
"test.setting.deprecated.true1",
true,
Setting.Property.NodeScope,
Setting.Property.DeprecatedWarning,
Setting.Property.Dynamic
);
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE2 = Setting.boolSetting(
"test.setting.deprecated.true2",
true,
Setting.Property.NodeScope,
Setting.Property.DeprecatedWarning,
Setting.Property.Dynamic
);
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE3 = Setting.boolSetting(
"test.setting.deprecated.true3",
true,
Setting.Property.NodeScope,
Setting.Property.Deprecated,
Setting.Property.Dynamic
);
public static final Setting<Boolean> TEST_NOT_DEPRECATED_SETTING = Setting.boolSetting(
"test.setting.not_deprecated",
false,
Setting.Property.NodeScope,
Setting.Property.Dynamic
);

private static final Map<String, Setting<?>> SETTINGS_MAP = Map.of(
TEST_DEPRECATED_SETTING_TRUE1.getKey(),
TEST_DEPRECATED_SETTING_TRUE1,
Expand All @@ -75,12 +55,6 @@ public class TestDeprecationHeaderRestAction extends BaseRestHandler {
TEST_NOT_DEPRECATED_SETTING
);

public static final String DEPRECATED_ENDPOINT = "[/_test_cluster/deprecated_settings] exists for deprecated tests";
public static final String DEPRECATED_USAGE = "[deprecated_settings] usage is deprecated. use [settings] instead";
public static final String DEPRECATED_WARN_USAGE =
"[deprecated_warn_settings] usage is deprecated but won't be breaking in next version";
public static final String COMPATIBLE_API_USAGE = "You are using a compatible API for this request";

private final Settings settings;

public TestDeprecationHeaderRestAction(Settings settings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.deprecation;
package org.elasticsearch.xpack.deprecation.plugin;

import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes;
Expand All @@ -28,6 +28,9 @@
import java.util.function.Supplier;

import static java.util.Collections.singletonList;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE1;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE2;
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_NOT_DEPRECATED_SETTING;

/**
* Adds {@link TestDeprecationHeaderRestAction} for testing deprecation requests via HTTP.
Expand All @@ -51,11 +54,7 @@ public List<RestHandler> getRestHandlers(

@Override
public List<Setting<?>> getSettings() {
return Arrays.asList(
TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE1,
TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE2,
TestDeprecationHeaderRestAction.TEST_NOT_DEPRECATED_SETTING
);
return Arrays.asList(TEST_DEPRECATED_SETTING_TRUE1, TEST_DEPRECATED_SETTING_TRUE2, TEST_NOT_DEPRECATED_SETTING);
}

@Override
Expand Down
22 changes: 22 additions & 0 deletions x-pack/plugin/deprecation/qa/early-deprecation-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

apply plugin: 'elasticsearch.base-internal-es-plugin'
apply plugin: 'elasticsearch.build'

esplugin {
name = 'early-deprecation-plugin'
description = 'Deprecated query plugin'
classname = 'org.elasticsearch.xpack.deprecation.earlyplugin.EarlyDeprecationTestPlugin'
}

dependencies {
compileOnly project(":server")
}
tasks.named("javadoc").configure {
enabled = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.deprecation;
package org.elasticsearch.xpack.deprecation.earlyplugin;

import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
Expand Down
48 changes: 0 additions & 48 deletions x-pack/plugin/deprecation/qa/early-deprecation-rest/build.gradle

This file was deleted.

44 changes: 0 additions & 44 deletions x-pack/plugin/deprecation/qa/rest/build.gradle

This file was deleted.

Loading