Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions .github/workflows/installcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#
# Installcheck Tests Workflow
#
# This workflow runs installcheck tests on node n1 of a three-node Spock cluster.
# Environment variables are loaded from tests/docker/pgedge.env
#
# NOTES:
# The 'security_label' test has no chance to pass without extra coding. So, just
# skip it for now. This decision may be revised later if something is changed
# in the PostgreSQL core.
# The sad fact is that n2 and n3 can't pass these tests without errors, because
# the LR is limited and doesn't support many features. That turns their logs
# into a mess, but we still save them to detect any potential issues.
#

name: Installcheck Tests (Three-Node Cluster)
run-name: Running installcheck tests on three-node Spock cluster

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
installcheck:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
pgver: [15, 16, 17, 18]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout spock
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Add permissions
run: |
sudo chmod -R a+w ${GITHUB_WORKSPACE}

- name: Set up Docker
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3

- name: Set up docker compose
uses: docker/setup-compose-action@364cc21a5de5b1ee4a7f5f9d3fa374ce0ccde746 # v1
with:
version: latest

- name: Start docker cluster
run: |
cd ${GITHUB_WORKSPACE}/tests/docker/
# To minimize regression tests difference, override pgedge.env with
# standard PostgreSQL regression test defaults
sed -i 's/^DBUSER=.*/DBUSER=regression/' pgedge.env
sed -i 's/^DBNAME=.*/DBNAME=regression/' pgedge.env
# Build and start the cluster
PGVER=${{ matrix.pgver }} DBUSER=regression DBNAME=regression \
docker compose up --build --wait -d
timeout-minutes: 20

- name: Run installcheck on node n1
id: installcheck
run: |
cd ${GITHUB_WORKSPACE}/tests/docker/

# Run installcheck on n1 and capture output
docker compose exec -T pgedge-n1 bash -c '~/run-installcheck.sh' \
| tee installcheck_output.txt || true

# Analyze the output for test failures
echo "Analyzing test results..."

# Check for 'exited with exit code' which indicates a crash or abnormal termination
if grep -q "exited with exit code" installcheck_output.txt; then
echo "ERROR: Found 'exited with exit code' in output - indicates abnormal termination"
echo "test_result=failed" >> $GITHUB_OUTPUT
exit 0
fi

# Check for 'not ok' test results, excluding 'security_label'
# Extract all 'not ok' lines and filter out security_label
FAILED_TESTS=$(grep "not ok" installcheck_output.txt | grep -v "security_label" || true)

if [ -n "$FAILED_TESTS" ]; then
echo "ERROR: Found failing tests (excluding security_label):"
echo "$FAILED_TESTS"
echo "test_result=failed" >> $GITHUB_OUTPUT
else
echo "All tests passed (security_label failures are expected and ignored)"
echo "test_result=passed" >> $GITHUB_OUTPUT
fi
timeout-minutes: 30

- name: Collect installcheck artifacts
if: ${{ always() }}
run: |
cd ${GITHUB_WORKSPACE}/tests/docker/
mkdir -p installcheck-logs

# Copy the output file we captured
cp installcheck_output.txt installcheck-logs/

# Copy regression output from n1 (where tests run)
# pg_regress outputs to /home/pgedge/installcheck-output/
docker compose cp pgedge-n1:/home/pgedge/installcheck-output/regression.diffs installcheck-logs/ || true
docker compose cp pgedge-n1:/home/pgedge/installcheck-output/regression.out installcheck-logs/ || true
docker compose cp pgedge-n1:/home/pgedge/installcheck-output/results installcheck-logs/results/ || true

# Collect PostgreSQL logs from all nodes
for node in n1 n2 n3; do
echo "Collecting logs from $node..."
# PostgreSQL log file (from pg_ctl -l in entrypoint.sh)
docker compose cp pgedge-$node:/home/pgedge/logfile.log installcheck-logs/$node-logfile.log || true
# Container logs
docker compose logs pgedge-$node > installcheck-logs/$node-container.log 2>&1 || true
done

- name: Upload installcheck artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: installcheck-logs-pg${{ matrix.pgver }}
path: tests/docker/installcheck-logs/
if-no-files-found: error
retention-days: 7

- name: Cleanup docker cluster
if: ${{ always() }}
run: |
cd ${GITHUB_WORKSPACE}/tests/docker/
docker compose down

- name: Check test result
run: |
if [ "${{ steps.installcheck.outputs.test_result }}" = "failed" ]; then
echo "Installcheck tests failed (see artifacts for details)"
exit 1
fi
echo "Installcheck tests passed successfully"
180 changes: 91 additions & 89 deletions tests/docker/Dockerfile-step-1.el9
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ ARG MAKE_JOBS=4

