Skip to content

Commit 0c3806d

Browse files
jakelandisAdam Locke
authored and
Adam Locke
committed
[REST API compatibility] Move _xpack prefix compat tests to their own qa module (elastic#79501)
This commit moves where we the _xpack/* REST compatible tests are executed. The _xpack/* prefix was deprecated in 7x and removed in 8.x via elastic#35958. However, when deprecated the paths were also removed from the API spec in 7x. This means that these paths are not available to test with the YAML test framework. As part of the work to support REST API compatibility for 8.x these _xpack prefix paths were re-introduced when using compatibility. These paths were tested via the primary x-pack YAML rest tests using custom specs and transformations. These custom specs are needed to allow the testing framing work to use the _xpack/* paths and the transformations tell the tests to use the _xpack prefix. To avoid re-introducing these prefix paths in the 7.x spec, custom specs for the tests are used. This worked well for testing on the server, but after introducing the compatibility tests via the rest-resources-zip (elastic#78534) the transformed tests in that zip requires those custom specs to execute properly. Since these are re-introduced just for testing we do not want to add these to the zip file of specs. To allow the xpack prefix to continue to be tested AND allow the tests to execute as-is via the specs/tests in the rest-resource-zip BUT do not expose the need for custom specs in the zip file ; these tests have been moved to their own qa module. As an implementation detail, the tests in the new qa module are transformed twice. Once as determined by the main x-pack transforms for things like compatible type support, and then once again solely for the purpose for testing the xpack prefix.
1 parent ff0d10d commit 0c3806d

File tree

66 files changed

+199
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+199
-70
lines changed

x-pack/plugin/build.gradle

-70
Original file line numberDiff line numberDiff line change
@@ -110,76 +110,6 @@ tasks.named("yamlRestTestV7CompatTransform").configure{ task ->
110110
task.skipTest("ml/trained_model_cat_apis/Test cat trained models", "A type field was added to cat.ml_trained_models #73660, this is a backwards compatible change. Still this is a cat api, and we don't support them with rest api compatibility. (the test would be very hard to transform too)")
111111
task.skipTest("ml/categorization_agg/Test categorization aggregation with poor settings", "https://github.com/elastic/elasticsearch/pull/79586")
112112

113-
task.replaceKeyInDo("license.delete", "xpack-license.delete")
114-
task.replaceKeyInDo("license.get", "xpack-license.get")
115-
task.replaceKeyInDo("license.get_basic_status", "xpack-license.get_basic_status")
116-
task.replaceKeyInDo("license.get_trial_status", "xpack-license.get_trial_status")
117-
task.replaceKeyInDo("license.post", "xpack-license.post")
118-
task.replaceKeyInDo("license.post_start_basic", "xpack-license.post_start_basic")
119-
task.replaceKeyInDo("license.post_start_trial", "xpack-license.post_start_trial")
120-
task.addAllowedWarningRegex(".*_xpack/license.* is deprecated.*")
121-
122-
task.replaceKeyInDo("migration.deprecations", "xpack-migration.deprecations")
123-
task.addAllowedWarningRegex(".*_xpack/migration.* is deprecated.*")
124-
125-
task.replaceKeyInDo("rollup.delete_job", "xpack-rollup.delete_job")
126-
task.replaceKeyInDo("rollup.get_jobs", "xpack-rollup.get_jobs")
127-
task.replaceKeyInDo("rollup.get_rollup_caps", "xpack-rollup.get_rollup_caps")
128-
task.replaceKeyInDo("rollup.get_rollup_index_caps", "xpack-rollup.get_rollup_index_caps")
129-
task.replaceKeyInDo("rollup.put_job", "xpack-rollup.put_job")
130-
task.replaceKeyInDo("rollup.start_job", "xpack-rollup.start_job")
131-
task.replaceKeyInDo("rollup.stop_job", "xpack-rollup.stop_job")
132-
task.addAllowedWarningRegex(".*_xpack/rollup.* is deprecated.*")
133-
134-
task.replaceKeyInDo("ml.close_job", "xpack-ml.close_job")
135-
task.replaceKeyInDo("ml.delete_calendar", "xpack-ml.delete_calendar")
136-
task.replaceKeyInDo("ml.delete_calendar_event", "xpack-ml.delete_calendar_event")
137-
task.replaceKeyInDo("ml.delete_calendar_job", "xpack-ml.delete_calendar_job")
138-
task.replaceKeyInDo("ml.delete_datafeed", "xpack-ml.delete_datafeed")
139-
task.replaceKeyInDo("ml.delete_expired_data", "xpack-ml.delete_expired_data")
140-
task.replaceKeyInDo("ml.delete_filter", "xpack-ml.delete_filter")
141-
task.replaceKeyInDo("ml.delete_forecast", "xpack-ml.delete_forecast")
142-
task.replaceKeyInDo("ml.delete_job", "xpack-ml.delete_job")
143-
task.replaceKeyInDo("ml.delete_model_snapshot", "xpack-ml.delete_model_snapshot")
144-
task.replaceKeyInDo("ml.flush_job", "xpack-ml.flush_job")
145-
task.replaceKeyInDo("ml.forecast", "xpack-ml.forecast")
146-
task.replaceKeyInDo("ml.get_buckets", "xpack-ml.get_buckets")
147-
task.replaceKeyInDo("ml.get_calendar_events", "xpack-ml.get_calendar_events")
148-
task.replaceKeyInDo("ml.get_calendars", "xpack-ml.get_calendars")
149-
task.replaceKeyInDo("ml.get_categories", "xpack-ml.get_categories")
150-
task.replaceKeyInDo("ml.get_datafeed_stats", "xpack-ml.get_datafeed_stats")
151-
task.replaceKeyInDo("ml.get_datafeeds", "xpack-ml.get_datafeeds")
152-
task.replaceKeyInDo("ml.get_filters", "xpack-ml.get_filters")
153-
task.replaceKeyInDo("ml.get_influencers", "xpack-ml.get_influencers")
154-
task.replaceKeyInDo("ml.get_job_stats", "xpack-ml.get_job_stats")
155-
task.replaceKeyInDo("ml.get_jobs", "xpack-ml.get_jobs")
156-
task.replaceKeyInDo("ml.get_model_snapshots", "xpack-ml.get_model_snapshots")
157-
task.replaceKeyInDo("ml.get_overall_buckets", "xpack-ml.get_overall_buckets")
158-
task.replaceKeyInDo("ml.get_records", "xpack-ml.get_records")
159-
task.replaceKeyInDo("ml.info", "xpack-ml.info")
160-
task.replaceKeyInDo("ml.open_job", "xpack-ml.open_job")
161-
task.replaceKeyInDo("ml.post_calendar_events", "xpack-ml.post_calendar_events")
162-
task.replaceKeyInDo("ml.post_data", "xpack-ml.post_data")
163-
task.replaceKeyInDo("ml.preview_datafeed", "xpack-ml.preview_datafeed")
164-
task.replaceKeyInDo("ml.put_calendar", "xpack-ml.put_calendar")
165-
task.replaceKeyInDo("ml.put_calendar_job", "xpack-ml.put_calendar_job")
166-
task.replaceKeyInDo("ml.put_datafeed", "xpack-ml.put_datafeed")
167-
task.replaceKeyInDo("ml.put_filter", "xpack-ml.put_filter")
168-
task.replaceKeyInDo("ml.put_job", "xpack-ml.put_job")
169-
task.replaceKeyInDo("ml.revert_model_snapshot", "xpack-ml.revert_model_snapshot")
170-
task.replaceKeyInDo("ml.set_upgrade_mode", "xpack-ml.set_upgrade_mode")
171-
task.replaceKeyInDo("ml.start_datafeed", "xpack-ml.start_datafeed")
172-
task.replaceKeyInDo("ml.stop_datafeed", "xpack-ml.stop_datafeed")
173-
task.replaceKeyInDo("ml.update_datafeed", "xpack-ml.update_datafeed")
174-
task.replaceKeyInDo("ml.update_filter", "xpack-ml.update_filter")
175-
task.replaceKeyInDo("ml.update_job", "xpack-ml.update_job")
176-
task.replaceKeyInDo("ml.update_model_snapshot", "xpack-ml.update_model_snapshot")
177-
task.replaceKeyInDo("ml.validate", "xpack-ml.validate")
178-
task.replaceKeyInDo("ml.validate_detector", "xpack-ml.validate_detector")
179-
task.addAllowedWarningRegex(".*_xpack/ml.* is deprecated.*")
180-
181-
task.replaceKeyInDo("ssl.certificates", "xpack-ssl.certificates", "Test get SSL certificates")
182-
task.addAllowedWarningRegexForTest(".*_xpack/ssl.* is deprecated.*", "Test get SSL certificates")
183113
task.replaceValueInMatch("_type", "_doc")
184114
task.addAllowedWarningRegex("\\[types removal\\].*")
185115
task.addAllowedWarningRegexForTest("Including \\[accept_enterprise\\] in get license.*", "Installing enterprise license")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import org.elasticsearch.gradle.VersionProperties
10+
import org.elasticsearch.gradle.internal.info.BuildParams
11+
import org.elasticsearch.gradle.internal.test.rest.CopyRestTestsTask
12+
import org.elasticsearch.gradle.util.GradleUtils
13+
14+
apply plugin: 'elasticsearch.yaml-rest-compat-test'
15+
16+
/**
17+
* This project exists to test the _xpack prefix for REST compatibility. The _xpack prefix was removed from the specification, but still supported
18+
* in 7x. This project re-introduces the _xpack prefix in the specification but only for compatibility testing purposes.
19+
*/
20+
21+
configurations {
22+
compatXpackTests
23+
}
24+
25+
int compatVersion = VersionProperties.getElasticsearchVersion().getMajor() - 1;
26+
27+
dependencies {
28+
"yamlRestTestV${compatVersion}CompatImplementation" project(':test:framework')
29+
"yamlRestTestV${compatVersion}CompatImplementation"(testArtifact(xpackProject('plugin')))
30+
compatXpackTests project(path: ':x-pack:plugin', configuration: 'restCompatTests')
31+
}
32+
33+
// copy the already transformed compatible rest tests from the x-pack compatible tests
34+
tasks.named("copyRestCompatTestTask").configure { task ->
35+
task.dependsOn(configurations.compatXpackTests);
36+
task.setXpackConfig(configurations.compatXpackTests);
37+
task.getIncludeXpack().set(List.of("ml", "rollup", "license", "migration", "ssl"));
38+
task.getOutputResourceDir().set(project.getLayout().getBuildDirectory().dir("restResources/v${compatVersion}/yamlTests/original"));
39+
task.setXpackConfigToFileTree(
40+
config -> project.fileTree(
41+
config.getSingleFile().toPath()
42+
)
43+
)
44+
}
45+
46+
// location for keys and certificates
47+
File extraResourceDir = file("$buildDir/extra_resource")
48+
File nodeKey = file("$extraResourceDir/testnode.pem")
49+
File nodeCert = file("$extraResourceDir/testnode.crt")
50+
// location for service tokens
51+
File serviceTokens = file("$extraResourceDir/service_tokens")
52+
53+
// Add key and certs to test classpath: it expects them there
54+
// User cert and key PEM files instead of a JKS Keystore for the cluster's trust material so that
55+
// it can run in a FIPS 140 JVM
56+
// TODO: Remove all existing uses of cross project file references when the new approach for referencing static files is available
57+
// https://github.com/elastic/elasticsearch/pull/32201
58+
tasks.register("copyExtraResources", Copy) {
59+
from(project(':x-pack:plugin:core').file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/')) {
60+
include 'testnode.crt', 'testnode.pem'
61+
}
62+
from(project(':x-pack:plugin:security:qa:service-account').file('src/javaRestTest/resources/')) {
63+
include 'service_tokens'
64+
}
65+
into extraResourceDir
66+
}
67+
// Add keystores to test classpath: it expects it there
68+
sourceSets."yamlRestTestV${compatVersion}Compat".resources.srcDir(extraResourceDir)
69+
tasks.named("processYamlRestTestV${compatVersion}CompatResources").configure {
70+
dependsOn("copyExtraResources")
71+
}
72+
73+
testClusters.configureEach {
74+
testDistribution = 'DEFAULT' // this is important since we use the reindex module in ML
75+
setting 'xpack.ml.enabled', 'true'
76+
setting 'xpack.security.enabled', 'true'
77+
setting 'xpack.watcher.enabled', 'false'
78+
setting 'xpack.security.authc.token.enabled', 'true'
79+
setting 'xpack.security.authc.api_key.enabled', 'true'
80+
setting 'xpack.security.transport.ssl.enabled', 'true'
81+
setting 'xpack.security.transport.ssl.key', nodeKey.name
82+
setting 'xpack.security.transport.ssl.certificate', nodeCert.name
83+
setting 'xpack.security.transport.ssl.verification_mode', 'certificate'
84+
setting 'xpack.security.audit.enabled', 'true'
85+
setting 'xpack.license.self_generated.type', 'trial'
86+
// disable ILM history, since it disturbs tests using _all
87+
setting 'indices.lifecycle.history_index_enabled', 'false'
88+
keystore 'bootstrap.password', 'x-pack-test-password'
89+
keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode'
90+
setting 'xpack.searchable.snapshot.shared_cache.size', '10mb'
91+
92+
user username: "x_pack_rest_user", password: "x-pack-test-password"
93+
extraConfigFile nodeKey.name, nodeKey
94+
extraConfigFile nodeCert.name, nodeCert
95+
extraConfigFile serviceTokens.name, serviceTokens
96+
97+
if (BuildParams.isSnapshotBuild() == false) {
98+
systemProperty 'es.index_mode_feature_flag_registered', 'true'
99+
}
100+
}
101+
102+
// transform (again) the (already) transformed x-pack compatibility tests to test the xpack prefixes
103+
tasks.named("yamlRestTestV7CompatTransform").configure{ task ->
104+
105+
task.replaceKeyInDo("license.delete", "xpack-license.delete")
106+
task.replaceKeyInDo("license.get", "xpack-license.get")
107+
task.replaceKeyInDo("license.get_basic_status", "xpack-license.get_basic_status")
108+
task.replaceKeyInDo("license.get_trial_status", "xpack-license.get_trial_status")
109+
task.replaceKeyInDo("license.post", "xpack-license.post")
110+
task.replaceKeyInDo("license.post_start_basic", "xpack-license.post_start_basic")
111+
task.replaceKeyInDo("license.post_start_trial", "xpack-license.post_start_trial")
112+
task.addAllowedWarningRegex(".*_xpack/license.* is deprecated.*")
113+
114+
task.replaceKeyInDo("migration.deprecations", "xpack-migration.deprecations")
115+
task.addAllowedWarningRegex(".*_xpack/migration.* is deprecated.*")
116+
117+
task.replaceKeyInDo("rollup.delete_job", "xpack-rollup.delete_job")
118+
task.replaceKeyInDo("rollup.get_jobs", "xpack-rollup.get_jobs")
119+
task.replaceKeyInDo("rollup.get_rollup_caps", "xpack-rollup.get_rollup_caps")
120+
task.replaceKeyInDo("rollup.get_rollup_index_caps", "xpack-rollup.get_rollup_index_caps")
121+
task.replaceKeyInDo("rollup.put_job", "xpack-rollup.put_job")
122+
task.replaceKeyInDo("rollup.start_job", "xpack-rollup.start_job")
123+
task.replaceKeyInDo("rollup.stop_job", "xpack-rollup.stop_job")
124+
task.addAllowedWarningRegex(".*_xpack/rollup.* is deprecated.*")
125+
126+
task.replaceKeyInDo("ml.close_job", "xpack-ml.close_job")
127+
task.replaceKeyInDo("ml.delete_calendar", "xpack-ml.delete_calendar")
128+
task.replaceKeyInDo("ml.delete_calendar_event", "xpack-ml.delete_calendar_event")
129+
task.replaceKeyInDo("ml.delete_calendar_job", "xpack-ml.delete_calendar_job")
130+
task.replaceKeyInDo("ml.delete_datafeed", "xpack-ml.delete_datafeed")
131+
task.replaceKeyInDo("ml.delete_expired_data", "xpack-ml.delete_expired_data")
132+
task.replaceKeyInDo("ml.delete_filter", "xpack-ml.delete_filter")
133+
task.replaceKeyInDo("ml.delete_forecast", "xpack-ml.delete_forecast")
134+
task.replaceKeyInDo("ml.delete_job", "xpack-ml.delete_job")
135+
task.replaceKeyInDo("ml.delete_model_snapshot", "xpack-ml.delete_model_snapshot")
136+
task.replaceKeyInDo("ml.flush_job", "xpack-ml.flush_job")
137+
task.replaceKeyInDo("ml.forecast", "xpack-ml.forecast")
138+
task.replaceKeyInDo("ml.get_buckets", "xpack-ml.get_buckets")
139+
task.replaceKeyInDo("ml.get_calendar_events", "xpack-ml.get_calendar_events")
140+
task.replaceKeyInDo("ml.get_calendars", "xpack-ml.get_calendars")
141+
task.replaceKeyInDo("ml.get_categories", "xpack-ml.get_categories")
142+
task.replaceKeyInDo("ml.get_datafeed_stats", "xpack-ml.get_datafeed_stats")
143+
task.replaceKeyInDo("ml.get_datafeeds", "xpack-ml.get_datafeeds")
144+
task.replaceKeyInDo("ml.get_filters", "xpack-ml.get_filters")
145+
task.replaceKeyInDo("ml.get_influencers", "xpack-ml.get_influencers")
146+
task.replaceKeyInDo("ml.get_job_stats", "xpack-ml.get_job_stats")
147+
task.replaceKeyInDo("ml.get_jobs", "xpack-ml.get_jobs")
148+
task.replaceKeyInDo("ml.get_model_snapshots", "xpack-ml.get_model_snapshots")
149+
task.replaceKeyInDo("ml.get_overall_buckets", "xpack-ml.get_overall_buckets")
150+
task.replaceKeyInDo("ml.get_records", "xpack-ml.get_records")
151+
task.replaceKeyInDo("ml.info", "xpack-ml.info")
152+
task.replaceKeyInDo("ml.open_job", "xpack-ml.open_job")
153+
task.replaceKeyInDo("ml.post_calendar_events", "xpack-ml.post_calendar_events")
154+
task.replaceKeyInDo("ml.post_data", "xpack-ml.post_data")
155+
task.replaceKeyInDo("ml.preview_datafeed", "xpack-ml.preview_datafeed")
156+
task.replaceKeyInDo("ml.put_calendar", "xpack-ml.put_calendar")
157+
task.replaceKeyInDo("ml.put_calendar_job", "xpack-ml.put_calendar_job")
158+
task.replaceKeyInDo("ml.put_datafeed", "xpack-ml.put_datafeed")
159+
task.replaceKeyInDo("ml.put_filter", "xpack-ml.put_filter")
160+
task.replaceKeyInDo("ml.put_job", "xpack-ml.put_job")
161+
task.replaceKeyInDo("ml.revert_model_snapshot", "xpack-ml.revert_model_snapshot")
162+
task.replaceKeyInDo("ml.set_upgrade_mode", "xpack-ml.set_upgrade_mode")
163+
task.replaceKeyInDo("ml.start_datafeed", "xpack-ml.start_datafeed")
164+
task.replaceKeyInDo("ml.stop_datafeed", "xpack-ml.stop_datafeed")
165+
task.replaceKeyInDo("ml.update_datafeed", "xpack-ml.update_datafeed")
166+
task.replaceKeyInDo("ml.update_filter", "xpack-ml.update_filter")
167+
task.replaceKeyInDo("ml.update_job", "xpack-ml.update_job")
168+
task.replaceKeyInDo("ml.update_model_snapshot", "xpack-ml.update_model_snapshot")
169+
task.replaceKeyInDo("ml.validate", "xpack-ml.validate")
170+
task.replaceKeyInDo("ml.validate_detector", "xpack-ml.validate_detector")
171+
task.addAllowedWarningRegex(".*_xpack/ml.* is deprecated.*")
172+
173+
task.replaceKeyInDo("ssl.certificates", "xpack-ssl.certificates", "Test get SSL certificates")
174+
task.addAllowedWarningRegexForTest(".*_xpack/ssl.* is deprecated.*", "Test get SSL certificates")
175+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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.test.rest;
9+
10+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
11+
12+
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
13+
14+
public class XPackRestIT extends AbstractXPackRestTest {
15+
16+
public XPackRestIT(ClientYamlTestCandidate testCandidate) {
17+
super(testCandidate);
18+
}
19+
20+
@ParametersFactory
21+
public static Iterable<Object[]> parameters() throws Exception {
22+
return createParameters();
23+
}
24+
}

0 commit comments

Comments
 (0)