Skip to content

Commit

Permalink
Fix configuration cache incompatibility in Rest compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
breskeby committed Nov 6, 2023
1 parent cef2b80 commit 880c974
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.gradle.api.file.FileSystemOperations;
import org.gradle.api.file.FileTree;
import org.gradle.api.file.ProjectLayout;
import org.gradle.api.internal.file.FileOperations;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.IgnoreEmptyDirectories;
Expand Down Expand Up @@ -43,7 +44,7 @@
*
* @see RestResourcesPlugin
*/
public class CopyRestTestsTask extends DefaultTask {
public abstract class CopyRestTestsTask extends DefaultTask {
private static final String REST_TEST_PREFIX = "rest-api-spec/test";
private final ListProperty<String> includeCore;
private final ListProperty<String> includeXpack;
Expand All @@ -62,6 +63,9 @@ public class CopyRestTestsTask extends DefaultTask {
private final ProjectLayout projectLayout;
private final FileSystemOperations fileSystemOperations;

@Inject
public abstract FileOperations getFileOperations();

@Inject
public CopyRestTestsTask(
ProjectLayout projectLayout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,17 @@ public void transform() throws IOException {
Collections.singletonList(new Skip(skippedFilesWithReason.get(file)))
);
} else {
List<RestTestTransform<?>> transformations = new ArrayList<>(getTransformations().get());

if (skippedFilesWithTestAndReason.containsKey(file)) {
// skip the named tests for this file
skippedFilesWithTestAndReason.get(file).forEach(fullTestNameAndReasonPair -> {
String prefix = file.getName().replace(".yml", "/");
String singleTestName = fullTestNameAndReasonPair.getLeft().replaceAll(".*" + prefix, "");
getTransformations().add(new Skip(singleTestName, fullTestNameAndReasonPair.getRight()));
transformations.add(new Skip(singleTestName, fullTestNameAndReasonPair.getRight()));
});
}
transformRestTests = transformer.transformRestTests(new LinkedList<>(tests), getTransformations().get());
transformRestTests = transformer.transformRestTests(new LinkedList<>(tests), transformations);
}

// convert to url to ensure forward slashes
Expand Down
7 changes: 4 additions & 3 deletions x-pack/qa/xpack-prefix-rest-compat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ tasks.named("copyRestCompatTestTask").configure { task ->
task.dependsOn(configurations.compatXpackTests);
task.setXpackConfig(configurations.compatXpackTests);
task.getIncludeXpack().set(List.of("license", "migration", "ml", "rollup", "sql", "ssl"));
task.getOutputResourceDir().set(project.getLayout().getBuildDirectory().dir("restResources/v${compatVersion}/yamlTests/original"));
def fileOperations = task.getFileOperations()
task.getOutputResourceDir().set(project.getLayout().getBuildDirectory().dir("restResources/v${compatVersion}/yamlTests/original"))
task.setXpackConfigToFileTree(
config -> fileTree(
config.getSingleFile().toPath()
config -> fileOperations.fileTree(
config.getSingleFile()
)
)
}
Expand Down

0 comments on commit 880c974

Please sign in to comment.