Skip to content

Commit

Permalink
Change rest compat task names
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Aug 26, 2024
1 parent 74d964b commit 50c4e24
Show file tree
Hide file tree
Showing 26 changed files with 36 additions and 39 deletions.
6 changes: 3 additions & 3 deletions REST_API_COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ The above code checks the request's compatible version and if the request has th

The primary means of testing compatibility is via the prior major version's YAML REST tests. The build system will download the latest prior version of the YAML rest tests and execute them against the current cluster version. Prior to execution the tests will be transformed by injecting the correct headers to enable compatibility as well as other custom changes to the tests to allow the tests to pass. These customizations are configured via the build.gradle and happen just prior to test execution. Since the compatibility tests are manipulated version of the tests stored in Github (via the past major version), it is important to find the local (on disk) version for troubleshooting compatibility tests.

The tests are wired into the `check` task, so that is the easiest way to test locally prior to committing. More specifically the task is called `yamlRestTestV7CompatTest`, where 7 is the version of tests that are executing. For example, version 8 of the server will have a task named `yamlRestTestV7CompatTest` and version 9 of the server will have a task named `yamlRestTestV8CompatTest`. These behaves nearly identical to it's non-compat `yamlRestTest` task. The only variance is that the tests are sourced from the prior version branch and the tests go through a transformation phase before execution. The transformation task is `yamlRestTestV7CompatTransform` where the Vnumber follows the same convention as the test.
The tests are wired into the `check` task, so that is the easiest way to test locally prior to committing. More specifically the task is called `yamlRestCompatTest`. These behave nearly identical to it's non-compat `yamlRestTest` task. The only variance is that the tests are sourced from the prior version branch and the tests go through a transformation phase before execution. The transformation task is `yamlRestCompatTestTransform`.

For example:

```bash
./gradlew :rest-api-spec:yamlRestTestV7CompatTest
./gradlew :rest-api-spec:yamlRestCompatTest
```

Since these are a variation of backward compatibility testing, the entire suite of compatibility tests will be skipped anytime the backward compatibility testing is disabled. Since the source code for these tests live in a branch of code, disabling a specific test should be done via the transformation task configuration in build.gradle (i.e. `yamlRestTestV7CompatTransform`).
Expand All @@ -188,7 +188,7 @@ Muting compatibility tests should be done via a test transform. A per test skip

