-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Introduce yamlRestCompatTest task and plugin. #62985
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
Conversation
|
Pinging @elastic/es-core-infra (:Core/Infra/Build) |
| final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class); | ||
| final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class); | ||
| String sourceSetName; | ||
| boolean skipHasRestTestCheck; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed so that you can run compat tests for a project that may no longer have YAML REST tests in master. Also, there may be cases where a module is completely deleted in master, but we will still want to use this plugin to only test compatibility.
This basically ensures that the execution of "compat" YAML tests is not directly coupled to the existence of "normal" YAML rest tests.
| boolean skipHasRestTestCheck; | ||
| Configuration coreConfig; | ||
| Configuration xpackConfig; | ||
| Configuration additionalConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed as a way to copy the 7.x module/plugin tests to the source set. For "normal" YAML tests they are already in the source set (since they are part of the current source code).
rjernst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We seem to be only testing against the previous minor, but shouldn't we create bwc test tasks for comparing against all compatible versions?
| .getBuildDir() | ||
| .toPath() | ||
| .resolve("bwc") | ||
| .resolve("checkout-" + priorMajorVersion + ".x"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we peeking at the source? Instead can we produce the files as an artifact? This would allow us to test against already released versions in the same way, just grab the zip of the spec/test files of that released version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The artifacts we produce only contain the OSS core api and tests. I need the x-pack core api/tests as well as all of the OSS/X-pack module/plugin API/tests. Back filling those I think is a reasonable approach as a long term solution, but I think sourcing like this is decent temporary approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree with @rjernst that peeking into other source folders is kind of an anti pattern. Instead sharing it declaratively as described here: https://docs.gradle.org/current/userguide/cross_project_publications.html is what we should aim for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally I think the bwc project would just share the checkoutDir as an artifact. Can you put a TODO in there to look into this after #62473 I will then pick that up at one. point. This PR does quite some rework on the bwc setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, exposing the checkoutDir as an artifact, I think will clean this up. I added a TODO in the code to come back to this.
Yes, testing against all prior minor versions is the long term goal. This PR is satisfies the short term goal that will allow the bare min. needed to start testing compatibility. I am presuming that testing compatibility against the latest minor should be part of the project's check task, and testing against all branches would be a new lifecycle task (similar to bwc). To satisfy the long term goal (and introduce a new lifecycle task to test all prior minors) we will need a way to checkout an arbitrary branch/tag or publish artifacts for ALL of the rest tests for each minor version (the existing artifacts only contain the OSS api/tests). This will need further discussion, but hoping that this approach is sufficient as a starting point. |
breskeby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some remarks regarding resolving and sharing artefacts among projects similar to what @rjernst commented and added a remark about avoiding project.copy{} at execution time. We probably want to tackle this sharing resources as artifacts in a separate story and not as part of this PR. If not we should at least create a ticket for this problem
| .getBuildDir() | ||
| .toPath() | ||
| .resolve("bwc") | ||
| .resolve("checkout-" + priorMajorVersion + ".x"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree with @rjernst that peeking into other source folders is kind of an anti pattern. Instead sharing it declaratively as described here: https://docs.gradle.org/current/userguide/cross_project_publications.html is what we should aim for.
| // always copy the core specs if the task executes | ||
| if (BuildParams.isInternal()) { | ||
| getLogger().debug("Rest specs for project [{}] will be copied to the test resources.", project.getPath()); | ||
| project.copy(c -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd like to get away from using the project property within task actions. I'm currently working on #62968 Instead using project.copy{} we should inject a FileSystemOperations service and use that one for these kind of operations. See for example the LoggedExec task how this service is injected: https://github.com/elastic/elasticsearch/pull/62968/files#diff-babd4b74d83a9cea8bf0823cf6b71b66
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some TODO's for the new project.copy's to ensure it uses the newer style once that PR lands. I didn't make the change now to avoid avoid copy/paste code from your PR (which could merge clash). If this PR beats yours then feel free to add it to your, else I will circle back to this.
| } | ||
| // copy any additional config | ||
| if (additionalConfig != null) { | ||
| project.copy(c -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
| .getBuildDir() | ||
| .toPath() | ||
| .resolve("bwc") | ||
| .resolve("checkout-" + priorMajorVersion + ".x"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally I think the bwc project would just share the checkoutDir as an artifact. Can you put a TODO in there to look into this after #62473 I will then pick that up at one. point. This PR does quite some rework on the bwc setup
| project.getDependencies() | ||
| .add( | ||
| task.coreConfig.getName(), | ||
| project.files(checkoutDir.resolve("rest-api-spec/src/main/resources").resolve(RELATIVE_API_PATH)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. We should not rely on file dependencies and provide these dependencies as artifacts of the bwc project.
|
Add some more TODO's to revisit after Rene's PRs land as well as to test multiple versions using published artifacts as discussed. |
This commit introduces a plugin to run REST compatibility tests. The plugin is not currently applied to any projects with this commit, but it establishes the foundation for testing REST compatibility. This plugin will be applied to all core, plugin, and module projects that currently have YAML based REST tests. This plugin, when applied will do the following: * Create a new sourceset that extends from the yamlRestTest sourceset * Ensure the default distribution is used to execute the tests * Checkout bwc:minor version of the source code * Copy the rest api and rest tests from bwc:minor to the new sourceset * Create the test task, but manipulate the classpath so it uses the "normal" YAML test runner, but the "compat" set of tests * wire up dependencies, ide, and check The implementation here depends on :distribution:bwc:minor:checkoutBwcBranch which is a convenient way to git checkout the most recent prior branch. This approach works but is a bit fragile and long term would like a more robust way to checkout arbitrary prior branches. This would be a fairly large effort and is not included in this commit. Also not included in this commit is the code necessary to inject the compatible header, any customization to running the compatibility tests, or any of the logic to override specific tests. Future commits will address those concerns.
This commit introduces a plugin to run REST compatibility tests.
The plugin is not currently applied to any projects with this commit,
but it establishes the foundation for testing REST compatibility.
This plugin will be applied to all core, plugin, and module projects
that currently have YAML based REST tests. This plugin, when applied
will do the following:
"normal" YAML test runner, but the "compat" set of tests
The implementation here depends on :distribution:bwc:minor:checkoutBwcBranch
which is a convenient way to git checkout the most recent prior branch.
This approach works but is a bit fragile and long term would like a more
robust way to checkout arbitrary prior branches. This would be a fairly large
effort and is not included in this commit.
Also not included in this commit is the code necessary to inject the
compatible header, any customization to running the compatibility tests,
or any of the logic to override specific tests. Future commits will address
those concerns.