Skip to content

Commit 8b77912

Browse files
authored
Migrate x-pack-deprecation REST tests (#131444) (#132750)
1 parent 72cf7fb commit 8b77912

File tree

14 files changed

+226
-149
lines changed

14 files changed

+226
-149
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
5656
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:jira");
5757
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:pagerduty");
5858
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:slack");
59-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:early-deprecation-rest");
60-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:rest");
6159
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:downsample:qa:with-security");
6260
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search:qa:rest");
6361
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:ccs-rolling-upgrade");
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
apply plugin: 'elasticsearch.internal-java-rest-test'
9+
// Necessary to use tests in Serverless
10+
apply plugin: 'elasticsearch.internal-test-artifact'
11+
12+
dependencies {
13+
javaRestTestImplementation project(path: ':x-pack:plugin:deprecation:qa:common')
14+
javaRestTestImplementation("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
15+
javaRestTestImplementation("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")
16+
17+
clusterModules project(':x-pack:plugin:deprecation:qa::early-deprecation-plugin')
18+
clusterModules project(':x-pack:plugin:deprecation:qa::deprecation-plugin')
19+
clusterModules project(':modules:ingest-common')
20+
clusterModules project(':modules:mapper-extras')
21+
clusterModules project(':modules:data-streams')
22+
clusterModules project(xpackModule('stack'))
23+
clusterModules project(xpackModule('deprecation'))
24+
clusterModules project(xpackModule('ilm'))
25+
clusterModules project(xpackModule('ml'))
26+
clusterModules project(xpackModule('mapper-constant-keyword'))
27+
clusterModules project(xpackModule('wildcard'))
28+
clusterModules project(xpackModule('transform'))
29+
}
30+
31+
restResources {
32+
restApi {
33+
include '_common', 'indices', 'index'
34+
}
35+
}
36+
37+
// Test clusters run with security disabled
38+
tasks.named("javaRestTest") {
39+
buildParams.withFipsEnabledOnly(it)
40+
}
41+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.deprecation;
9+
10+
import org.elasticsearch.common.settings.Setting;
11+
12+
public class DeprecationSettings {
13+
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE1 = Setting.boolSetting(
14+
"test.setting.deprecated.true1",
15+
true,
16+
Setting.Property.NodeScope,
17+
Setting.Property.DeprecatedWarning,
18+
Setting.Property.Dynamic
19+
);
20+
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE2 = Setting.boolSetting(
21+
"test.setting.deprecated.true2",
22+
true,
23+
Setting.Property.NodeScope,
24+
Setting.Property.DeprecatedWarning,
25+
Setting.Property.Dynamic
26+
);
27+
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE3 = Setting.boolSetting(
28+
"test.setting.deprecated.true3",
29+
true,
30+
Setting.Property.NodeScope,
31+
Setting.Property.Deprecated,
32+
Setting.Property.Dynamic
33+
);
34+
public static final Setting<Boolean> TEST_NOT_DEPRECATED_SETTING = Setting.boolSetting(
35+
"test.setting.not_deprecated",
36+
false,
37+
Setting.Property.NodeScope,
38+
Setting.Property.Dynamic
39+
);
40+
41+
public static final String DEPRECATED_ENDPOINT = "[/_test_cluster/deprecated_settings] exists for deprecated tests";
42+
public static final String DEPRECATED_USAGE = "[deprecated_settings] usage is deprecated. use [settings] instead";
43+
public static final String DEPRECATED_WARN_USAGE =
44+
"[deprecated_warn_settings] usage is deprecated but won't be breaking in next version";
45+
public static final String COMPATIBLE_API_USAGE = "You are using a compatible API for this request";
46+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
apply plugin: 'elasticsearch.base-internal-es-plugin'
9+
apply plugin: 'elasticsearch.build'
10+
11+
esplugin {
12+
name = 'deprecation-plugin'
13+
description = 'Deprecated query plugin'
14+
classname ='org.elasticsearch.xpack.deprecation.plugin.TestDeprecationPlugin'
15+
}
16+
17+
dependencies {
18+
compileOnly project(":server")
19+
implementation project(':x-pack:plugin:deprecation:qa::common')
20+
}

x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecatedQueryBuilder.java renamed to x-pack/plugin/deprecation/qa/deprecation-plugin/src/main/java/org/elasticsearch/xpack/deprecation/plugin/TestDeprecatedQueryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
package org.elasticsearch.xpack.deprecation;
8+
package org.elasticsearch.xpack.deprecation.plugin;
99

1010
import org.apache.lucene.search.Query;
1111
import org.elasticsearch.TransportVersion;

x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecationHeaderRestAction.java renamed to x-pack/plugin/deprecation/qa/deprecation-plugin/src/main/java/org/elasticsearch/xpack/deprecation/plugin/TestDeprecationHeaderRestAction.java

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* 2.0; you may not use this file except in compliance with the Elastic License
55
* 2.0.
66
*/
7-
package org.elasticsearch.xpack.deprecation;
7+
package org.elasticsearch.xpack.deprecation.plugin;
88

99
import org.elasticsearch.client.internal.node.NodeClient;
1010
import org.elasticsearch.common.logging.DeprecationCategory;
@@ -26,6 +26,14 @@
2626

2727
import static org.elasticsearch.rest.RestRequest.Method.GET;
2828
import static org.elasticsearch.rest.RestRequest.Method.POST;
29+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.COMPATIBLE_API_USAGE;
30+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.DEPRECATED_ENDPOINT;
31+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.DEPRECATED_USAGE;
32+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.DEPRECATED_WARN_USAGE;
33+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE1;
34+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE2;
35+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE3;
36+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_NOT_DEPRECATED_SETTING;
2937

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

39-
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE1 = Setting.boolSetting(
40-
"test.setting.deprecated.true1",
41-
true,
42-
Setting.Property.NodeScope,
43-
Setting.Property.DeprecatedWarning,
44-
Setting.Property.Dynamic
45-
);
46-
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE2 = Setting.boolSetting(
47-
"test.setting.deprecated.true2",
48-
true,
49-
Setting.Property.NodeScope,
50-
Setting.Property.DeprecatedWarning,
51-
Setting.Property.Dynamic
52-
);
53-
public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE3 = Setting.boolSetting(
54-
"test.setting.deprecated.true3",
55-
true,
56-
Setting.Property.NodeScope,
57-
Setting.Property.Deprecated,
58-
Setting.Property.Dynamic
59-
);
60-
public static final Setting<Boolean> TEST_NOT_DEPRECATED_SETTING = Setting.boolSetting(
61-
"test.setting.not_deprecated",
62-
false,
63-
Setting.Property.NodeScope,
64-
Setting.Property.Dynamic
65-
);
66-
6747
private static final Map<String, Setting<?>> SETTINGS_MAP = Map.of(
6848
TEST_DEPRECATED_SETTING_TRUE1.getKey(),
6949
TEST_DEPRECATED_SETTING_TRUE1,
@@ -75,12 +55,6 @@ public class TestDeprecationHeaderRestAction extends BaseRestHandler {
7555
TEST_NOT_DEPRECATED_SETTING
7656
);
7757

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

8660
public TestDeprecationHeaderRestAction(Settings settings) {

x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecationPlugin.java renamed to x-pack/plugin/deprecation/qa/deprecation-plugin/src/main/java/org/elasticsearch/xpack/deprecation/plugin/TestDeprecationPlugin.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* 2.0; you may not use this file except in compliance with the Elastic License
55
* 2.0.
66
*/
7-
package org.elasticsearch.xpack.deprecation;
7+
package org.elasticsearch.xpack.deprecation.plugin;
88

99
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1010
import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -28,6 +28,9 @@
2828
import java.util.function.Supplier;
2929

3030
import static java.util.Collections.singletonList;
31+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE1;
32+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE2;
33+
import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_NOT_DEPRECATED_SETTING;
3134

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

5255
@Override
5356
public List<Setting<?>> getSettings() {
54-
return Arrays.asList(
55-
TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE1,
56-
TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE2,
57-
TestDeprecationHeaderRestAction.TEST_NOT_DEPRECATED_SETTING
58-
);
57+
return Arrays.asList(TEST_DEPRECATED_SETTING_TRUE1, TEST_DEPRECATED_SETTING_TRUE2, TEST_NOT_DEPRECATED_SETTING);
5958
}
6059

6160
@Override
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
apply plugin: 'elasticsearch.base-internal-es-plugin'
9+
apply plugin: 'elasticsearch.build'
10+
11+
esplugin {
12+
name = 'early-deprecation-plugin'
13+
description = 'Deprecated query plugin'
14+
classname = 'org.elasticsearch.xpack.deprecation.earlyplugin.EarlyDeprecationTestPlugin'
15+
}
16+
17+
dependencies {
18+
compileOnly project(":server")
19+
}
20+
tasks.named("javadoc").configure {
21+
enabled = false
22+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* 2.0; you may not use this file except in compliance with the Elastic License
55
* 2.0.
66
*/
7-
package org.elasticsearch.xpack.deprecation;
7+
package org.elasticsearch.xpack.deprecation.earlyplugin;
88

99
import org.elasticsearch.common.logging.DeprecationCategory;
1010
import org.elasticsearch.common.logging.DeprecationLogger;

x-pack/plugin/deprecation/qa/early-deprecation-rest/build.gradle

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)