Skip to content

Commit

Permalink
test_runner: add Postgres version check
Browse files Browse the repository at this point in the history
  • Loading branch information
bayandin committed Apr 17, 2024
1 parent 498d884 commit d2321a2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test_runner/fixtures/neon_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ class NeonEnv:
Some notable functions and fields in NeonEnv:
postgres - A factory object for creating postgres compute nodes.
endpoints - A factory object for creating postgres compute nodes.
pageservers - An array containing objects representing the pageservers
Expand Down
26 changes: 26 additions & 0 deletions test_runner/regress/test_postgres_version.py
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
6 changes: 3 additions & 3 deletions vendor/revisions.json
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"
}

0 comments on commit d2321a2

Please sign in to comment.