Skip to content
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

Update task names for rest compatiblity #75267

Merged
merged 9 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -22,13 +22,13 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
def compatibleVersion = Version.fromString(VersionProperties.getVersions().get("elasticsearch")).getMajor() - 1
def specIntermediateDir = "restResources/v${compatibleVersion}/yamlSpecs"
def testIntermediateDir = "restResources/v${compatibleVersion}/yamlTests"
def transformTask = ":transformV${compatibleVersion}RestTests"
def transformTask = ":yamlRestTestV${compatibleVersion}CompatTransform"
def YAML_FACTORY = new YAMLFactory()
def MAPPER = new ObjectMapper(YAML_FACTORY)
def READER = MAPPER.readerFor(ObjectNode.class)
def WRITER = MAPPER.writerFor(ObjectNode.class)

def "yamlRestCompatTest does nothing when there are no tests"() {
def "yamlRestTestCompat does nothing when there are no tests"() {
given:
addSubProject(":distribution:bwc:minor") << """
configurations { checkout }
Expand All @@ -44,16 +44,16 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
"""

when:
def result = gradleRunner("yamlRestCompatTest", '--stacktrace').build()
def result = gradleRunner("yamlRestTestV${compatibleVersion}Compat", '--stacktrace').build()

then:
result.task(':yamlRestCompatTest').outcome == TaskOutcome.NO_SOURCE
result.task(":yamlRestTestV${compatibleVersion}Compat").outcome == TaskOutcome.NO_SOURCE
result.task(':copyRestCompatApiTask').outcome == TaskOutcome.NO_SOURCE
result.task(':copyRestCompatTestTask').outcome == TaskOutcome.NO_SOURCE
result.task(transformTask).outcome == TaskOutcome.NO_SOURCE
}

def "yamlRestCompatTest executes and copies api and transforms tests from :bwc:minor"() {
def "yamlRestTestCompat executes and copies api and transforms tests from :bwc:minor"() {
given:
internalBuild()

Expand Down Expand Up @@ -93,10 +93,10 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
file("distribution/bwc/minor/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/" + test) << ""

when:
def result = gradleRunner("yamlRestCompatTest").build()
def result = gradleRunner("yamlRestTestV${compatibleVersion}Compat").build()

then:
result.task(':yamlRestCompatTest').outcome == TaskOutcome.SKIPPED
result.task(":yamlRestTestV${compatibleVersion}Compat").outcome == TaskOutcome.SKIPPED
result.task(':copyRestCompatApiTask').outcome == TaskOutcome.SUCCESS
result.task(':copyRestCompatTestTask').outcome == TaskOutcome.SUCCESS
result.task(transformTask).outcome == TaskOutcome.SUCCESS
Expand All @@ -123,16 +123,16 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
result.task(':copyYamlTestsTask').outcome == TaskOutcome.NO_SOURCE

when:
result = gradleRunner("yamlRestCompatTest").build()
result = gradleRunner("yamlRestTestV${compatibleVersion}Compat").build()

then:
result.task(':yamlRestCompatTest').outcome == TaskOutcome.SKIPPED
result.task(":yamlRestTestV${compatibleVersion}Compat").outcome == TaskOutcome.SKIPPED
result.task(':copyRestCompatApiTask').outcome == TaskOutcome.UP_TO_DATE
result.task(':copyRestCompatTestTask').outcome == TaskOutcome.UP_TO_DATE
result.task(transformTask).outcome == TaskOutcome.UP_TO_DATE
}

def "yamlRestCompatTest is wired into check and checkRestCompat"() {
def "yamlRestTestCompat is wired into check and checkRestCompat"() {
given:

addSubProject(":distribution:bwc:minor") << """
Expand All @@ -155,7 +155,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
then:
result.task(':check').outcome == TaskOutcome.UP_TO_DATE
result.task(':checkRestCompat').outcome == TaskOutcome.UP_TO_DATE
result.task(':yamlRestCompatTest').outcome == TaskOutcome.NO_SOURCE
result.task(":yamlRestTestV${compatibleVersion}Compat").outcome == TaskOutcome.NO_SOURCE
result.task(':copyRestCompatApiTask').outcome == TaskOutcome.NO_SOURCE
result.task(':copyRestCompatTestTask').outcome == TaskOutcome.NO_SOURCE
result.task(transformTask).outcome == TaskOutcome.NO_SOURCE
Expand All @@ -169,7 +169,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
then:
result.task(':check').outcome == TaskOutcome.UP_TO_DATE
result.task(':checkRestCompat').outcome == TaskOutcome.UP_TO_DATE
result.task(':yamlRestCompatTest').outcome == TaskOutcome.SKIPPED
result.task(":yamlRestTestV${compatibleVersion}Compat").outcome == TaskOutcome.SKIPPED
result.task(':copyRestCompatApiTask').outcome == TaskOutcome.SKIPPED
result.task(':copyRestCompatTestTask').outcome == TaskOutcome.SKIPPED
result.task(transformTask).outcome == TaskOutcome.SKIPPED
Expand All @@ -195,7 +195,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
dependencies {
yamlRestTestImplementation "junit:junit:4.12"
}
tasks.named("transformV7RestTests").configure({ task ->
tasks.named("yamlRestTestV${compatibleVersion}CompatTransform").configure({ task ->
task.replaceValueInMatch("_type", "_doc")
task.replaceValueInMatch("_source.values", ["z", "x", "y"], "one")
task.removeMatch("_source.blah")
Expand Down Expand Up @@ -261,7 +261,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
- match: {}
""".stripIndent()
when:
def result = gradleRunner("yamlRestCompatTest").build()
def result = gradleRunner("yamlRestTestV${compatibleVersion}Compat").build()

then:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
* Apply this plugin to run the YAML based REST tests from a prior major version against this version's cluster.
*/
public class YamlRestCompatTestPlugin implements Plugin<Project> {
public static final String REST_COMPAT_CHECK_TASK_NAME = "checkRestCompat";
public static final String SOURCE_SET_NAME = "yamlRestCompatTest";
private static final String REST_COMPAT_CHECK_TASK_NAME = "checkRestCompat";
private static final String SOURCE_SET_NAME = "yamlRestCompatTest";
private static final Path RELATIVE_API_PATH = Path.of("rest-api-spec/api");
private static final Path RELATIVE_TEST_PATH = Path.of("rest-api-spec/test");
private static final Path RELATIVE_REST_API_RESOURCES = Path.of("rest-api-spec/src/main/resources");
Expand Down Expand Up @@ -138,9 +138,11 @@ public void apply(Project project) {
task.onlyIf(t -> isEnabled(project));
});

String testTaskName = "yamlRestTestV"+ compatibleVersion + "Compat";

// transform the copied tests task
TaskProvider<RestCompatTestTransformTask> transformCompatTestTask = project.getTasks()
.register("transformV" + compatibleVersion + "RestTests", RestCompatTestTransformTask.class, task -> {
.register(testTaskName + "Transform", RestCompatTestTransformTask.class, task -> {
task.getSourceDirectory().set(copyCompatYamlTestTask.flatMap(CopyRestTestsTask::getOutputResourceDir));
task.getOutputDirectory()
.set(project.getLayout().getBuildDirectory().dir(compatTestsDir.resolve("transformed").toString()));
Expand All @@ -161,9 +163,9 @@ public void apply(Project project) {
.named(RestResourcesPlugin.COPY_YAML_TESTS_TASK)
.flatMap(CopyRestTestsTask::getOutputResourceDir);

// setup the yamlRestTest task
Provider<RestIntegTestTask> yamlRestCompatTestTask = RestTestUtil.registerTestTask(project, yamlCompatTestSourceSet);
project.getTasks().withType(RestIntegTestTask.class).named(SOURCE_SET_NAME).configure(testTask -> {
// setup the test task
Provider<RestIntegTestTask> yamlRestCompatTestTask = RestTestUtil.registerTestTask(project, yamlCompatTestSourceSet, testTaskName);
project.getTasks().withType(RestIntegTestTask.class).named(testTaskName).configure(testTask -> {
// Use test runner and classpath from "normal" yaml source set
testTask.setTestClassesDirs(
yamlTestSourceSet.getOutput().getClassesDirs().plus(yamlCompatTestSourceSet.getOutput().getClassesDirs())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ private RestTestUtil() {
}

/**
* Creates a task with the source set name of type {@link RestIntegTestTask}
* Creates a {@link RestIntegTestTask} task with the source set of the same name
*/
public static Provider<RestIntegTestTask> registerTestTask(Project project, SourceSet sourceSet) {
return registerTestTask(project, sourceSet, sourceSet.getName());
}

/**
* Creates a {@link RestIntegTestTask} task with a custom name for the provided source set
*/
public static Provider<RestIntegTestTask> registerTestTask(Project project, SourceSet sourceSet, String taskName) {
// lazily create the test task
return project.getTasks().register(sourceSet.getName(), RestIntegTestTask.class, testTask -> {
return project.getTasks().register(taskName, RestIntegTestTask.class, testTask -> {
testTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
testTask.setDescription("Runs the REST tests against an external cluster");
project.getPlugins().withType(JavaPlugin.class, t ->
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 @@ -25,7 +25,7 @@ dependencies {
compileOnly project(':modules:lang-painless')
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
'search.query/50_queries_with_synonyms/Test common terms query with stacked tokens',
'indices.analyze/10_analyze/htmlStrip_deprecated',
Expand Down
2 changes: 1 addition & 1 deletion modules/geo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ if (BuildParams.inFipsJvm){
// The geo module is replaced by spatial in the default distribution and in FIPS 140 mode, we set the testclusters to
// use the default distribution, so there is no need to run these tests
tasks.named("yamlRestTest").configure{enabled = false }
tasks.named("yamlRestCompatTest").configure{enabled = false }
tasks.named("yamlRestTestV7Compat").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 @@ -44,7 +44,7 @@ tasks.named("thirdPartyAudit").configure {
)
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
'ingest/80_foreach/Test foreach Processor',
'ingest/230_change_target_index/Test Change Target Index with Explicit Pipeline',
Expand Down
2 changes: 1 addition & 1 deletion modules/ingest-user-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ testClusters.all {
extraConfigFile 'ingest-user-agent/test-regexes.yml', file('src/test/test-regexes.yml')
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
'ingest-useragent/30_custom_regex/Test user agent processor with custom regex file',
'ingest-useragent/20_useragent_processor/Test user agent processor with parameters'
Expand Down
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("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
'lang_mustache/60_typed_keys/Multisearch template with typed_keys parameter',
'lang_mustache/60_typed_keys/Search template with typed_keys parameter'
Expand Down
2 changes: 1 addition & 1 deletion modules/lang-painless/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tasks.named("test").configure {
jvmArgs '-XX:-OmitStackTraceInFastThrow', '-XX:-HeapDumpOnOutOfMemoryError'
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
].join(',')
}
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,7 +20,7 @@ restResources {
}
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
'/30_inner_hits/Test two sub-queries with only one having inner_hits'
].join(',')
Expand Down
2 changes: 1 addition & 1 deletion modules/percolator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ restResources {
}
}

tasks.named("transformV7RestTests").configure({ task ->
tasks.named("yamlRestTestV7CompatTransform").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 @@ -164,7 +164,7 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
}
}
}
tasks.named("transformV7RestTests").configure({ task ->
tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
task.addAllowedWarningRegex("\\[types removal\\].*")
})

Expand All @@ -175,7 +175,7 @@ def v7compatibilityNotSupportedTests = {
]
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', v7compatibilityNotSupportedTests().join(',')
}

Expand Down
2 changes: 1 addition & 1 deletion modules/repository-url/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ testClusters.all {
}, PropertyNormalization.IGNORE_VALUE
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
'repository_url/10_basic/Get a non existing snapshot',
'repository_url/10_basic/Restore with repository-url using http://',
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 @@ -37,7 +37,7 @@ tasks.named("dependencyLicenses").configure {
mapping from: /lucene-.*/, to: 'lucene'
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
'analysis_icu/10_basic/Normalization with deprecated unicodeSetFilter'
].join(',')
Expand Down
2 changes: 1 addition & 1 deletion plugins/ingest-attachment/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ if (BuildParams.inFipsJvm) {
tasks.named("jarHell").configure { enabled = false }
tasks.named("test").configure { enabled = false }
tasks.named("yamlRestTest").configure { enabled = false };
tasks.named("yamlRestCompatTest").configure { enabled = false };
tasks.named("yamlRestTestV7Compat").configure { enabled = false };
tasks.named("testingConventions").configure { enabled = false };
}
4 changes: 2 additions & 2 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def v7compatibilityNotSupportedTests = {
'indices.upgrade/*/*'
]
}
tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
onlyIf {
// Skip these tests on Windows since the blacklist exceeds Windows CLI limits
OS.current() != OS.WINDOWS
Expand Down Expand Up @@ -103,7 +103,7 @@ tasks.named("yamlRestCompatTest").configure {
.join(',')
}

tasks.named("transformV7RestTests").configure({ task ->
tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
task.replaceValueInMatch("_type", "_doc")
task.addAllowedWarningRegex("\\[types removal\\].*")
task.replaceValueInMatch("nodes.\$node_id.roles.8", "ml", "node_info role test")
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ tasks.named("yamlRestTest").configure {
dependsOn "copyExtraResources"
}

tasks.named("transformV7RestTests").configure({ task ->
tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
task.replaceKeyInDo("license.delete", "xpack-license.delete")
task.replaceKeyInDo("license.get", "xpack-license.get")
task.replaceKeyInDo("license.get_basic_status", "xpack-license.get_basic_status")
Expand Down Expand Up @@ -142,7 +142,7 @@ def v7compatibilityNotSupportedTests = {
]
}

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
/*
* We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
* other if we allow them to set the number of available processors as it's set-once in Netty.
Expand Down Expand Up @@ -217,7 +217,7 @@ tasks.named("precommit").configure {
dependsOn 'enforceYamlTestConvention', 'enforceApiSpecsConvention'
}

tasks.named("transformV7RestTests").configure({ task ->
tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
task.replaceValueInMatch("_type", "_doc")
task.addAllowedWarningRegex("\\[types removal\\].*")
})
4 changes: 2 additions & 2 deletions x-pack/plugin/watcher/qa/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (BuildParams.inFipsJvm){
tasks.named("yamlRestTest").configure{enabled = false }
}

tasks.named("transformV7RestTests").configure({ task ->
tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
task.replaceKeyInDo("watcher.ack_watch", "xpack-watcher.ack_watch")
task.replaceKeyInDo("watcher.activate_watch", "xpack-watcher.activate_watch")
task.replaceKeyInDo("watcher.deactivate_watch", "xpack-watcher.deactivate_watch")
Expand All @@ -54,7 +54,7 @@ tasks.named("transformV7RestTests").configure({ task ->

})

tasks.named("yamlRestCompatTest").configure {
tasks.named("yamlRestTestV7Compat").configure {
systemProperty 'tests.rest.blacklist', [
'mustache/25_array_compare/Basic array_compare watch',
'mustache/30_search_input/Test search input mustache integration (using request body and rest_total_hits_as_int)',
Expand Down