Skip to content

Commit 3e8ffd0

Browse files
committed
accept patch version too and run regression tests
1 parent b504db6 commit 3e8ffd0

10 files changed

Lines changed: 346 additions & 121 deletions

File tree

.github/workflows/test-package-installation.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Test Latest Citus Package Installation on Supported PostgreSQL Versions
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
citus_version:
7+
description: "Citus full version (e.g., 14.0.0)"
8+
required: true
9+
type: string
510

611
env:
712
# Branch whose build-package.yml and postgres-matrix.yml are the source of truth
@@ -13,7 +18,6 @@ jobs:
1318
runs-on: ubuntu-latest
1419
outputs:
1520
matrix: ${{ steps.build_matrix.outputs.matrix }}
16-
citus_version: ${{ steps.resolve_versions.outputs.citus_version }}
1721
steps:
1822
- name: Checkout repository
1923
uses: actions/checkout@v4
@@ -35,24 +39,36 @@ jobs:
3539
echo "Discovered platforms: ${platforms}"
3640
echo "platforms=${platforms}" >> "$GITHUB_OUTPUT"
3741
38-
- name: Resolve Citus & PG versions from postgres-matrix.yml
42+
- name: Resolve PG versions from postgres-matrix.yml
3943
id: resolve_versions
4044
run: |
4145
git show "origin/${SOURCE_BRANCH}:postgres-matrix.yml" > /tmp/postgres-matrix.yml
4246
43-
# Latest entry = last element in version_matrix
44-
citus_version=$(yq '.version_matrix[-1] | keys | .[0]' /tmp/postgres-matrix.yml)
47+
citus_version="${{ inputs.citus_version }}"
48+
49+
# Validate x.y.z format
50+
if ! [[ "$citus_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
51+
echo "::error::citus_version must be in x.y.z format (e.g., 14.0.0), got: ${citus_version}"
52+
exit 1
53+
fi
54+
55+
# Extract major.minor for postgres-matrix.yml lookup
56+
citus_major_minor="${citus_version%.*}"
4557
4658
pg_versions=$(
4759
yq -o=json \
48-
".version_matrix[-1].\"${citus_version}\".postgres_versions" \
60+
".version_matrix[] | select(has(\"${citus_major_minor}\")).\"${citus_major_minor}\".postgres_versions" \
4961
/tmp/postgres-matrix.yml \
5062
| jq -c '[.[] | tostring]'
5163
)
5264
53-
echo "Latest Citus version: ${citus_version}"
65+
if [[ -z "$pg_versions" || "$pg_versions" == "null" ]]; then
66+
echo "::error::No entry found for Citus ${citus_major_minor} in postgres-matrix.yml"
67+
exit 1
68+
fi
69+
70+
echo "Citus version: ${citus_version} (major.minor: ${citus_major_minor})"
5471
echo "Supported PG versions: ${pg_versions}"
55-
echo "citus_version=${citus_version}" >> "$GITHUB_OUTPUT"
5672
echo "pg_versions=${pg_versions}" >> "$GITHUB_OUTPUT"
5773
5874
- name: Build matrix
@@ -66,7 +82,7 @@ jobs:
6682
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
6783
6884
test_package:
69-
name: "PG${{ matrix.pg_version }}/Citus${{ needs.discover.outputs.citus_version }} - ${{ matrix.platform }}"
85+
name: "PG${{ matrix.pg_version }}/Citus${{ inputs.citus_version }} - ${{ matrix.platform }}"
7086
needs: discover
7187
runs-on: ubuntu-latest
7288
strategy:
@@ -86,4 +102,4 @@ jobs:
86102
python3 test_package_installation/run_test.py \
87103
"${{ matrix.platform }}" \
88104
"${{ matrix.pg_version }}" \
89-
"${{ needs.discover.outputs.citus_version }}"
105+
"${{ inputs.citus_version }}"

test_package_installation/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,33 @@
22

33
Verifies that Citus packages can be installed from the package repository on all supported platforms.
44

5-
Each test spins up a Docker container for the target OS, installs the PostgreSQL and Citus packages,
6-
sets up a cluster, and runs very basic tests.
5+
Each test:
6+
* spins up a Docker container for the target OS
7+
* installs the PostgreSQL and Citus packages
8+
* sets up a cluster and runs very basic tests
9+
* runs `make check-multi` regression tests from the Citus repository against the installed Citus version
710

811
## Running locally
912

1013
Requires **Python 3.10+** and **Docker**. No additional Python packages needed.
1114

1215
```bash
13-
python3 test_package_installation/run_test.py <platform> <pg_major_version> <citus_major_minor_version>
16+
python3 test_package_installation/run_test.py <platform> <pg_major_version> <citus_full_version>
1417
```
1518

1619
Examples:
1720

1821
```bash
19-
python3 test_package_installation/run_test.py ubuntu/noble 18 14.0
20-
python3 test_package_installation/run_test.py el/9 17 14.0
21-
python3 test_package_installation/run_test.py debian/bookworm 16 14.0
22+
python3 test_package_installation/run_test.py ubuntu/noble 18 14.0.0
23+
python3 test_package_installation/run_test.py el/9 17 14.0.0
24+
python3 test_package_installation/run_test.py debian/bookworm 16 14.0.0
2225
```
2326

2427
## Running via GitHub Actions
2528

2629
You can manually trigger the workflow using [this GitHub Actions tab](https://github.com/citusdata/packaging/actions/workflows/test-package-installation.yml).
2730

28-
It automatically discovers the supported platforms, latest Citus version that we published
29-
packages for, and compatible PostgreSQL versions from the `all-citus` branch, using
30-
[.github/workflows/build-package.yml](https://github.com/citusdata/packaging/blob/all-citus/.github/workflows/build-package.yml) and [postgres-matrix.yml](https://github.com/citusdata/packaging/blob/all-citus/postgres-matrix.yml) files.
31+
It asks for the Citus version to test, and then it automatically discovers the supported platforms and
32+
compatible PostgreSQL versions from the `all-citus` branch, using
33+
[.github/workflows/build-package.yml](https://github.com/citusdata/packaging/blob/all-citus/.github/workflows/build-package.yml)
34+
and [postgres-matrix.yml](https://github.com/citusdata/packaging/blob/all-citus/postgres-matrix.yml) files.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# Runs "make check-multi" (multi_schedule).
4+
#
5+
# Expects the Citus source to be cloned at /citus and pg_regress
6+
# to be available in the PostgreSQL binary path.
7+
#
8+
# Usage: run_multi_schedule.sh <pg_binary_path>
9+
# Example: run_multi_schedule.sh /usr/lib/postgresql/18/bin
10+
11+
set -euo pipefail
12+
13+
if [ -z "$1" ]; then
14+
echo "Error: some arguments are missing." >&2
15+
echo "Usage: $0 <pg_binary_path>" >&2
16+
exit 1
17+
fi
18+
19+
PG_BIN="$1"
20+
21+
## suppress some of the regression test failures
22+
23+
# On rpm based distros, Postgres package might be linked against a newer ICU
24+
# than the one used to generate expected test output. To avoid test failures
25+
# due to this, patch the expected output to match the newer ICU version.
26+
# Without this, today pg18.sql fails.
27+
echo 's/und-u-kc-true-ks-level1/und-u-kc-ks-level1/g' >> /citus/src/test/regress/bin/normalize.sed
28+
29+
## run "make check-multi"
30+
31+
export PATH="${PG_BIN}:${PATH}"
32+
33+
cd /citus
34+
35+
# we don't need lz4 and zstd as none of the tests in multi_schedule depend on them
36+
./configure PG_CONFIG="${PG_BIN}/pg_config" --without-libcurl --without-lz4 --without-zstd
37+
38+
chown -R postgres:postgres /citus
39+
40+
echo "Running make check-multi ..."
41+
42+
if ! su - postgres -c "make check-multi -C /citus/src/test/regress"; then
43+
echo "make check-multi failed. Printing regression.diffs ..."
44+
cat /citus/src/test/regress/regression.diffs
45+
exit 1
46+
fi
47+
48+
echo "make check-multi completed successfully."

test_package_installation/setup_cluster_and_test.sh renamed to test_package_installation/common/test_basics.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,30 @@
33
# Sets up a multi-node Citus cluster, creates a distributed table,
44
# rebalances shards, and verifies even distribution.
55
#
6-
# Called by test_deb.sh and test_rpm.sh after package installation.
7-
#
86
# Note: need to run this as root
97
#
10-
# Usage: setup_cluster_and_test.sh <pg_binary_path>
11-
# Example: setup_cluster_and_test.sh /usr/lib/postgresql/17/bin
8+
# Usage: test_basics.sh <pg_major_version> <citus_full_version> <pg_binary_path>
9+
# Example: test_basics.sh 18 14.0.0 /usr/lib/postgresql/17/bin
1210

1311
set -euo pipefail
1412

15-
if [ -z "$1" ]; then
13+
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
1614
echo "Error: some arguments are missing." >&2
17-
echo "Usage: $0 <pg_binary_path>" >&2
15+
echo "Usage: $0 <pg_major_version> <citus_full_version> <pg_binary_path>" >&2
1816
exit 1
1917
fi
2018

21-
PG_BIN="$1"
19+
PG_MAJOR_VERSION="$1"
20+
CITUS_FULL_VERSION="$2"
21+
PG_BIN="$3"
2222

2323
## constants and helpers
2424

2525
NODE_COUNT=3
2626
SHARDS_PER_NODE=5
2727
FIRST_NODE_PORT=9700
2828

29-
run_psql_cmd()
30-
{
29+
run_psql_cmd() {
3130
if [ -z "$1" ] || [ -z "$2" ]; then
3231
echo "Error: some arguments are missing." >&2
3332
echo "Usage: run_psql_cmd <port_number> <sql_command>" >&2
@@ -62,6 +61,26 @@ for i in $(seq 0 $((NODE_COUNT - 1))); do
6261
run_psql_cmd "$port_number" "CREATE EXTENSION citus;"
6362
done
6463

64+
## verify PG version
65+
66+
pg_version=$(run_psql_cmd "$FIRST_NODE_PORT" "SELECT version();")
67+
if [[ "$pg_version" != "PostgreSQL ${PG_MAJOR_VERSION}."* ]]; then
68+
echo "Error: PostgreSQL version verification failed. Expected version to start with 'PostgreSQL ${PG_MAJOR_VERSION}.', got: $pg_version" >&2
69+
exit 1
70+
else
71+
echo "Verified PostgreSQL version: $pg_version"
72+
fi
73+
74+
## verify Citus extension version
75+
76+
citus_version=$(run_psql_cmd "$FIRST_NODE_PORT" "SHOW citus.version;")
77+
if [[ "$citus_version" != "${CITUS_FULL_VERSION}"* ]]; then
78+
echo "Error: Citus version verification failed. Expected version to start with '${CITUS_FULL_VERSION}', got: $citus_version" >&2
79+
exit 1
80+
else
81+
echo "Verified Citus version: $citus_version"
82+
fi
83+
6584
## create a distributed table
6685

6786
echo "Creating a distributed table ..."

test_package_installation/test_deb.sh renamed to test_package_installation/deb/install_package.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,28 @@
55
#
66
# Note: need to run this as root
77
#
8-
# Usage: test_deb.sh <pg_major_version> <citus_major_minor_version>
9-
# Example: test_deb.sh 17 14.0
8+
# Usage: install_package.sh <pg_major_version> <citus_full_version>
9+
# Example: install_package.sh 18 14.0.0
1010

1111
set -euo pipefail
1212

1313
if [ -z "$1" ] || [ -z "$2" ]; then
1414
echo "Error: some arguments are missing." >&2
15-
echo "Usage: $0 <pg_major_version> <citus_major_minor_version>" >&2
15+
echo "Usage: $0 <pg_major_version> <citus_full_version>" >&2
1616
exit 1
1717
fi
1818

1919
PG_MAJOR_VERSION="$1"
20-
CITUS_MAJOR_MINOR_VERSION="$2"
20+
CITUS_FULL_VERSION="$2"
2121

2222
export DEBIAN_FRONTEND=noninteractive
2323

24+
apt-get -y update
25+
2426
## install postgres
2527

2628
echo "Installing PostgreSQL ..."
2729

28-
apt-get -y update
2930
apt-get -y install curl ca-certificates
3031

3132
install -d /usr/share/postgresql-common/pgdg
@@ -42,8 +43,8 @@ echo "Installing Citus ..."
4243

4344
curl --fail https://install.citusdata.com/community/deb.sh > add-citus-repo.sh
4445
bash add-citus-repo.sh
45-
apt-get -y install postgresql-${PG_MAJOR_VERSION}-citus-${CITUS_MAJOR_MINOR_VERSION}
4646

47-
## setup a citus cluster and run verification tests
47+
citus_major_minor_version="${CITUS_FULL_VERSION%.*}"
48+
apt-get -y install postgresql-${PG_MAJOR_VERSION}-citus-${citus_major_minor_version}=${CITUS_FULL_VERSION}.citus-1
4849

49-
/setup_cluster_and_test.sh "/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin"
50+
echo "PostgreSQL and Citus packages installed successfully."
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Installs dependencies needed to run Citus regression tests.
4+
#
5+
# Note: need to run this as root
6+
#
7+
# Usage: install_regression_test_deps.sh <pg_major_version> <citus_full_version>
8+
# Example: install_regression_test_deps.sh 18 14.0.0
9+
10+
set -euo pipefail
11+
12+
if [ -z "$1" ] || [ -z "$2" ]; then
13+
echo "Error: some arguments are missing." >&2
14+
echo "Usage: $0 <pg_major_version> <citus_full_version>" >&2
15+
exit 1
16+
fi
17+
18+
PG_MAJOR_VERSION="$1"
19+
CITUS_FULL_VERSION="$2"
20+
21+
export DEBIAN_FRONTEND=noninteractive
22+
23+
apt-get -y update
24+
25+
## install pg_regress
26+
27+
echo "Installing pg_regress via postgresql-server-dev-${PG_MAJOR_VERSION} ..."
28+
29+
apt-get -y install postgresql-server-dev-${PG_MAJOR_VERSION}
30+
31+
## clone citus repository
32+
33+
echo "Cloning Citus repository (tag v${CITUS_FULL_VERSION}) ..."
34+
35+
CITUS_TAG="v${CITUS_FULL_VERSION}"
36+
CITUS_REPO_DIR="/citus"
37+
38+
apt-get -y install git build-essential
39+
git clone --depth 1 --branch "$CITUS_TAG" https://github.com/citusdata/citus "$CITUS_REPO_DIR"
40+
41+
echo "Regression test dependencies installed successfully."
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Installs PostgreSQL and Citus packages on EL/OL (RPM-based distros), then
4+
# runs the cluster setup and verification test.
5+
#
6+
# Note: need to run this as root
7+
#
8+
# Usage: install_package.sh <pg_major_version> <citus_full_version> <os_version>
9+
# Example: install_package.sh 18 14.0.0 8
10+
11+
set -euo pipefail
12+
13+
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
14+
echo "Error: some arguments are missing." >&2
15+
echo "Usage: $0 <pg_major_version> <citus_full_version> <os_version>" >&2
16+
exit 1
17+
fi
18+
19+
PG_MAJOR_VERSION="$1"
20+
CITUS_FULL_VERSION="$2"
21+
OS_VERSION="$3"
22+
23+
yum -y update
24+
25+
## install postgres
26+
27+
echo "Installing PostgreSQL ..."
28+
29+
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-${OS_VERSION}-x86_64/pgdg-redhat-repo-latest.noarch.rpm
30+
31+
# disable the built-in PostgreSQL module
32+
yum -qy module disable postgresql
33+
34+
yum install -y postgresql${PG_MAJOR_VERSION}-server
35+
36+
## install citus
37+
38+
echo "Installing Citus ..."
39+
40+
curl --fail https://install.citusdata.com/community/rpm.sh > add-citus-repo.sh
41+
bash add-citus-repo.sh
42+
43+
citus_major_minor_version="${CITUS_FULL_VERSION%.*}"
44+
citus_major_minor_version_without_dot="${citus_major_minor_version//./}"
45+
46+
# TODO: use --nogpgcheck for now
47+
yum install -y --nogpgcheck citus${citus_major_minor_version_without_dot}_${PG_MAJOR_VERSION}-${CITUS_FULL_VERSION}.citus-1.el${OS_VERSION}
48+
49+
echo "PostgreSQL and Citus packages installed successfully."

0 commit comments

Comments
 (0)