Skip to content

Commit

Permalink
Add Postgres commit sha to Postgres version (#4603)
Browse files Browse the repository at this point in the history
## Problem

Ref https://neondb.slack.com/archives/C036U0GRMRB/p1688122168477729

## Summary of changes
- Add sha from postgres repo into postgres version string (via
`--with-extra-version`)
- Add a test that Postgres version matches the expected one
- Remove build-time hard check and allow only related tests to fail
  • Loading branch information
bayandin authored May 7, 2024
1 parent 5a3d8e7 commit 51376ef
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 29 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,6 @@ jobs:
submodules: true
fetch-depth: 1

- name: Check Postgres submodules revision
shell: bash -euo pipefail {0}
run: |
# This is a temporary solution to ensure that the Postgres submodules revision is correct (i.e. the updated intentionally).
# Eventually it will be replaced by a regression test https://github.com/neondatabase/neon/pull/4603
FAILED=false
for postgres in postgres-v14 postgres-v15 postgres-v16; do
expected=$(cat vendor/revisions.json | jq --raw-output '."'"${postgres}"'"')
actual=$(git rev-parse "HEAD:vendor/${postgres}")
if [ "${expected}" != "${actual}" ]; then
echo >&2 "Expected ${postgres} rev to be at '${expected}', but it is at '${actual}'"
FAILED=true
fi
done
if [ "${FAILED}" = "true" ]; then
echo >&2 "Please update vendor/revisions.json if these changes are intentional"
exit 1
fi
- name: Set pg 14 revision for caching
id: pg_v14_rev
run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v14) >> $GITHUB_OUTPUT
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ $(POSTGRES_INSTALL_DIR)/build/%/config.status:
echo "'git submodule update --init --recursive --depth 2 --progress .' in project root.\n"; \
exit 1; }
mkdir -p $(POSTGRES_INSTALL_DIR)/build/$*
(cd $(POSTGRES_INSTALL_DIR)/build/$* && \
env PATH="$(EXTRA_PATH_OVERRIDES):$$PATH" $(ROOT_PROJECT_DIR)/vendor/postgres-$*/configure \

VERSION=$*; \
EXTRA_VERSION=$$(cd $(ROOT_PROJECT_DIR)/vendor/postgres-$$VERSION && git rev-parse HEAD); \
(cd $(POSTGRES_INSTALL_DIR)/build/$$VERSION && \
env PATH="$(EXTRA_PATH_OVERRIDES):$$PATH" $(ROOT_PROJECT_DIR)/vendor/postgres-$$VERSION/configure \
CFLAGS='$(PG_CFLAGS)' \
$(PG_CONFIGURE_OPTS) \
--prefix=$(abspath $(POSTGRES_INSTALL_DIR))/$* > configure.log)
$(PG_CONFIGURE_OPTS) --with-extra-version=" ($$EXTRA_VERSION)" \
--prefix=$(abspath $(POSTGRES_INSTALL_DIR))/$$VERSION > configure.log)

# nicer alias to run 'configure'
# Note: I've been unable to use templates for this part of our configuration.
Expand Down
2 changes: 1 addition & 1 deletion test_runner/fixtures/neon_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,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
35 changes: 35 additions & 0 deletions test_runner/regress/test_postgres_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import json
import re
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) 15.6 (85d809c124a898847a97d66a211f7d5ef4f8e0cb)".
pattern = r"postgres \(PostgreSQL\) (?P<version>\d+\.\d+) \((?P<commit>[0-9a-f]{40})\)"
match = re.search(pattern, output, re.IGNORECASE)
assert match is not None, f"Can't parse {output} with {pattern}"

version = match.group("version")
commit = match.group("commit")

assert (
pg_version.v_prefixed in expected_revisions
), f"Version `{pg_version.v_prefixed}` doesn't exist in `vendor/revisions.json`, please update it if these changes are intentional"

msg = f"Unexpected Postgres {pg_version} version: `{output}`, please update `vendor/revisions.json` if these changes are intentional"
assert [version, commit] == expected_revisions[pg_version.v_prefixed], 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": "8ef3c33aa01631e17cb24a122776349fcc777b46",
"postgres-v15": "f0d6b0ef7581bd78011832e23d8420a7d2c8a83a",
"postgres-v14": "d6f7e2c604bfc7cbc4c46bcea0a8e800f4bc778a"
"v16": ["16.2", "8ef3c33aa01631e17cb24a122776349fcc777b46"],
"v15": ["15.6", "f0d6b0ef7581bd78011832e23d8420a7d2c8a83a"],
"v14": ["14.11", "d6f7e2c604bfc7cbc4c46bcea0a8e800f4bc778a"]
}

1 comment on commit 51376ef

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3051 tests run: 2907 passed, 4 failed, 140 skipped (full report)


Failures on Postgres 14

  • test_pgbench_intensive_init_workload[neon_off-github-actions-selfhosted-1000]: release
  • test_heavy_write_workload[neon_on-github-actions-selfhosted-10-5-5]: release
  • test_storage_controller_many_tenants[github-actions-selfhosted]: release
  • test_bulk_tenant_create[github-actions-selfhosted-5]: release
# Run all failed tests locally:
scripts/pytest -vv -n $(nproc) -k "test_pgbench_intensive_init_workload[neon_off-release-pg14-github-actions-selfhosted-1000] or test_heavy_write_workload[neon_on-release-pg14-github-actions-selfhosted-10-5-5] or test_storage_controller_many_tenants[release-pg14-github-actions-selfhosted] or test_bulk_tenant_create[release-pg14-github-actions-selfhosted-5]"

Code coverage* (full report)

  • functions: 31.3% (6246 of 19976 functions)
  • lines: 46.7% (46762 of 100097 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
51376ef at 2024-05-07T16:59:49.466Z :recycle:

Please sign in to comment.