Skip to content

Commit 1c0b642

Browse files
committed
test: make sure to fail if version wrong
1 parent 1e5713d commit 1c0b642

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

testinfra/test_ami_nix.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,20 @@ def test_postgresql_version(host):
540540

541541

542542
def test_libpq5_version(host):
543-
"""Print the libpq5 version installed."""
543+
"""Print the libpq5 version installed and ensure it's >= 14."""
544544
# Try different package managers to find libpq5
545545
result = run_ssh_command(host['ssh'], "dpkg -l | grep libpq5 || true")
546546
if result['succeeded'] and result['stdout'].strip():
547547
print(f"\nlibpq5 package info:\n{result['stdout']}")
548+
# Extract version from dpkg output (format: ii libpq5:arm64 17.5-1.pgdg20.04+1)
549+
import re
550+
version_match = re.search(r'libpq5[^ ]* +(\d+)\.', result['stdout'])
551+
if version_match:
552+
major_version = int(version_match.group(1))
553+
print(f"libpq5 major version: {major_version}")
554+
assert major_version >= 14, f"libpq5 version {major_version} is less than 14"
555+
else:
556+
print("Could not parse libpq5 version from dpkg output")
548557
else:
549558
print("\nlibpq5 not found via dpkg")
550559

@@ -562,8 +571,21 @@ def test_libpq5_version(host):
562571
else:
563572
print("\nCould not find libpq dependency for psql")
564573

565-
# This test always passes, it's just for informational purposes
566-
assert True
574+
# Try to get version from libpq directly
575+
result = run_ssh_command(host['ssh'], "psql --version 2>&1 | head -1")
576+
if result['succeeded'] and result['stdout'].strip():
577+
print(f"\npsql version output: {result['stdout'].strip()}")
578+
# The psql version should match the libpq version
579+
import re
580+
version_match = re.search(r'psql \(PostgreSQL\) (\d+)\.', result['stdout'])
581+
if version_match:
582+
major_version = int(version_match.group(1))
583+
print(f"psql/libpq major version: {major_version}")
584+
assert major_version >= 14, f"psql/libpq version {major_version} is less than 14"
585+
else:
586+
print("Could not parse psql version")
587+
588+
print("✓ libpq5 version is >= 14")
567589

568590

569591
def test_postgrest_read_only_session_attrs(host):

0 commit comments

Comments
 (0)