Repository navigation
Add RequireServerVersion annotation for tests - #3939
Conversation
|
I would suggest going with junit-like naming: See |
9061529 to
5794e33
Compare
|
Renamed to |
It might be reasonable to have both. |
I agree, It's plain to say disabled for. |
|
Do you mean add |
|
I mean we could add |
|
@sehrope are we waiting for something? Might as well merge this |
vlsi
left a comment
There was a problem hiding this comment.
This is a clear improvement. I post several comments, however, feel free to decide if you want to address them or not.
The PR title and description refer to @RequireServerVersion but the actual implementation uses @EnabledForServerVersionRange. The title should be updated to match.
|
For reference, JUnit has both However, if we allow |
|
Was mostly done addressing the feedback but didn't get a chance yet to finish testing the changes. Snowed in for the day so figure will get to wrapping it up by this afternoon. |
âĶcify mandatory server version ranges
âĶrverVersionRange
5794e33 to
615c7c0
Compare
|
Rebased and force pushed. Adds Added a base parent for both as the majority of the version related code is the same. Each just defines how it matches and whether it's negative or positive result. Also includes checks that:
To unify the code both are implemented by deciding if we match, and then returning either the enabled or disabled result depending on the annotation. Note that the "matches" logic for the disabled annotation is backwards. If it matches, the test is disabled. The response message is slightly worse than before for the enabled annotation as we only say whether we did not match at all (previously we would explicitly say which of the lt / lte / gte / gt clauses was violated). But that was done because the same approach does not work for the disabled annotation and wanted to keep the code consistent. If someone is investigating can always look at the actual annotations anyway. I'll merge this tomorrow if there's nothing new. |
Three commits here which:
@RequireServerVersionannotation for tests that allows declaring the applicable server versions.@DisabledIfServerVersionBelowand@DisabledIfServerVersionGreaterusage with@RequireServerVersionMain driver for this was trying to understand which test is running when. The double negative for the annotation vs the check makes it confusing (e.g., it runs when it's not disabled and that is driven by the version being below...).
It's also ambiguous if something like "Greater than 10" really means greater than or equal 10.0.
The new approach positive affirms the situations where we want the thing to run with annotation args for:
lt- Less thanlte- Less than or equalgt- Greater thangte- Greater than or equalI'd expect that
ltandgteare going to be the most useful. The "less than" makes sense if you want all versions older than X (where presumably it breaks). And "greater than or equal" makes sense when X is the first version that supports a given feature that is being tested. Ex:Note that the old
@DisabledIfServerVersionGreater("19")name implied a>check, but its implementation actually used>=, disabling the test for version 19 and above. The migration to@RequireServerVersion(lt = "19")preserves that existing runtime behavior while making the boundary semantics explicit.One minor improvement to the old approach was caching the server response in the junit context. That shaves a connection open / close per annotation call. I doubt it's meaningfully different (24 uses of the annotation times 10ms per connection rounds to nothing) but nice to have an example of that in the test code. It may be useful somewhere else too.