```groovy
tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
tasks.named("yamlRestCompatTestTransform").configure({ task ->
task.skipTestsByFilePattern("**/cat*/*.yml", "Cat API are not supported")
task.skipTest("bulk/10_basic/Array of objects", "Muted due failures. See #12345")
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

package org.elasticsearch.gradle.internal.test.rest.compat.compat;

import org.elasticsearch.gradle.Version;
import org.elasticsearch.gradle.VersionProperties;
import org.elasticsearch.gradle.internal.ElasticsearchJavaBasePlugin;
import org.elasticsearch.gradle.internal.test.rest.CopyRestApiTask;
import org.elasticsearch.gradle.internal.test.rest.CopyRestTestsTask;
Expand Down Expand Up @@ -40,7 +38,6 @@
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Map;

import javax.inject.Inject;

import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.setupYamlRestTestDependenciesDefaults;
Expand All @@ -59,8 +56,7 @@ public abstract class AbstractYamlRestCompatTestPlugin implements Plugin<Project
private static final Path RELATIVE_REST_CORE = Path.of("rest-api-spec");
private static final Path RELATIVE_REST_XPACK = Path.of("x-pack/plugin");
private static final Path RELATIVE_REST_PROJECT_RESOURCES = Path.of("src/yamlRestTest/resources");
private static final int COMPATIBLE_VERSION = Version.fromString(VersionProperties.getVersions().get("elasticsearch")).getMajor() - 1;
private static final String SOURCE_SET_NAME = "yamlRestTestV" + COMPATIBLE_VERSION + "Compat";
private static final String SOURCE_SET_NAME = "yamlRestCompatTest";
private ProjectLayout projectLayout;
private FileOperations fileOperations;

Expand All @@ -73,7 +69,7 @@ public AbstractYamlRestCompatTestPlugin(ProjectLayout projectLayout, FileOperati
@Override
public void apply(Project project) {

final Path compatRestResourcesDir = Path.of("restResources").resolve("v" + COMPATIBLE_VERSION);
final Path compatRestResourcesDir = Path.of("restResources");
final Path compatSpecsDir = compatRestResourcesDir.resolve("yamlSpecs");
final Path compatTestsDir = compatRestResourcesDir.resolve("yamlTests");
project.getPluginManager().apply(getBasePlugin());
Expand Down Expand Up @@ -182,7 +178,7 @@ public void apply(Project project) {

// transform the copied tests task
TaskProvider<RestCompatTestTransformTask> transformCompatTestTask = project.getTasks()
.register("yamlRestTestV" + COMPATIBLE_VERSION + "CompatTransform", RestCompatTestTransformTask.class, task -> {
.register("yamlRestCompatTestTransform", RestCompatTestTransformTask.class, task -> {
task.getSourceDirectory().set(copyCompatYamlTestTask.flatMap(CopyRestTestsTask::getOutputResourceDir));
task.getOutputDirectory()
.set(project.getLayout().getBuildDirectory().dir(compatTestsDir.resolve("transformed").toString()));
Expand Down
2 changes: 1 addition & 1 deletion build-tools-internal/version.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
elasticsearch = 8.16.0
elasticsearch = 9.0.0
lucene = 9.11.1

bundled_jdk_vendor = openjdk
Expand Down
2 changes: 1 addition & 1 deletion modules/aggregations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (BuildParams.isSnapshotBuild() == false) {
}
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest("search.aggregation/20_terms/string profiler via global ordinals filters implementation", "The profiler results aren't backwards compatible.")
task.skipTest("search.aggregation/20_terms/string profiler via global ordinals native implementation", "The profiler results aren't backwards compatible.")
task.skipTest("search.aggregation/20_terms/string profiler via map", "The profiler results aren't backwards compatible.")
Expand Down
2 changes: 1 addition & 1 deletion modules/analysis-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
clusterModules project(':modules:mapper-extras')
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest("indices.analyze/10_analyze/htmlStrip_deprecated", "Cleanup versioned deprecations in analysis #41560")
task.skipTest("analysis-common/40_token_filters/delimited_payload_filter_error", "Remove preconfigured delimited_payload_filter #43686")
task.skipTest("analysis-common/20_analyzers/standard_html_strip", "Cleanup versioned deprecations in analysis #41560")
Expand Down
2 changes: 1 addition & 1 deletion modules/health-shards-availability/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ restResources {
}
}

tasks.named("yamlRestTestV7CompatTransform").configure {task ->
tasks.named("yamlRestCompatTestTransform").configure {task ->
task.addAllowedWarningRegex("setting \\[ecs\\] is deprecated as ECS format is the default and only option")
}
4 changes: 2 additions & 2 deletions modules/ingest-attachment/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ tasks.named("forbiddenPatterns").configure {
exclude '**/text-cjk-*.txt'
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
// 2 new tika metadata fields are returned in v8
task.replaceValueInLength("_source.attachment", 8, "Test ingest attachment processor with .doc file")
task.replaceValueInLength("_source.attachment", 8, "Test ingest attachment processor with .docx file")
Expand All @@ -153,5 +153,5 @@ tasks.named("thirdPartyAudit").configure {
if (BuildParams.inFipsJvm) {
tasks.named("test").configure { enabled = false }
tasks.named("yamlRestTest").configure { enabled = false };
tasks.named("yamlRestTestV7CompatTest").configure { enabled = false };
tasks.named("yamlRestCompatTest").configure { enabled = false };
}
2 changes: 1 addition & 1 deletion modules/ingest-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ tasks.named("thirdPartyAudit").configure {
)
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.addAllowedWarningRegex("\\[types removal\\].*")
}
2 changes: 1 addition & 1 deletion modules/ingest-geoip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ tasks.named("dependencyLicenses").configure {
ignoreFile 'elastic-geoip-database-service-agreement-LICENSE.txt'
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTestsByFilePattern("**/ingest_geoip/20_geoip_processor.yml", "from 8.0 yaml rest tests use geoip test fixture and default geoip are no longer packaged. In 7.x yaml tests used default databases which makes tests results very different, so skipping these tests")
// task.skipTest("lang_mustache/50_multi_search_template/Multi-search template with errors", "xxx")
}
2 changes: 1 addition & 1 deletion modules/ingest-user-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ restResources {
}
}

tasks.named("yamlRestTestV7CompatTransform").configure {task ->
tasks.named("yamlRestCompatTestTransform").configure {task ->
task.addAllowedWarningRegex("setting \\[ecs\\] is deprecated as ECS format is the default and only option")
}
2 changes: 1 addition & 1 deletion modules/lang-mustache/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ restResources {
}
}

tasks.named("yamlRestTestV7CompatTransform").configure {task ->
tasks.named("yamlRestCompatTestTransform").configure {task ->
task.addAllowedWarningRegex("\\[types removal\\].*")
task.replaceValueInMatch("responses.1.error.root_cause.0.type", "x_content_e_o_f_exception", "Multi-search template with errors")
}
2 changes: 1 addition & 1 deletion modules/lang-painless/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ tasks.named("test").configure {
jvmArgs '-XX:-OmitStackTraceInFastThrow', '-XX:-HeapDumpOnOutOfMemoryError'
}

tasks.named("yamlRestTestV7CompatTest").configure {
tasks.named("yamlRestCompatTest").configure {
systemProperty 'tests.rest.blacklist', [
'painless/20_scriptfield/Scripted Field Doing Compare (fields api)',
'painless/70_execute_painless_scripts/Execute with double field context (single-value, fields api)',
Expand Down
2 changes: 1 addition & 1 deletion modules/parent-join/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ restResources {
}
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest("/30_inner_hits/profile fetch", "profile output has changed")
}
2 changes: 1 addition & 1 deletion modules/percolator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ restResources {
}
}

tasks.named("yamlRestTestV7CompatTransform").configure{ task ->
tasks.named("yamlRestCompatTestTransform").configure{ task ->
task.addAllowedWarningRegex("\\[types removal\\].*")
}
4 changes: 2 additions & 2 deletions modules/reindex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ if (OS.current() == OS.WINDOWS) {
}
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest("reindex/20_validation/reindex without source gives useful error message", "exception with a type. Not much benefit adding _doc there.")
task.skipTest("update_by_query/20_validation/update_by_query without source gives useful error message", "exception with a type. Not much benefit adding _doc there.")

Expand All @@ -179,7 +179,7 @@ tasks.named("yamlRestTestV7CompatTransform").configure { task ->
task.addAllowedWarningRegex("\\[types removal\\].*")
}

tasks.named("yamlRestTestV7CompatTest").configure {
tasks.named("yamlRestCompatTest").configure {
systemProperty 'tests.rest.blacklist', [
'update_by_query/80_scripting/Can\'t change _id',
'update_by_query/80_scripting/Set unsupported operation type',
Expand Down
2 changes: 1 addition & 1 deletion modules/runtime-fields-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
api project(':libs:elasticsearch-dissect')
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest("runtime_fields/100_geo_point/fetch fields from source", "Format changed. Old format was a bug.")
task.skipTest("runtime_fields/101_geo_point_from_source/fetch fields from source", "Format changed. Old format was a bug.")
task.skipTest("runtime_fields/102_geo_point_source_in_query/fetch fields from source", "Format changed. Old format was a bug.")
Expand Down
2 changes: 1 addition & 1 deletion plugins/analysis-icu/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tasks.named("dependencyLicenses").configure {
mapping from: /lucene-.*/, to: 'lucene'
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest("analysis_icu/10_basic/Normalization with deprecated unicodeSetFilter", "Cleanup versioned deprecations in analysis #41560")
}

2 changes: 1 addition & 1 deletion rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
clusterModules project(':modules:data-streams')
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->

task.skipTestsByFilePattern("**/cat*/*.yml", "Cat API are meant to be consumed by humans, so will not be supported by Compatible REST API")
task.skipTestsByFilePattern("**/indices.upgrade/*.yml", "upgrade api will only get a dummy endpoint returning an exception suggesting to use _reindex")
Expand Down
3 changes: 2 additions & 1 deletion server/src/main/java/org/elasticsearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public class Version implements VersionId<Version>, ToXContentFragment {
public static final Version V_8_15_0 = new Version(8_15_00_99);
public static final Version V_8_15_1 = new Version(8_15_01_99);
public static final Version V_8_16_0 = new Version(8_16_00_99);
public static final Version CURRENT = V_8_16_0;
public static final Version V_9_0_0 = new Version(9_0_00_99);
public static final Version CURRENT = V_9_0_0;

private static final NavigableMap<Integer, Version> VERSION_IDS;
private static final Map<String, Version> VERSION_STRINGS;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugin/autoscaling/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ restResources {
}
}

tasks.named("yamlRestTestV7CompatTest").configure {
tasks.named("yamlRestCompatTest").configure {
systemProperty 'tests.rest.blacklist', [
"autoscaling/get_autoscaling_capacity/Test get fixed autoscaling capacity",
].join(',')
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tasks.named("yamlRestTest").configure {
systemProperty 'tests.rest.blacklist', restTestBlacklist.join(',')
}

tasks.named("yamlRestTestV7CompatTest").configure {
tasks.named("yamlRestCompatTest").configure {
systemProperty 'tests.rest.blacklist', [
'unsigned_long/50_script_values/Scripted sort values',
'unsigned_long/50_script_values/script_score query',
Expand All @@ -80,7 +80,7 @@ tasks.named("yamlRestTestV7CompatTest").configure {
].join(',')
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest(
"vectors/10_dense_vector_basic/Deprecated function signature",
"to support it, it would require to almost revert back the #48725 and complicate the code"
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/downsample/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ artifacts {
tasks.named('yamlRestTest') {
usesDefaultDistribution()
}
tasks.named('yamlRestTestV7CompatTest') {
tasks.named('yamlRestCompatTest') {
usesDefaultDistribution()
}
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("yamlRestTest").configure{enabled = false }
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest("rollup/10_basic/Rollup index", "Downsample for TSDB changed the configuration")
}
2 changes: 1 addition & 1 deletion x-pack/plugin/eql/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tasks.named('javaRestTest') {
tasks.named('yamlRestTest') {
usesDefaultDistribution()
}
tasks.named('yamlRestTestV7CompatTest') {
tasks.named('yamlRestCompatTest') {
usesDefaultDistribution()
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugin/mapper-unsigned-long/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ restResources {
}
}

tasks.named("yamlRestTestV7CompatTest").configure {
tasks.named("yamlRestCompatTest").configure {
systemProperty 'tests.rest.blacklist', [
'50_script_values/Scripted fields values return Long',
'50_script_values/Scripted sort values',
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugin/watcher/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (BuildParams.inFipsJvm){
}


tasks.named("yamlRestTestV7CompatTransform").configure{ task ->
tasks.named("yamlRestCompatTestTransform").configure{ task ->
task.skipTest("mustache/30_search_input/Test search input mustache integration (using request body and rest_total_hits_as_int)", "remove JodaCompatibleDateTime -- ZonedDateTime doesn't output millis/nanos if they're 0 (#78417)")
task.skipTest("mustache/30_search_input/Test search input mustache integration (using request body)", "remove JodaCompatibleDateTime -- ZonedDateTime doesn't output millis/nanos if they're 0 (#78417)")
task.skipTest("mustache/40_search_transform/Test search transform mustache integration (using request body)", "remove JodaCompatibleDateTime -- ZonedDateTime doesn't output millis/nanos if they're 0 (#78417)")
Expand Down
4 changes: 2 additions & 2 deletions x-pack/qa/xpack-prefix-rest-compat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ testClusters.configureEach {
}

// transform (again) the (already) transformed x-pack compatibility tests to test the xpack prefixes
tasks.named("yamlRestTestV7CompatTransform").configure{ task ->
tasks.named("yamlRestCompatTestTransform").configure{ task ->

task.replaceKeyInDo("license.delete", "xpack-license.delete")
task.replaceKeyInDo("license.get", "xpack-license.get")
Expand Down Expand Up @@ -184,7 +184,7 @@ tasks.named("yamlRestTestV7CompatTransform").configure{ task ->
task.addAllowedWarningRegexForTest(".*_xpack/ssl.* is deprecated.*", "Test get SSL certificates")
}

tasks.named("yamlRestTestV7CompatTest").configure {
tasks.named("yamlRestCompatTest").configure {
systemProperty 'tests.rest.blacklist', [
'ml/evaluate_data_frame/Test classification auc_roc',
'ml/evaluate_data_frame/Test classification auc_roc with default top_classes_field',
Expand Down

0 comments on commit 50c4e24

Please sign in to comment.