Skip to content

Commit

Permalink
Refactor update test
Browse files Browse the repository at this point in the history
Currently the update test is quite inconvenient to run locally and also
inconvenient to debug as the different update tests all run in their own
docker container. This patch refactors the update test to no longer
require docker and make it easier to debug as it will run in the
local environment as determined by pg_config.
This patch also consolidates update/downgrade and repair test since
they do very similar things and adds support for coredump stacktraces to
the github action and removes some dead code from the update tests.
Additionally the versions to be used in the update test are now
determined from existing git tags so the post release patch no longer
needs to add newly released versions.
  • Loading branch information
svenklemm committed Mar 3, 2024
1 parent 7548a06 commit fe06edd
Show file tree
Hide file tree
Showing 17 changed files with 358 additions and 1,145 deletions.
117 changes: 58 additions & 59 deletions .github/workflows/update-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,12 @@ name: Test Update and Downgrade
- prerelease_test
pull_request:
jobs:
config:
runs-on: ubuntu-latest
outputs:
pg_latest: ${{ steps.setter.outputs.PG_LATEST }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Read configuration
id: setter
run: python .github/gh_config_reader.py

update_test:
name: Update test PG${{ matrix.pg }}
runs-on: 'ubuntu-latest'
needs: config
strategy:
matrix:
pg: ${{ fromJson(needs.config.outputs.pg_latest) }}
pg: [13, 14, 15, 16]
fail-fast: false
env:
PG_VERSION: ${{ matrix.pg }}
Expand All @@ -32,63 +20,74 @@ jobs:
- name: Checkout TimescaleDB
uses: actions/checkout@v4

- name: Update tests ${{ matrix.pg }}
- name: Install Dependencies
run: |
PG_MAJOR=$(echo "${{ matrix.pg }}" | sed -e 's![.].*!!')
./scripts/test_updates_pg${PG_MAJOR}.sh
sudo apt-get update
sudo apt-get install gnupg systemd-coredump gdb postgresql-common libkrb5-dev
yes | sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }}
sudo apt-get install -y --no-install-recommends timescaledb-2-postgresql-${{ matrix.pg }}
git fetch --tags
- name: Update diff
if: failure()
- name: Update tests PG${{ matrix.pg }}
run: |
find . -name "update_test.*.diff.*" -maxdepth 1 | xargs -IFILE sh -c "echo '\nFILE\n';cat FILE"
- name: Upload Artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: Extension update diff ${{ matrix.pg }}
path: update_test.*.diff.*
PATH="/usr/lib/postgresql/${{ matrix.pg }}/bin:$PATH"
./scripts/test_updates.sh
downgrade_test:
name: Downgrade test PG${{ matrix.pg }}
runs-on: 'ubuntu-latest'
needs: config
strategy:
matrix:
pg: ${{ fromJson(needs.config.outputs.pg_latest) }}
fail-fast: false
env:
PG_VERSION: ${{ matrix.pg }}
POSTGRES_HOST_AUTH_METHOD: trust
GENERATE_DOWNGRADE_SCRIPT: ON
steps:
- name: Checkout TimescaleDB
uses: actions/checkout@v4
- name: Downgrade tests PG${{ matrix.pg }}
if: always()
run: |
PATH="/usr/lib/postgresql/${{ matrix.pg }}/bin:$PATH"
./scripts/test_downgrade.sh
# We need the tags to be able to build a downgrade script.
- name: Fetch all tags
run: git fetch --tags && git tag
- name: Update diff
if: failure()
run: |
find update_test -name "*.diff" | xargs -IFILE sh -c "echo '\nFILE\n';cat FILE"
- name: Downgrade tests ${{ matrix.pg }}
env:
TEST_VERSION: v7
- name: Check for coredumps
if: always()
id: collectlogs
run: |
DOWNGRADE_TO=$(grep '^downgrade_to_version = ' version.config | sed -e 's!^[^=]\+ = !!')
PG_MAJOR=$(echo "${{ matrix.pg }}" | sed -e 's![.].*!!')
UPDATE_FROM_TAG=${DOWNGRADE_TO}-pg${PG_MAJOR}
export UPDATE_FROM_TAG
# We need to use same libssl version used in the latest official TimescaleDB container images.
# So we will use the fixed alpine version, this will guarantee that libssl version won't change.
PG_IMAGE_TAG="${PG_VERSION}-alpine3.18" scripts/test_downgrade_from_tag.sh
# wait for in progress coredumps
sleep 10
if coredumpctl list; then
echo "coredumps=true" >>$GITHUB_OUTPUT
false
fi
- name: Downgrade diff
if: failure()
- name: Stack trace
if: always() && steps.collectlogs.outputs.coredumps == 'true'
run: |
find . -name "downgrade_test.*.diff.*" -maxdepth 1 | xargs -IFILE sh -c "echo '\nFILE\n';cat FILE"
sudo coredumpctl gdb <<<"
set verbose on
set trace-commands on
show debug-file-directory
printf "'"'"query = '%s'\n\n"'"'", (char *) debug_query_string
frame function ExceptionalCondition
printf "'"'"condition = '%s'\n"'"'", (char *) conditionName
up 1
l
info args
info locals
bt full
" 2>&1 | tee stacktrace.log
./scripts/bundle_coredumps.sh
false
- name: Upload Coredumps
if: always() && steps.collectlogs.outputs.coredumps == 'true'
uses: actions/upload-artifact@v4
with:
name: Coredumps sqlsmith ${{ matrix.os }} PG${{ matrix.pg }}
path: coredumps