# Export as environment variables for build-time and runtime
ENV PGVER=${PGVER} \
DBUSER=${DBUSER} \
DBPASSWD=${DBPASSWD} \
DBNAME=${DBNAME} \
DBPORT=${DBPORT}
DBUSER=${DBUSER} \
DBPASSWD=${DBPASSWD} \
DBNAME=${DBNAME} \
DBPORT=${DBPORT}

# PostgreSQL paths
ENV PATH="/home/pgedge/pgedge:/home/pgedge/pgedge/pg${PGVER}/bin:${PATH}" \
LD_LIBRARY_PATH="/home/pgedge/pgedge/pg${PGVER}/lib" \
PG_CONFIG="/home/pgedge/pgedge/pg${PGVER}/bin/pg_config" \
PGDATA="/home/pgedge/pgedge/data/pg${PGVER}"
LD_LIBRARY_PATH="/home/pgedge/pgedge/pg${PGVER}/lib" \
PG_CONFIG="/home/pgedge/pgedge/pg${PGVER}/bin/pg_config" \
PGDATA="/home/pgedge/pgedge/data/pg${PGVER}"

# Document exposed port
EXPOSE 5432
Expand All @@ -75,18 +75,18 @@ USER root

# Write PostgreSQL environment to .bashrc for interactive shells and entrypoint
RUN set -eux && \
{ \
echo "# PostgreSQL Environment"; \
echo "export PGVER=${PGVER}"; \
echo "export PGUSER=${DBUSER}"; \
echo "export PGPASSWORD=${DBPASSWD}"; \
echo "export PGDATABASE=${DBNAME}"; \
echo "export PGPORT=${DBPORT}"; \
echo "export PG_CONFIG=${PG_CONFIG}"; \
echo "export PATH=${PATH}"; \
echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"; \
echo "export PGDATA=${PGDATA}"; \
} >> /home/pgedge/.bashrc
{ \
echo "# PostgreSQL Environment"; \
echo "export PGVER=${PGVER}"; \
echo "export PGUSER=${DBUSER}"; \
echo "export PGPASSWORD=${DBPASSWD}"; \
echo "export PGDATABASE=${DBNAME}"; \
echo "export PGPORT=${DBPORT}"; \
echo "export PG_CONFIG=${PG_CONFIG}"; \
echo "export PATH=${PATH}"; \
echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"; \
echo "export PGDATA=${PGDATA}"; \
} >> /home/pgedge/.bashrc

# Copy Spock source code and test scripts
COPY . /home/pgedge/spock
Expand All @@ -99,14 +99,14 @@ COPY --chmod=755 tests/docker/*.sh /home/pgedge/
# Clone spockbench for testing workloads
# TODO: Pin to specific tag/commit for reproducibility
RUN set -eux && \
git clone --branch delta-apply-update --depth 1 \
https://github.com/pgEdge/spockbench.git /home/pgedge/spockbench && \
git clone --branch delta-apply-update --depth 1 \
https://github.com/pgEdge/spockbench.git /home/pgedge/spockbench && \
echo "export SPOCKBENCH_SOURCE_DIR=/home/pgedge/spockbench" >> /home/pgedge/.bashrc

RUN set -eux && \
cd /home/pgedge/spockbench && \
python3 setup.py install && \
echo "Spockbench installation complete"
cd /home/pgedge/spockbench && \
python3 setup.py install && \
echo "Spockbench installation complete"

# Set proper ownership
RUN chown -R pgedge:pgedge /home/pgedge/
Expand All @@ -124,16 +124,18 @@ WORKDIR /home/pgedge

# Determine the latest stable tag for the requested PostgreSQL major version
RUN set -eux && \
LATEST_TAG=$(git ls-remote --tags https://github.com/postgres/postgres.git | \
grep "refs/tags/REL_${PGVER}_" | \
sed 's|.*refs/tags/||' | \
tr '_' '.' | \
sort -V | \
tail -n 1 | \
tr '.' '_') && \
echo "Cloning PostgreSQL tag: ${LATEST_TAG}" && \
git clone --branch "${LATEST_TAG}" --depth 1 \
https://github.com/postgres/postgres.git /home/pgedge/postgres
LATEST_TAG=$(git ls-remote --tags https://github.com/postgres/postgres.git | \
grep "refs/tags/REL_${PGVER}_" | \
sed 's|.*refs/tags/||' | \
tr '_' '.' | \
sort -V | \
tail -n 1 | \
tr '.' '_') && \
echo "Cloning PostgreSQL tag: ${LATEST_TAG}" && \
git clone --branch "${LATEST_TAG}" --depth 1 \
https://github.com/postgres/postgres.git /home/pgedge/postgres && \
echo "export PG_SRCDIR=/home/pgedge/postgres" >> /home/pgedge/.bashrc


# ==============================================================================
# Apply Spock Patches to PostgreSQL
Expand All @@ -142,60 +144,60 @@ RUN set -eux && \
WORKDIR /home/pgedge/postgres

RUN set -eux && \
PATCH_DIR="/home/pgedge/spock/patches/${PGVER}" && \
if [ -d "${PATCH_DIR}" ] && [ -n "$(ls -A "${PATCH_DIR}" 2>/dev/null)" ]; then \
echo "Applying Spock patches for PostgreSQL ${PGVER}:"; \
for patchfile in "${PATCH_DIR}"/*; do \
echo " - $(basename "${patchfile}")"; \
patch -p1 --verbose < "${patchfile}"; \
done; \
echo "All patches applied successfully"; \
else \
echo "No patches found for PostgreSQL ${PGVER}, continuing with vanilla source"; \
fi
PATCH_DIR="/home/pgedge/spock/patches/${PGVER}" && \
if [ -d "${PATCH_DIR}" ] && [ -n "$(ls -A "${PATCH_DIR}" 2>/dev/null)" ]; then \
echo "Applying Spock patches for PostgreSQL ${PGVER}:"; \
for patchfile in "${PATCH_DIR}"/*; do \
echo " - $(basename "${patchfile}")"; \
patch -p1 --verbose < "${patchfile}"; \
done; \
echo "All patches applied successfully"; \
else \
echo "No patches found for PostgreSQL ${PGVER}, continuing with vanilla source"; \
fi

# ==============================================================================
# Compile and Install PostgreSQL
# ==============================================================================

RUN set -eux && \
echo "========================================" && \
echo "Configuring PostgreSQL ${PGVER}" && \
echo "========================================" && \
./configure \
--prefix="/home/pgedge/pgedge/pg${PGVER}" \
--disable-rpath \
--with-zstd \
--with-lz4 \
--with-icu \
--with-libxslt \
--with-libxml \
--with-uuid=ossp \
--with-gssapi \
--with-ldap \
--with-pam \
--with-openssl \
--with-systemd \
--with-llvm \
--with-python \
--enable-debug \
--enable-dtrace \
--enable-cassert \
--enable-tap-tests \
PYTHON=/usr/bin/python3 \
CFLAGS="-g -O0" \
BITCODE_CFLAGS="-gdwarf-5 -O0 -fforce-dwarf-frame" && \
echo "========================================" && \
echo "Building PostgreSQL (${MAKE_JOBS} jobs)" && \
echo "========================================" && \
make -j${MAKE_JOBS} > /dev/null && \
make -C contrib -j${MAKE_JOBS} > /dev/null && \
echo "========================================" && \
echo "Installing PostgreSQL" && \
echo "========================================" && \
make install > /dev/null && \
make -C contrib install > /dev/null && \
echo "PostgreSQL installation complete"
echo "========================================" && \
echo "Configuring PostgreSQL ${PGVER}" && \
echo "========================================" && \
./configure \
--prefix="/home/pgedge/pgedge/pg${PGVER}" \
--disable-rpath \
--with-zstd \
--with-lz4 \
--with-icu \
--with-libxslt \
--with-libxml \
--with-uuid=ossp \
--with-gssapi \
--with-ldap \
--with-pam \
--with-openssl \
--with-systemd \
--with-llvm \
--with-python \
--enable-debug \
--enable-dtrace \
--enable-cassert \
--enable-tap-tests \
PYTHON=/usr/bin/python3 \
CFLAGS="-g -O0" \
BITCODE_CFLAGS="-gdwarf-5 -O0 -fforce-dwarf-frame" && \
echo "========================================" && \
echo "Building PostgreSQL (${MAKE_JOBS} jobs)" && \
echo "========================================" && \
make -j${MAKE_JOBS} > /dev/null && \
make -C contrib -j${MAKE_JOBS} > /dev/null && \
echo "========================================" && \
echo "Installing PostgreSQL" && \
echo "========================================" && \
make install > /dev/null && \
make -C contrib install > /dev/null && \
echo "PostgreSQL installation complete"

# ==============================================================================
# Compile and Install Spock Extension
Expand All @@ -204,14 +206,14 @@ RUN set -eux && \
WORKDIR /home/pgedge/spock

RUN set -eux && \
echo "========================================" && \
echo "Building Spock Extension" && \
echo "========================================" && \
make clean > /dev/null && \
make -j${MAKE_JOBS} > /dev/null && \
make install > /dev/null && \
echo "========================================" && \
echo "Building Spock Extension" && \
echo "========================================" && \
make clean > /dev/null && \
make -j${MAKE_JOBS} > /dev/null && \
make install > /dev/null && \
echo "export SPOCK_SOURCE_DIR=/home/pgedge/spock" >> /home/pgedge/.bashrc && \
echo "Spock installation complete"
echo "Spock installation complete"

# ==============================================================================
# Runtime Configuration
Expand Down
Loading