-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: add Postgres version check
- Loading branch information
Showing
3 changed files
with
30 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
from fixtures.neon_fixtures import PgBin | ||
from fixtures.pg_version import PgVersion | ||
|
||
|
||
def test_postgres_version(base_dir: Path, pg_bin: PgBin, pg_version: PgVersion): | ||
"""Test that Postgres version matches the one we expect""" | ||
|
||
with (base_dir / "vendor" / "revisions.json").open() as f: | ||
expected_revisions = json.load(f) | ||
|
||
output_prefix = pg_bin.run_capture(["postgres", "--version"], with_command_header=False) | ||
stdout = Path(f"{output_prefix}.stdout") | ||
assert stdout.exists(), "postgres --version didn't print anything to stdout" | ||
|
||
with stdout.open() as f: | ||
output = f.read().strip() | ||
|
||
# `postgres --version` prints something like "postgres (PostgreSQL) 14.8 1144aee1661c79eec65e784a8dad8bd450d9df79". | ||
# We need only last 2 components of it — verison itself and SHA of the commit. | ||
_, version, sha = output.rsplit(" ", 2) | ||
|
||
msg = f"Unexpected Postgres {pg_version} version: `{output}`, please update `vendor/revisions.json` if these changes are intentional" | ||
assert (version, sha) == expected_revisions[pg_version], msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"postgres-v16": "261497dd63ace434045058b1453bcbaaa83f23e5", | ||
"postgres-v15": "85d809c124a898847a97d66a211f7d5ef4f8e0cb", | ||
"postgres-v14": "d9149dc59abcbeeb26293707509aef51752db28f" | ||
"16.2": "261497dd63ace434045058b1453bcbaaa83f23e5", | ||
"15.6": "85d809c124a898847a97d66a211f7d5ef4f8e0cb", | ||
"14.11": "d9149dc59abcbeeb26293707509aef51752db28f" | ||
} |