From 1b515b961efffb00d293006bbdf6f5d735579759 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 15 Jul 2025 03:47:14 +0000 Subject: [PATCH 1/9] Add GitHub Actions workflow for testing PostgreSQL versions 13-17 and beta Co-authored-by: nik --- .github/workflows/test.yml | 156 +++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f69e4f6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,156 @@ +name: Test PostgreSQL Versions + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + postgres-version: ['13', '14', '15', '16', '17'] + fail-fast: false + + services: + postgres: + image: postgres:${{ matrix.postgres-version }} + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install PostgreSQL client + run: | + sudo apt-get update + sudo apt-get install -y postgresql-client-${{ matrix.postgres-version }} + + - name: Prepare test database + run: | + export PGPASSWORD=postgres + psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' + psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' + psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" + psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" + env: + PGPASSWORD: postgres + + - name: Test wide mode + run: | + export PGPASSWORD=postgres + echo "\set postgres_dba_wide true" > ~/.psqlrc + echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + for f in sql/*; do + echo "Testing $f in wide mode..." + psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + done + env: + PGPASSWORD: postgres + + - name: Test normal mode + run: | + export PGPASSWORD=postgres + echo "\set postgres_dba_wide false" > ~/.psqlrc + echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + for f in sql/*; do + echo "Testing $f in normal mode..." + psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + done + env: + PGPASSWORD: postgres + + - name: Run regression tests + run: | + export PGPASSWORD=postgres + echo "\set postgres_dba_wide false" > ~/.psqlrc + echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + + echo "Running regression test for 0_node.sql..." + diff -b test/regression/0_node.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/0_node.sql | grep Role) + + echo "Running regression test for p1_alignment_padding.sql..." + diff -b test/regression/p1_alignment_padding.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) + + echo "Running regression test for a1_activity.sql..." + diff -b test/regression/a1_activity.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/a1_activity.sql | grep User) + env: + PGPASSWORD: postgres + + test-beta: + runs-on: ubuntu-latest + continue-on-error: true # Allow beta tests to fail without breaking CI + + strategy: + matrix: + postgres-version: ['18-beta'] + + services: + postgres: + image: postgres:${{ matrix.postgres-version }} + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install PostgreSQL client (beta) + run: | + sudo apt-get update + # Install latest PostgreSQL client for beta testing + sudo apt-get install -y postgresql-client + + - name: Prepare test database + run: | + export PGPASSWORD=postgres + psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' + psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' + psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" + psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" + env: + PGPASSWORD: postgres + + - name: Test wide mode (beta) + run: | + export PGPASSWORD=postgres + echo "\set postgres_dba_wide true" > ~/.psqlrc + echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + for f in sql/*; do + echo "Testing $f in wide mode (PostgreSQL 18 beta)..." + psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + done + env: + PGPASSWORD: postgres + + - name: Test normal mode (beta) + run: | + export PGPASSWORD=postgres + echo "\set postgres_dba_wide false" > ~/.psqlrc + echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + for f in sql/*; do + echo "Testing $f in normal mode (PostgreSQL 18 beta)..." + psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + done + env: + PGPASSWORD: postgres \ No newline at end of file From e3be4b27c21c8087d2f9dfdc38e4c9c75a0d4233 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 15 Jul 2025 03:50:20 +0000 Subject: [PATCH 2/9] Improve GitHub Actions workflow for PostgreSQL testing Co-authored-by: nik --- .github/workflows/test.yml | 77 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f69e4f6..501d71a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,7 @@ jobs: env: POSTGRES_PASSWORD: postgres POSTGRES_DB: test + POSTGRES_USER: postgres options: >- --health-cmd pg_isready --health-interval 10s @@ -36,58 +37,56 @@ jobs: - name: Install PostgreSQL client run: | sudo apt-get update - sudo apt-get install -y postgresql-client-${{ matrix.postgres-version }} + sudo apt-get install -y postgresql-client + + - name: Wait for PostgreSQL to be ready + run: | + until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for postgres..." + sleep 2 + done - name: Prepare test database run: | - export PGPASSWORD=postgres - psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' - psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' - psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" - psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" - env: - PGPASSWORD: postgres + # Create extensions (they need to be created by superuser) + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' + + # Create test tables + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" - name: Test wide mode run: | - export PGPASSWORD=postgres echo "\set postgres_dba_wide true" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc for f in sql/*; do echo "Testing $f in wide mode..." - psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null done - env: - PGPASSWORD: postgres - name: Test normal mode run: | - export PGPASSWORD=postgres echo "\set postgres_dba_wide false" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc for f in sql/*; do echo "Testing $f in normal mode..." - psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null done - env: - PGPASSWORD: postgres - name: Run regression tests run: | - export PGPASSWORD=postgres echo "\set postgres_dba_wide false" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc echo "Running regression test for 0_node.sql..." - diff -b test/regression/0_node.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/0_node.sql | grep Role) + diff -b test/regression/0_node.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/0_node.sql | grep Role) echo "Running regression test for p1_alignment_padding.sql..." - diff -b test/regression/p1_alignment_padding.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) + diff -b test/regression/p1_alignment_padding.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) echo "Running regression test for a1_activity.sql..." - diff -b test/regression/a1_activity.out <(psql -h localhost -U postgres -d test -f warmup.psql -f sql/a1_activity.sql | grep User) - env: - PGPASSWORD: postgres + diff -b test/regression/a1_activity.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/a1_activity.sql | grep User) test-beta: runs-on: ubuntu-latest @@ -103,6 +102,7 @@ jobs: env: POSTGRES_PASSWORD: postgres POSTGRES_DB: test + POSTGRES_USER: postgres options: >- --health-cmd pg_isready --health-interval 10s @@ -121,36 +121,37 @@ jobs: # Install latest PostgreSQL client for beta testing sudo apt-get install -y postgresql-client + - name: Wait for PostgreSQL to be ready + run: | + until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for postgres..." + sleep 2 + done + - name: Prepare test database run: | - export PGPASSWORD=postgres - psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' - psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' - psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" - psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" - env: - PGPASSWORD: postgres + # Create extensions (they need to be created by superuser) + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' + + # Create test tables + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" - name: Test wide mode (beta) run: | - export PGPASSWORD=postgres echo "\set postgres_dba_wide true" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc for f in sql/*; do echo "Testing $f in wide mode (PostgreSQL 18 beta)..." - psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null done - env: - PGPASSWORD: postgres - name: Test normal mode (beta) run: | - export PGPASSWORD=postgres echo "\set postgres_dba_wide false" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc for f in sql/*; do echo "Testing $f in normal mode (PostgreSQL 18 beta)..." - psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null - done - env: - PGPASSWORD: postgres \ No newline at end of file + PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + done \ No newline at end of file From b57de9f64168c463e9d5ea852919422d09131839 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 15 Jul 2025 03:55:04 +0000 Subject: [PATCH 3/9] Simplify GitHub Actions workflow for PostgreSQL testing Co-authored-by: nik --- .github/workflows/test.yml | 121 ++++++------------------------------- 1 file changed, 19 insertions(+), 102 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 501d71a..b41dc7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,49 +12,33 @@ jobs: strategy: matrix: - postgres-version: ['13', '14', '15', '16', '17'] + test-name: ['postgres-dba-tests'] fail-fast: false - services: - postgres: - image: postgres:${{ matrix.postgres-version }} - env: - POSTGRES_PASSWORD: postgres - POSTGRES_DB: test - POSTGRES_USER: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - steps: - name: Checkout code uses: actions/checkout@v4 - - name: Install PostgreSQL client - run: | - sudo apt-get update - sudo apt-get install -y postgresql-client - - - name: Wait for PostgreSQL to be ready + - name: Start PostgreSQL and configure run: | - until pg_isready -h localhost -p 5432 -U postgres; do - echo "Waiting for postgres..." - sleep 2 - done + # Configure PostgreSQL for pg_stat_statements + sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf + sudo systemctl start postgresql.service + pg_isready + + # Create runner user and test database + sudo -u postgres createuser -s runner + sudo -u postgres createdb test - name: Prepare test database run: | # Create extensions (they need to be created by superuser) - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' + sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' + sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' # Create test tables - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" + psql -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" + psql -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" - name: Test wide mode run: | @@ -62,7 +46,7 @@ jobs: echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc for f in sql/*; do echo "Testing $f in wide mode..." - PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + psql -d test -f warmup.psql -f "$f" > /dev/null done - name: Test normal mode @@ -71,7 +55,7 @@ jobs: echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc for f in sql/*; do echo "Testing $f in normal mode..." - PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null + psql -d test -f warmup.psql -f "$f" > /dev/null done - name: Run regression tests @@ -80,78 +64,11 @@ jobs: echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc echo "Running regression test for 0_node.sql..." - diff -b test/regression/0_node.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/0_node.sql | grep Role) + diff -b test/regression/0_node.out <(psql -d test -f warmup.psql -f sql/0_node.sql | grep Role) echo "Running regression test for p1_alignment_padding.sql..." - diff -b test/regression/p1_alignment_padding.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) + diff -b test/regression/p1_alignment_padding.out <(psql -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) echo "Running regression test for a1_activity.sql..." - diff -b test/regression/a1_activity.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/a1_activity.sql | grep User) + diff -b test/regression/a1_activity.out <(psql -d test -f warmup.psql -f sql/a1_activity.sql | grep User) - test-beta: - runs-on: ubuntu-latest - continue-on-error: true # Allow beta tests to fail without breaking CI - - strategy: - matrix: - postgres-version: ['18-beta'] - - services: - postgres: - image: postgres:${{ matrix.postgres-version }} - env: - POSTGRES_PASSWORD: postgres - POSTGRES_DB: test - POSTGRES_USER: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install PostgreSQL client (beta) - run: | - sudo apt-get update - # Install latest PostgreSQL client for beta testing - sudo apt-get install -y postgresql-client - - - name: Wait for PostgreSQL to be ready - run: | - until pg_isready -h localhost -p 5432 -U postgres; do - echo "Waiting for postgres..." - sleep 2 - done - - - name: Prepare test database - run: | - # Create extensions (they need to be created by superuser) - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' - - # Create test tables - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" - - - name: Test wide mode (beta) - run: | - echo "\set postgres_dba_wide true" > ~/.psqlrc - echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc - for f in sql/*; do - echo "Testing $f in wide mode (PostgreSQL 18 beta)..." - PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null - done - - - name: Test normal mode (beta) - run: | - echo "\set postgres_dba_wide false" > ~/.psqlrc - echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc - for f in sql/*; do - echo "Testing $f in normal mode (PostgreSQL 18 beta)..." - PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null - done \ No newline at end of file From d1890920d272879c8decdcd4d587f97e2a499ebe Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 15 Jul 2025 03:56:48 +0000 Subject: [PATCH 4/9] Improve PostgreSQL configuration and error handling in CI workflow Co-authored-by: nik --- .github/workflows/test.yml | 42 ++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b41dc7c..5e10255 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,8 +21,27 @@ jobs: - name: Start PostgreSQL and configure run: | - # Configure PostgreSQL for pg_stat_statements - sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf + # Stop default PostgreSQL if running + sudo systemctl stop postgresql.service || true + + # Find PostgreSQL config files + echo "PostgreSQL config files:" + find /etc/postgresql -name "postgresql.conf" -type f + find /etc/postgresql -name "pg_hba.conf" -type f + + # Configure PostgreSQL for pg_stat_statements (multiple approaches to ensure it works) + sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf || true + sudo sed -i "s/^#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf || true + sudo bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /etc/postgresql/*/main/postgresql.conf" + + # Show the final configuration + echo "Final postgresql.conf shared_preload_libraries setting:" + grep -n "shared_preload_libraries" /etc/postgresql/*/main/postgresql.conf || echo "Not found" + + # Set trust authentication for local connections + sudo bash -c "echo 'local all all trust' > /etc/postgresql/*/main/pg_hba.conf" + + # Start PostgreSQL sudo systemctl start postgresql.service pg_isready @@ -32,10 +51,17 @@ jobs: - name: Prepare test database run: | + # Check PostgreSQL version and available extensions + sudo -u postgres psql -d test -c 'SELECT version();' + sudo -u postgres psql -d test -c 'SELECT * FROM pg_available_extensions WHERE name IN ('"'"'pg_stat_statements'"'"', '"'"'pgstattuple'"'"');' + # Create extensions (they need to be created by superuser) sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' + # Verify extensions are created + sudo -u postgres psql -d test -c 'SELECT * FROM pg_extension;' + # Create test tables psql -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" psql -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" @@ -46,7 +72,11 @@ jobs: echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc for f in sql/*; do echo "Testing $f in wide mode..." - psql -d test -f warmup.psql -f "$f" > /dev/null + if ! psql -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then + echo "FAILED: $f in wide mode" + psql -d test -f warmup.psql -f "$f" + exit 1 + fi done - name: Test normal mode @@ -55,7 +85,11 @@ jobs: echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc for f in sql/*; do echo "Testing $f in normal mode..." - psql -d test -f warmup.psql -f "$f" > /dev/null + if ! psql -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then + echo "FAILED: $f in normal mode" + psql -d test -f warmup.psql -f "$f" + exit 1 + fi done - name: Run regression tests From ab11877a65b4bde752b20f3194cd0c88155c653d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 15 Jul 2025 04:00:48 +0000 Subject: [PATCH 5/9] Update CI to test multiple PostgreSQL versions with improved configuration Co-authored-by: nik --- .github/workflows/test.yml | 219 +++++++++++++++++++++++++++++-------- 1 file changed, 171 insertions(+), 48 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e10255..6d3222d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,97 +12,220 @@ jobs: strategy: matrix: - test-name: ['postgres-dba-tests'] + postgres-version: ['13', '14', '15', '16', '17'] fail-fast: false + services: + postgres: + image: postgres:${{ matrix.postgres-version }} + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: - name: Checkout code uses: actions/checkout@v4 - - name: Start PostgreSQL and configure + - name: Install PostgreSQL client + run: | + sudo apt-get update + sudo apt-get install -y postgresql-client + + - name: Configure PostgreSQL for pg_stat_statements run: | - # Stop default PostgreSQL if running - sudo systemctl stop postgresql.service || true + # Wait for PostgreSQL to be ready + until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for postgres..." + sleep 2 + done - # Find PostgreSQL config files - echo "PostgreSQL config files:" - find /etc/postgresql -name "postgresql.conf" -type f - find /etc/postgresql -name "pg_hba.conf" -type f + # Get container ID and configure shared_preload_libraries + CONTAINER_ID=$(docker ps --filter "expose=5432" --format "{{.ID}}") + echo "PostgreSQL container: $CONTAINER_ID" - # Configure PostgreSQL for pg_stat_statements (multiple approaches to ensure it works) - sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf || true - sudo sed -i "s/^#shared_preload_libraries = ''/shared_preload_libraries = 'pg_stat_statements'/" /etc/postgresql/*/main/postgresql.conf || true - sudo bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /etc/postgresql/*/main/postgresql.conf" + # Configure shared_preload_libraries in postgresql.conf + docker exec $CONTAINER_ID bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /var/lib/postgresql/data/postgresql.conf" - # Show the final configuration - echo "Final postgresql.conf shared_preload_libraries setting:" - grep -n "shared_preload_libraries" /etc/postgresql/*/main/postgresql.conf || echo "Not found" + # Configure pg_hba.conf for trust authentication + docker exec $CONTAINER_ID bash -c "echo 'local all all trust' > /var/lib/postgresql/data/pg_hba.conf" - # Set trust authentication for local connections - sudo bash -c "echo 'local all all trust' > /etc/postgresql/*/main/pg_hba.conf" + # Restart PostgreSQL to load the configuration + docker restart $CONTAINER_ID - # Start PostgreSQL - sudo systemctl start postgresql.service - pg_isready + # Wait for PostgreSQL to be ready after restart + until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for postgres to restart..." + sleep 2 + done - # Create runner user and test database - sudo -u postgres createuser -s runner - sudo -u postgres createdb test + echo "PostgreSQL ${{ matrix.postgres-version }} configured successfully" - name: Prepare test database run: | - # Check PostgreSQL version and available extensions - sudo -u postgres psql -d test -c 'SELECT version();' - sudo -u postgres psql -d test -c 'SELECT * FROM pg_available_extensions WHERE name IN ('"'"'pg_stat_statements'"'"', '"'"'pgstattuple'"'"');' + # Check PostgreSQL version + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT version();' - # Create extensions (they need to be created by superuser) - sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' - sudo -u postgres psql -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' + # Create extensions + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' - # Verify extensions are created - sudo -u postgres psql -d test -c 'SELECT * FROM pg_extension;' + # Verify extensions + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension;' - # Create test tables - psql -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" - psql -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" + # Create test tables (exactly as in CircleCI) + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" - name: Test wide mode run: | echo "\set postgres_dba_wide true" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + echo "Testing all SQL files in wide mode..." for f in sql/*; do - echo "Testing $f in wide mode..." - if ! psql -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then - echo "FAILED: $f in wide mode" - psql -d test -f warmup.psql -f "$f" + echo " Testing $f..." + if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then + echo "❌ FAILED: $f in wide mode" + echo "Error output:" + PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" exit 1 fi done + echo "✅ All tests passed in wide mode" - name: Test normal mode run: | echo "\set postgres_dba_wide false" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + echo "Testing all SQL files in normal mode..." for f in sql/*; do - echo "Testing $f in normal mode..." - if ! psql -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then - echo "FAILED: $f in normal mode" - psql -d test -f warmup.psql -f "$f" + echo " Testing $f..." + if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then + echo "❌ FAILED: $f in normal mode" + echo "Error output:" + PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" exit 1 fi done + echo "✅ All tests passed in normal mode" - name: Run regression tests run: | echo "\set postgres_dba_wide false" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc - echo "Running regression test for 0_node.sql..." - diff -b test/regression/0_node.out <(psql -d test -f warmup.psql -f sql/0_node.sql | grep Role) + echo "Running regression tests..." + + echo " Testing 0_node.sql..." + diff -b test/regression/0_node.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/0_node.sql | grep Role) - echo "Running regression test for p1_alignment_padding.sql..." - diff -b test/regression/p1_alignment_padding.out <(psql -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) + echo " Testing p1_alignment_padding.sql..." + diff -b test/regression/p1_alignment_padding.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) + + echo " Testing a1_activity.sql..." + diff -b test/regression/a1_activity.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/a1_activity.sql | grep User) + + echo "✅ All regression tests passed" + + test-beta: + runs-on: ubuntu-latest + continue-on-error: true # Allow beta tests to fail without breaking CI + + strategy: + matrix: + postgres-version: ['18-beta'] + fail-fast: false + + services: + postgres: + image: postgres:${{ matrix.postgres-version }} + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install PostgreSQL client + run: | + sudo apt-get update + sudo apt-get install -y postgresql-client + + - name: Configure PostgreSQL for pg_stat_statements + run: | + # Wait for PostgreSQL to be ready + until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for postgres..." + sleep 2 + done - echo "Running regression test for a1_activity.sql..." - diff -b test/regression/a1_activity.out <(psql -d test -f warmup.psql -f sql/a1_activity.sql | grep User) + # Get container ID and configure shared_preload_libraries + CONTAINER_ID=$(docker ps --filter "expose=5432" --format "{{.ID}}") + echo "PostgreSQL container: $CONTAINER_ID" + + # Configure shared_preload_libraries in postgresql.conf + docker exec $CONTAINER_ID bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /var/lib/postgresql/data/postgresql.conf" + + # Configure pg_hba.conf for trust authentication + docker exec $CONTAINER_ID bash -c "echo 'local all all trust' > /var/lib/postgresql/data/pg_hba.conf" + + # Restart PostgreSQL to load the configuration + docker restart $CONTAINER_ID + + # Wait for PostgreSQL to be ready after restart + until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for postgres to restart..." + sleep 2 + done + + echo "PostgreSQL ${{ matrix.postgres-version }} configured successfully" + + - name: Prepare test database + run: | + # Check PostgreSQL version + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT version();' + + # Create extensions + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' + + # Create test tables + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);" + + - name: Test wide mode (beta) + run: | + echo "\set postgres_dba_wide true" > ~/.psqlrc + echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + echo "Testing all SQL files in wide mode (PostgreSQL 18 beta)..." + for f in sql/*; do + echo " Testing $f..." + PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in wide mode (beta)" + done + echo "✅ Wide mode tests completed (beta)" + + - name: Test normal mode (beta) + run: | + echo "\set postgres_dba_wide false" > ~/.psqlrc + echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc + echo "Testing all SQL files in normal mode (PostgreSQL 18 beta)..." + for f in sql/*; do + echo " Testing $f..." + PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in normal mode (beta)" + done + echo "✅ Normal mode tests completed (beta)" From be6de7846e845977905ad834786fab54ce9ad7b7 Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Mon, 14 Jul 2025 21:08:12 -0700 Subject: [PATCH 6/9] Update GitHub Actions to test PostgreSQL 13-17 and remove CircleCI - Update test matrix to include PostgreSQL 13-17 (supported versions) - Add beta testing for PostgreSQL 18-beta and 19-beta - Remove CircleCI configuration after migrating all functionality - All regression tests preserved from CircleCI implementation --- .circleci/config.yml | 77 -------------------------------------- .github/workflows/test.yml | 2 +- 2 files changed, 1 insertion(+), 78 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b55ccb3..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,77 +0,0 @@ -version: 2 - -workflows: - version: 2 - test: - jobs: - - test-10 - - test-11 - - test-12 - - test-13 - - test-14 - -jobs: - test-10: &test-template - working_directory: ~/postgres_dba - docker: - - image: postgres:10 - environment: - - POSTGRES_VERSION: 10 - steps: - - run: - name: Install Git - command: apt update && apt install -y git - - checkout - - run: - name: Init Postgres cluster - command: | - pg_createcluster $POSTGRES_VERSION main - echo 'local all all trust' > /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf - echo "shared_preload_libraries='pg_stat_statements'" >> /etc/postgresql/$POSTGRES_VERSION/main/postgresql.conf - pg_ctlcluster $POSTGRES_VERSION main start - - run: - name: Prepare DB - command: | - psql -U postgres -c 'create database test' - psql -U postgres test -c 'create extension pg_stat_statements' - psql -U postgres test -c 'create extension pgstattuple' - psql -U postgres test -c "create table align1 as select 1::int4, 2::int8, 3::int4 as more from generate_series(1, 100000) _(i);" - psql -U postgres test -c "create table align2 as select 1::int4, 3::int4 as more, 2::int8 from generate_series(1, 100000) _(i);" - - run: - name: Tests - command: | - echo "\set postgres_dba_wide true" > ~/.psqlrc - echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc - for f in ~/postgres_dba/sql/*; do psql -U postgres test -f ~/postgres_dba/warmup.psql -f "$f">/dev/null; done - echo "\set postgres_dba_wide false" > ~/.psqlrc - echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc - for f in ~/postgres_dba/sql/*; do psql -U postgres test -f ~/postgres_dba/warmup.psql -f "$f">/dev/null; done - diff -b test/regression/0_node.out <(psql -U postgres test -f warmup.psql -f ~/postgres_dba/sql/0_node.sql | grep Role) - diff -b test/regression/p1_alignment_padding.out <(psql -U postgres test -f warmup.psql -f ~/postgres_dba/sql/p1_alignment_padding.sql | grep align) - diff -b test/regression/a1_activity.out <(psql -U postgres test -f warmup.psql -f ~/postgres_dba/sql/a1_activity.sql | grep User) - test-11: - <<: *test-template - docker: - - image: postgres:11 - environment: - - POSTGRES_VERSION: 11 - test-12: - <<: *test-template - docker: - - image: postgres:12 - environment: - - POSTGRES_VERSION: 12 - - test-13: - <<: *test-template - docker: - - image: postgres:13 - environment: - - POSTGRES_VERSION: 13 - - test-14: - <<: *test-template - docker: - - image: postgres:14 - environment: - - POSTGRES_VERSION: 14 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d3222d..b11d5f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -139,7 +139,7 @@ jobs: strategy: matrix: - postgres-version: ['18-beta'] + postgres-version: ['18-beta', '19-beta'] fail-fast: false services: From 37070d9e897acf138841ecde51c5171b8bf0ca44 Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Mon, 14 Jul 2025 21:18:29 -0700 Subject: [PATCH 7/9] Fix GitHub Actions PostgreSQL configuration and test execution - Replace docker restart with proper pg_ctl stop/start for reliability - Add comprehensive pg_hba.conf configuration (host + local trust) - Add --no-psqlrc flag to prevent psqlrc interference - Improve timing and synchronization with sleep buffer - Add better error handling with || true for stop command - Apply consistent approach to both regular and beta tests --- .github/workflows/test.yml | 58 ++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b11d5f6..f1ca889 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,20 +46,25 @@ jobs: sleep 2 done - # Get container ID and configure shared_preload_libraries + # Get container ID CONTAINER_ID=$(docker ps --filter "expose=5432" --format "{{.ID}}") echo "PostgreSQL container: $CONTAINER_ID" - # Configure shared_preload_libraries in postgresql.conf + # Stop PostgreSQL to modify configuration + docker exec $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -m fast stop || true + + # Configure shared_preload_libraries docker exec $CONTAINER_ID bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /var/lib/postgresql/data/postgresql.conf" - # Configure pg_hba.conf for trust authentication - docker exec $CONTAINER_ID bash -c "echo 'local all all trust' > /var/lib/postgresql/data/pg_hba.conf" + # Configure trust authentication for easier testing + docker exec $CONTAINER_ID bash -c "echo 'host all all all trust' > /var/lib/postgresql/data/pg_hba.conf" + docker exec $CONTAINER_ID bash -c "echo 'local all all trust' >> /var/lib/postgresql/data/pg_hba.conf" - # Restart PostgreSQL to load the configuration - docker restart $CONTAINER_ID + # Restart PostgreSQL + docker exec $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -l /var/lib/postgresql/data/logfile start # Wait for PostgreSQL to be ready after restart + sleep 5 until pg_isready -h localhost -p 5432 -U postgres; do echo "Waiting for postgres to restart..." sleep 2 @@ -77,7 +82,7 @@ jobs: PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;' # Verify extensions - PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension;' + PGPASSWORD=postgres psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension ORDER BY extname;' # Create test tables (exactly as in CircleCI) PGPASSWORD=postgres psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);" @@ -90,10 +95,10 @@ jobs: echo "Testing all SQL files in wide mode..." for f in sql/*; do echo " Testing $f..." - if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then + if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then echo "❌ FAILED: $f in wide mode" echo "Error output:" - PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" + PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" exit 1 fi done @@ -106,10 +111,10 @@ jobs: echo "Testing all SQL files in normal mode..." for f in sql/*; do echo " Testing $f..." - if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1; then + if ! PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then echo "❌ FAILED: $f in normal mode" echo "Error output:" - PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" + PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" exit 1 fi done @@ -123,13 +128,13 @@ jobs: echo "Running regression tests..." echo " Testing 0_node.sql..." - diff -b test/regression/0_node.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/0_node.sql | grep Role) + diff -b test/regression/0_node.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/0_node.sql | grep Role) echo " Testing p1_alignment_padding.sql..." - diff -b test/regression/p1_alignment_padding.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) + diff -b test/regression/p1_alignment_padding.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/p1_alignment_padding.sql | grep align) echo " Testing a1_activity.sql..." - diff -b test/regression/a1_activity.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f sql/a1_activity.sql | grep User) + diff -b test/regression/a1_activity.out <(PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f sql/a1_activity.sql | grep User) echo "✅ All regression tests passed" @@ -173,20 +178,25 @@ jobs: sleep 2 done - # Get container ID and configure shared_preload_libraries + # Get container ID CONTAINER_ID=$(docker ps --filter "expose=5432" --format "{{.ID}}") echo "PostgreSQL container: $CONTAINER_ID" - # Configure shared_preload_libraries in postgresql.conf + # Stop PostgreSQL to modify configuration + docker exec $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -m fast stop || true + + # Configure shared_preload_libraries docker exec $CONTAINER_ID bash -c "echo \"shared_preload_libraries = 'pg_stat_statements'\" >> /var/lib/postgresql/data/postgresql.conf" - # Configure pg_hba.conf for trust authentication - docker exec $CONTAINER_ID bash -c "echo 'local all all trust' > /var/lib/postgresql/data/pg_hba.conf" + # Configure trust authentication + docker exec $CONTAINER_ID bash -c "echo 'host all all all trust' > /var/lib/postgresql/data/pg_hba.conf" + docker exec $CONTAINER_ID bash -c "echo 'local all all trust' >> /var/lib/postgresql/data/pg_hba.conf" - # Restart PostgreSQL to load the configuration - docker restart $CONTAINER_ID + # Restart PostgreSQL + docker exec $CONTAINER_ID pg_ctl -D /var/lib/postgresql/data -l /var/lib/postgresql/data/logfile start # Wait for PostgreSQL to be ready after restart + sleep 5 until pg_isready -h localhost -p 5432 -U postgres; do echo "Waiting for postgres to restart..." sleep 2 @@ -211,10 +221,10 @@ jobs: run: | echo "\set postgres_dba_wide true" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc - echo "Testing all SQL files in wide mode (PostgreSQL 18 beta)..." + echo "Testing all SQL files in wide mode (PostgreSQL ${{ matrix.postgres-version }})..." for f in sql/*; do echo " Testing $f..." - PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in wide mode (beta)" + PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in wide mode (beta)" done echo "✅ Wide mode tests completed (beta)" @@ -222,10 +232,10 @@ jobs: run: | echo "\set postgres_dba_wide false" > ~/.psqlrc echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc - echo "Testing all SQL files in normal mode (PostgreSQL 18 beta)..." + echo "Testing all SQL files in normal mode (PostgreSQL ${{ matrix.postgres-version }})..." for f in sql/*; do echo " Testing $f..." - PGPASSWORD=postgres psql -h localhost -U postgres -d test -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in normal mode (beta)" + PGPASSWORD=postgres psql -h localhost -U postgres -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1 || echo " ⚠️ Warning: $f failed in normal mode (beta)" done echo "✅ Normal mode tests completed (beta)" From 704f6b4e73acc10c237cdb5cfb690410beea6a5e Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Mon, 14 Jul 2025 21:30:19 -0700 Subject: [PATCH 8/9] Fix PostgreSQL client installation for all versions - Add PostgreSQL official APT repository to support all versions - Install postgresql-client-common and postgresql-client packages - This resolves 'Unable to locate package postgresql-client-17' error - Applied to both main test and beta test jobs --- .github/workflows/test.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1ca889..3aa8095 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,8 +35,15 @@ jobs: - name: Install PostgreSQL client run: | + # Add PostgreSQL official APT repository sudo apt-get update - sudo apt-get install -y postgresql-client + sudo apt-get install -y wget ca-certificates + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list + sudo apt-get update + + # Install PostgreSQL client (will get the latest version available) + sudo apt-get install -y postgresql-client-common postgresql-client - name: Configure PostgreSQL for pg_stat_statements run: | @@ -167,8 +174,15 @@ jobs: - name: Install PostgreSQL client run: | + # Add PostgreSQL official APT repository sudo apt-get update - sudo apt-get install -y postgresql-client + sudo apt-get install -y wget ca-certificates + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list + sudo apt-get update + + # Install PostgreSQL client (will get the latest version available) + sudo apt-get install -y postgresql-client-common postgresql-client - name: Configure PostgreSQL for pg_stat_statements run: | From e81f250bf84765634b32190476e80f47c7182bab Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Mon, 14 Jul 2025 21:33:17 -0700 Subject: [PATCH 9/9] Simplify PostgreSQL client installation to fix version compatibility - Use postgresql-client-14 from Ubuntu repositories (stable and available) - Remove complex APT repository setup that was causing failures - PostgreSQL client 14 is compatible with all server versions (13-17 + beta) - Add psql --version verification step - Applied to both main test and beta test jobs --- .github/workflows/test.yml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3aa8095..be296e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,15 +35,12 @@ jobs: - name: Install PostgreSQL client run: | - # Add PostgreSQL official APT repository - sudo apt-get update - sudo apt-get install -y wget ca-certificates - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - - echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list + # Install PostgreSQL client from Ubuntu repositories (works with all PostgreSQL versions) sudo apt-get update + sudo apt-get install -y postgresql-client-common postgresql-client-14 - # Install PostgreSQL client (will get the latest version available) - sudo apt-get install -y postgresql-client-common postgresql-client + # Verify installation + psql --version - name: Configure PostgreSQL for pg_stat_statements run: | @@ -174,15 +171,12 @@ jobs: - name: Install PostgreSQL client run: | - # Add PostgreSQL official APT repository - sudo apt-get update - sudo apt-get install -y wget ca-certificates - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - - echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list + # Install PostgreSQL client from Ubuntu repositories (works with all PostgreSQL versions) sudo apt-get update + sudo apt-get install -y postgresql-client-common postgresql-client-14 - # Install PostgreSQL client (will get the latest version available) - sudo apt-get install -y postgresql-client-common postgresql-client + # Verify installation + psql --version - name: Configure PostgreSQL for pg_stat_statements run: |