[7.x] Introduce changes related to yamlRestCompatTest (#62985) (#63105)

Backport for #62985 that includes the related changes, but 
not the actual plugin for yamlRestCompatTest. The plugin 
is not necessary in 7.x, and back porting relevant changes to
help keep 7.x code inline with master.
This commit is contained in:
Jake Landis 2020-10-01 15:29:57 -05:00 committed by GitHub
parent 6899ce6309
commit d864d14832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 5 deletions

View File

@ -58,8 +58,10 @@ public class CopyRestApiTask extends DefaultTask {
final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class);
final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class);
String sourceSetName;
boolean skipHasRestTestCheck;
Configuration coreConfig;
Configuration xpackConfig;
Configuration additionalConfig;
private final PatternFilterable corePatternSet;
private final PatternFilterable xpackPatternSet;
@ -89,6 +91,11 @@ public class CopyRestApiTask extends DefaultTask {
return sourceSetName;
}
@Input
public boolean isSkipHasRestTestCheck() {
return skipHasRestTestCheck;
}
@SkipWhenEmpty
@InputFiles
public FileTree getInputDir() {
@ -98,7 +105,7 @@ public class CopyRestApiTask extends DefaultTask {
xpackPatternSet.setIncludes(includeXpack.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
xpackFileTree = xpackConfig.getAsFileTree().matching(xpackPatternSet);
}
boolean projectHasYamlRestTests = projectHasYamlRestTests();
boolean projectHasYamlRestTests = skipHasRestTestCheck || projectHasYamlRestTests();
if (includeCore.get().isEmpty() == false || projectHasYamlRestTests) {
if (BuildParams.isInternal()) {
corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
@ -107,7 +114,10 @@ public class CopyRestApiTask extends DefaultTask {
coreFileTree = coreConfig.getAsFileTree(); // jar file
}
}
ConfigurableFileCollection fileCollection = getProject().files(coreFileTree, xpackFileTree);
ConfigurableFileCollection fileCollection = additionalConfig == null
? getProject().files(coreFileTree, xpackFileTree)
: getProject().files(coreFileTree, xpackFileTree, additionalConfig.getAsFileTree());
// if project has rest tests or the includes are explicitly configured execute the task, else NO-SOURCE due to the null input
return projectHasYamlRestTests || includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false
@ -132,7 +142,7 @@ public class CopyRestApiTask extends DefaultTask {
if (BuildParams.isInternal()) {
getLogger().debug("Rest specs for project [{}] will be copied to the test resources.", project.getPath());
project.copy(c -> {
c.from(coreConfig.getSingleFile());
c.from(coreConfig.getAsFileTree());
c.into(getOutputDir());
c.include(corePatternSet.getIncludes());
});
@ -164,6 +174,14 @@ public class CopyRestApiTask extends DefaultTask {
c.include(xpackPatternSet.getIncludes());
});
}
// TODO: once https://github.com/elastic/elasticsearch/pull/62968 lands ensure that this uses `getFileSystemOperations()`
// copy any additional config
if (additionalConfig != null) {
project.copy(c -> {
c.from(additionalConfig.getAsFileTree());
c.into(getOutputDir());
});
}
}
/**

View File

@ -58,6 +58,7 @@ public class CopyRestTestsTask extends DefaultTask {
String sourceSetName;
Configuration coreConfig;
Configuration xpackConfig;
Configuration additionalConfig;
private final PatternFilterable corePatternSet;
private final PatternFilterable xpackPatternSet;
@ -104,10 +105,14 @@ public class CopyRestTestsTask extends DefaultTask {
coreFileTree = coreConfig.getAsFileTree(); // jar file
}
}
ConfigurableFileCollection fileCollection = getProject().files(coreFileTree, xpackFileTree);
ConfigurableFileCollection fileCollection = additionalConfig == null
? getProject().files(coreFileTree, xpackFileTree)
: getProject().files(coreFileTree, xpackFileTree, additionalConfig.getAsFileTree());
// copy tests only if explicitly requested
return includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false ? fileCollection.getAsFileTree() : null;
return includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false || additionalConfig != null
? fileCollection.getAsFileTree()
: null;
}
@OutputDirectory
@ -158,6 +163,14 @@ public class CopyRestTestsTask extends DefaultTask {
c.include(xpackPatternSet.getIncludes());
});
}
// TODO: once https://github.com/elastic/elasticsearch/pull/62968 lands ensure that this uses `getFileSystemOperations()`
// copy any additional config
if (additionalConfig != null) {
project.copy(c -> {
c.from(additionalConfig.getAsFileTree());
c.into(getOutputDir());
});
}
}
private Optional<SourceSet> getSourceSet() {