- name: Upload Artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: Extension downgrade diff ${{ matrix.pg }}
path: downgrade_test.*.diff.*
name: Update test PG${{ matrix.pg }}
path: update_test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ typedef.list
/test/testcluster
/test/log
/test/temp_schedule
/build
/build*
/update_test
**/GPATH
**/GTAGS
**/GRTAGS
Expand Down
46 changes: 46 additions & 0 deletions scripts/test_downgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -e

SCRIPT_DIR=$(dirname $0)
PG_MAJOR_VERSION=$(pg_config --version | awk '{print $2}' | awk -F. '{print $1}')

PG_EXTENSION_DIR=$(pg_config --sharedir)/extension
if [ "${CI:-false}" == true ]; then
GIT_REF=${GIT_REF:-$(git rev-parse HEAD)}
else
GIT_REF=$(git branch --show-current)
fi


BUILD_DIR="build_update_pg${PG_MAJOR_VERSION}"

CURRENT_VERSION=$(grep '^version ' version.config | awk '{ print $3 }')
PREV_VERSION=$(grep '^downgrade_to_version ' version.config | awk '{ print $3 }')

if [ ! -d "${BUILD_DIR}" ]; then
echo "Initializing build directory"
BUILD_DIR="${BUILD_DIR}" ./bootstrap -DCMAKE_BUILD_TYPE=Release -DWARNINGS_AS_ERRORS=OFF -DASSERTIONS=ON -DLINTER=ON -DGENERATE_DOWNGRADE_SCRIPT=ON -DREGRESS_CHECKS=OFF -DTAP_CHECKS=OFF
fi

if [ ! -f "${PG_EXTENSION_DIR}/timescaledb--${PREV_VERSION}.sql" ]; then
echo "Building ${PREV_VERSION}"
git checkout ${PREV_VERSION}
make -C "${BUILD_DIR}" -j4 > /dev/null
sudo make -C "${BUILD_DIR}" install > /dev/null
git checkout ${GIT_REF}
fi

# We want to use the latest loader for all the tests so we build it last
make -C "${BUILD_DIR}" -j4
sudo make -C "${BUILD_DIR}" install > /dev/null

set +e

FROM_VERSION=${CURRENT_VERSION} TO_VERSION=${PREV_VERSION} TEST_VERSION=v8 TEST_REPAIR=false "${SCRIPT_DIR}/test_update_from_version.sh"
return_code=$?
if [ $return_code -ne 0 ]; then
echo -e "\nFailed downgrade from ${CURRENT_VERSION} to ${PREV_VERSION}\n"
exit 1
fi

Loading

0 comments on commit fe06edd

Please sign in to comment.