Message-ID: From: "sehrope (@sehrope)" To: "pgjdbc/pgjdbc" Date: Sat, 14 Feb 2026 18:35:05 +0000 Subject: [pgjdbc/pgjdbc] PR #3939: Add RequireServerVersion annotation for tests List-Id: X-GitHub-Author-Id: 1690926 X-GitHub-Author-Login: sehrope X-GitHub-Issue: 3939 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: merged X-GitHub-Type: pull_request X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/pull/3939 Content-Type: text/plain; charset=utf-8 Three commits here which: * Add a new `@RequireServerVersion` annotation for tests that allows declaring the applicable server versions. * Replaces the `@DisabledIfServerVersionBelow` and `@DisabledIfServerVersionGreater` usage with `@RequireServerVersion` * Removes the unused annotations Main 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 than * `lte` - Less than or equal * `gt` - Greater than * `gte` - Greater than or equal I'd expect that `lt` and `gte` are 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: ```diff @@ -297,7 +297,7 @@ class LogicalReplicationStatusTest { * Test fail on PG version 9.4.5 because postgresql have bug. */ @Test - @DisabledIfServerVersionBelow("9.4.8") + @RequireServerVersion(gte = "9.4.8") void applyLocationDoNotDependOnFlushLocation() throws Exception { PGConnection pgConnection = (PGConnection) replicationConnection; ``` 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.