Collection of cookbooks for Podman Quadlets
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

39 lines
1.2 KiB

"""Shared constants and helper functions for PostgreSQL integration tests.
These are extracted from conftest.py so that test modules can import them
without conflicting with pytest's conftest discovery mechanism.
"""
from pathlib import Path
# Default version shipped in the example config.env.
PG_MAJOR_DEFAULT = "14"
# Version to start from in the major-upgrade scenario.
PG_MAJOR_UPGRADE_FROM = "14"
# Version to upgrade to in the major-upgrade scenario.
PG_MAJOR_UPGRADE_TO = "17"
# Default credentials from config/examples/config.env.
PG_USER = "postgres"
PG_PASSWORD = "postgres"
PG_DB = "postgres"
def run_sql(vm, ssh_key: Path, sql: str) -> str:
"""Execute *sql* via ``podman exec`` on the running postgresql-server container.
Uses the Unix socket at /var/run/postgresql inside the container (mapped
from /run/quadlets/postgresql on the host). The pg_hba.conf generated by
the official postgres image grants trust access on local sockets, so no
password is required.
Returns:
Stripped stdout of the psql command.
"""
result = vm.ssh_run(
f"podman exec postgresql-server psql -U {PG_USER} -t -c \"{sql}\"",
ssh_key,
)
return result.stdout.strip()