Skip to content

Commit d864d14

Browse files
authored
[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.
1 parent 6899ce6 commit d864d14

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestApiTask.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ public class CopyRestApiTask extends DefaultTask {
5858
final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class);
5959
final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class);
6060
String sourceSetName;
61+
boolean skipHasRestTestCheck;
6162
Configuration coreConfig;
6263
Configuration xpackConfig;
64+
Configuration additionalConfig;
6365

6466
private final PatternFilterable corePatternSet;
6567
private final PatternFilterable xpackPatternSet;
@@ -89,6 +91,11 @@ String getSourceSetName() {
8991
return sourceSetName;
9092
}
9193

94+
@Input
95+
public boolean isSkipHasRestTestCheck() {
96+
return skipHasRestTestCheck;
97+
}
98+
9299
@SkipWhenEmpty
93100
@InputFiles
94101
public FileTree getInputDir() {
@@ -98,7 +105,7 @@ public FileTree getInputDir() {
98105
xpackPatternSet.setIncludes(includeXpack.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
99106
xpackFileTree = xpackConfig.getAsFileTree().matching(xpackPatternSet);
100107
}
101-
boolean projectHasYamlRestTests = projectHasYamlRestTests();
108+
boolean projectHasYamlRestTests = skipHasRestTestCheck || projectHasYamlRestTests();
102109
if (includeCore.get().isEmpty() == false || projectHasYamlRestTests) {
103110
if (BuildParams.isInternal()) {
104111
corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
@@ -107,7 +114,10 @@ public FileTree getInputDir() {
107114
coreFileTree = coreConfig.getAsFileTree(); // jar file
108115
}
109116
}
110-
ConfigurableFileCollection fileCollection = getProject().files(coreFileTree, xpackFileTree);
117+
118+
ConfigurableFileCollection fileCollection = additionalConfig == null
119+
? getProject().files(coreFileTree, xpackFileTree)
120+
: getProject().files(coreFileTree, xpackFileTree, additionalConfig.getAsFileTree());
111121

112122
// if project has rest tests or the includes are explicitly configured execute the task, else NO-SOURCE due to the null input
113123
return projectHasYamlRestTests || includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false
@@ -132,7 +142,7 @@ void copy() {
132142
if (BuildParams.isInternal()) {
133143
getLogger().debug("Rest specs for project [{}] will be copied to the test resources.", project.getPath());
134144
project.copy(c -> {
135-
c.from(coreConfig.getSingleFile());
145+
c.from(coreConfig.getAsFileTree());
136146
c.into(getOutputDir());
137147
c.include(corePatternSet.getIncludes());
138148
});
@@ -164,6 +174,14 @@ void copy() {
164174
c.include(xpackPatternSet.getIncludes());
165175
});
166176
}
177+
// TODO: once https://github.com/elastic/elasticsearch/pull/62968 lands ensure that this uses `getFileSystemOperations()`
178+
// copy any additional config
179+
if (additionalConfig != null) {
180+
project.copy(c -> {
181+
c.from(additionalConfig.getAsFileTree());
182+
c.into(getOutputDir());
183+
});
184+
}
167185
}
168186

169187
/**

buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestTestsTask.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class CopyRestTestsTask extends DefaultTask {
5858
String sourceSetName;
5959
Configuration coreConfig;
6060
Configuration xpackConfig;
61+
Configuration additionalConfig;
6162

6263
private final PatternFilterable corePatternSet;
6364
private final PatternFilterable xpackPatternSet;
@@ -104,10 +105,14 @@ public FileTree getInputDir() {
104105
coreFileTree = coreConfig.getAsFileTree(); // jar file
105106
}
106107
}
107-
ConfigurableFileCollection fileCollection = getProject().files(coreFileTree, xpackFileTree);
108+
ConfigurableFileCollection fileCollection = additionalConfig == null
109+
? getProject().files(coreFileTree, xpackFileTree)
110+
: getProject().files(coreFileTree, xpackFileTree, additionalConfig.getAsFileTree());
108111

109112
// copy tests only if explicitly requested
110-
return includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false ? fileCollection.getAsFileTree() : null;
113+
return includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false || additionalConfig != null
114+
? fileCollection.getAsFileTree()
115+
: null;
111116
}
112117

113118
@OutputDirectory
@@ -158,6 +163,14 @@ void copy() {
158163
c.include(xpackPatternSet.getIncludes());
159164
});
160165
}
166+
// TODO: once https://github.com/elastic/elasticsearch/pull/62968 lands ensure that this uses `getFileSystemOperations()`
167+
// copy any additional config
168+
if (additionalConfig != null) {
169+
project.copy(c -> {
170+
c.from(additionalConfig.getAsFileTree());
171+
c.into(getOutputDir());
172+
});
173+
}
161174
}
162175

163176
private Optional<SourceSet> getSourceSet() {

0 commit comments

Comments
 (0)