-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Use versioned sourceset for REST compat testing #78418
Use versioned sourceset for REST compat testing #78418
Conversation
Pinging @elastic/es-delivery (Team:Delivery) |
@@ -55,6 +54,7 @@ | |||
@Override | |||
public void apply(Project project) { | |||
final int compatibleVersion = Version.fromString(VersionProperties.getVersions().get("elasticsearch")).getMajor() - 1; | |||
final String sourceSetName = "yamlRestTestV" + compatibleVersion + "Compat"; | |||
final Path compatRestResourcesDir = Path.of("restResources").resolve("v" + compatibleVersion); |
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.
If we are having version-specific source sets, do we still need to capture the version here in the file path as well. As it is now we have files like src/yamlRestTestV7Compat/resources/rest-api-spec/test/v7compat/foo/bar.yml
. We probably don't need to track the version twice now. Also begs the question whether we need this change in the first place if we are already managing per-version test resources. How will this affect backporting, etc?
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.
src/yamlRestTestV7Compat/resources/rest-api-spec/test/v7compat/foo/bar.yml
uses a 4 part path to keept it from colliding with the actual v7 test/foo/bar.yml
if it exists. (Both the real v7 tests and the custom test in this source set are on the same classpath, and there quite a bit of re-use of file names). v7compat
in the path is just a convention and included the v7 to help demark these are intended for compatibilty with v7. The fact this is just a convention and without any teeth (i.e. these would execute when master is v9) is a motivating factor for this PR.
I can remove the v7
from the v7compat
convention in this PR since I agree it doesn't make sense now. I think I could also remove this extra directory entirely and ensure uniqueness of the files between the two sources of tests (with validation in Gradle). Thoughts ?
Since our REST compatilbity only supports 1 major version, these should never be backported and anything in this sourceset should be removed in the next major 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.
I can remove the v7 from the v7compat convention in this PR since I agree it doesn't make sense now. I think I could also remove this extra directory entirely and ensure uniqueness of the files between the two sources of tests (with validation in Gradle). Thoughts ?
Yeah, I think that makes sense. It's just less stuff to try and keep in sync.
@@ -126,13 +127,15 @@ void copy() { | |||
|
|||
getLogger().debug("Rest specs for project [{}] will be copied to the test resources.", projectPath); | |||
fileSystemOperations.copy(c -> { | |||
c.setDuplicatesStrategy(DuplicatesStrategy.FAIL); |
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.
These duplicate fails are not actually needed for this PR, but I realized while adding the custom duplicate check to the compat testing task, it would be good to add a duplicate check here too.
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 don't think this is necessary since FAIL
is now the default behavior in Gradle 7.0 and later.
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.
ah.. it is. gradle/gradle#15759 I will remove this.
+ ".x] branch and the [" + sourceSetName + "] tests. "); | ||
} | ||
} | ||
}); |
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.
example of failure:
* What went wrong:
Execution failed for task ':rest-api-spec:yamlRestTestV7CompatTest'.
> Found duplicated test(s) [search/30_limits.yml] please ensure there not any duplicate YAML test files between the [7.x] branch and the [yamlRestTestV7Compat] tests.
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'm wondering if it might be better (and simpler) to implement this in the yaml testing framework code instead. It could be as simple as checking the result of the call to add()
here and throwing an exception if it returns false
.
@mark-vieira - should be ready for another review. I implemented a duplicate check to ensure that the same test file is not on the class path more then once. 98% of the tests use 2 parts (foo/bar.yml) under the folder test and the duplicate check checks for those 2 parts. There is a slim chance of a false positive if a test uses 3 parts and the custom compat uses 2 part and there is name collision, but that is extremely unlikely. I also removed the uncessary |
@elasticmachine update branch |
...al/src/main/java/org/elasticsearch/gradle/internal/rest/compat/YamlRestCompatTestPlugin.java
Outdated
Show resolved
Hide resolved
+ ".x] branch and the [" + sourceSetName + "] tests. "); | ||
} | ||
} | ||
}); |
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'm wondering if it might be better (and simpler) to implement this in the yaml testing framework code instead. It could be as simple as checking the result of the call to add()
here and throwing an exception if it returns false
.
Pinging @elastic/clients-team (Team:Clients) |
Changed on It turns out we actually do support running duplicates on the classpath without stomping on each other. The framework will append a #2 to each test name. In light of this, i reduced the error down to a warning since which test (the first or the second with the same name) gets the #2 appended is dependent on the classloading order. We probably could add in some specific ordering of the collections so it wouldn't be classloader ordering but it would be some other non obvious ordering. The new warning is there in part to inform future developers that we actually do support duplicated names. Example of the new warning message:
I don't have a strong opinion to keep or leave this warning. |
@mark-vieira - finally got back round to this. should be ready for another review |
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.
LGTM
@elasticmachine update branch |
This commit changes the sourceset name for REST API compatility testing
from yamlRestCompatTest to yamlRestTestV(N)Compat wher
(N)
is the versionfrom which the tests are sourced. For example yamlRestTestV7Compat
or yamlRestTestV8Compat.
Two motivating reasons for this change.
consitent naming - all compatible rest testing will now use a common
prefix of
yamlRestTestV7Compat
where the task name to execute isyamlRestTestV7CompatTest
and the transformation task isyamlRestTestV7CompatTransform
It makes sense that corresponding source set follows this convention.
Better support when the major version changes. Gradle uses the source
set under the covers to execute the compatiblity tests. However, a user
can add custom REST tests to this source set. By using dynamically named
source sets, there should little concern of accidentally running the wrong
version tests. Additionaly it is visualy easy to tell which version the tests are
from.
This commit also removes the unecessary duplicated v7compat directory
and adds copy and classpath duplicate checks to ensure that we don't
accidentally stomp on duplicates with all of the copy and classpath manipulation.
related: #75267