Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update test pipeline #194

Merged
merged 1 commit into from
Oct 9, 2023
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
8 changes: 6 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request') && inputs.debug_enabled }}
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Run tests linux
id: test-linux
run: sudo su postgres -c "PG_VERSION=$PG_VERSION ./ci/scripts/run-tests-linux.sh"
Expand All @@ -45,7 +45,11 @@ jobs:
if: ${{ startsWith(matrix.os, 'ubuntu') }}
- name: Run update tests linux
id: update-test-linux
run: sudo su postgres -c "PG_VERSION=$PG_VERSION python3 ./scripts/test_updates.py -U postgres"
run: |
sudo pip install GitPython &&\
# Start postgres
sudo su postgres -c "PG_VERSION=$PG_VERSION RUN_TESTS=0 ./ci/scripts/run-tests-linux.sh" && \
sudo python3 ./scripts/test_updates.py -U postgres
env:
PG_VERSION: ${{ matrix.postgres }}
if: ${{ startsWith(matrix.os, 'ubuntu') }}
Expand Down
22 changes: 19 additions & 3 deletions ci/scripts/run-tests-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
WORKDIR=/tmp/lantern
GITHUB_OUTPUT=${GITHUB_OUTPUT:-/dev/null}
PG_VERSION=${PG_VERSION:-15}
RUN_TESTS=${RUN_TESTS:-1}

export PGDATA=/etc/postgresql/$PG_VERSION/main

Expand All @@ -21,11 +22,26 @@ wait_for_pg(){
done
}

function run_db_tests(){
if [[ "$RUN_TESTS" == "1" ]]
then
cd $WORKDIR/build && \
make test && \
killall postgres && \
gcovr -r $WORKDIR/src/ --object-directory $WORKDIR/build/ --xml /tmp/coverage.xml
fi
}

echo "port = 5432" >> ${PGDATA}/postgresql.conf
# Enable auth without password
echo "local all all trust" > $PGDATA/pg_hba.conf
echo "host all all 127.0.0.1/32 trust" >> $PGDATA/pg_hba.conf
echo "host all all ::1/128 trust" >> $PGDATA/pg_hba.conf


# Set port
echo "port = 5432" >> ${PGDATA}/postgresql.conf
# Run postgres database
GCOV_PREFIX=$WORKDIR/build/CMakeFiles/lantern.dir/ GCOV_PREFIX_STRIP=5 POSTGRES_HOST_AUTH_METHOD=trust /usr/lib/postgresql/$PG_VERSION/bin/postgres 1>/tmp/pg-out.log 2>/tmp/pg-error.log &
# Wait for start and run tests
wait_for_pg && cd $WORKDIR/build && make test && \
killall postgres && \
gcovr -r $WORKDIR/src/ --object-directory $WORKDIR/build/ --xml /tmp/coverage.xml
wait_for_pg && run_db_tests
5 changes: 3 additions & 2 deletions scripts/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def update_from_tag(from_version: str, to_version: str):
sha_before = repo.head.object.hexsha
print("sha_before", sha_before)
print("checkout to tag", from_tag)
repo.remotes[0].fetch()
repo.git.checkout(from_tag)
sha_after = repo.head.object.hexsha
print("sha_after", sha_after)
Expand All @@ -25,7 +26,7 @@ def update_from_tag(from_version: str, to_version: str):

res = subprocess.run(f"psql postgres -U {args.user} -c 'DROP DATABASE IF EXISTS {args.db};'", shell=True)
res = subprocess.run(f"psql postgres -U {args.user} -c 'CREATE DATABASE {args.db};'", shell=True)
res = subprocess.run(f"psql postgres -c 'DROP EXTENSION IF EXISTS lantern CASCADE; CREATE EXTENSION lantern;' -d {args.db};", shell=True)
res = subprocess.run(f"psql postgres -U {args.user} -c 'DROP EXTENSION IF EXISTS lantern CASCADE; CREATE EXTENSION lantern;' -d {args.db};", shell=True)
# todo:: run init() portion of parallel tests

repo.git.checkout(sha_before)
Expand All @@ -41,7 +42,7 @@ def update_from_tag(from_version: str, to_version: str):
# collect the tag from command line to upgrade from

parser = argparse.ArgumentParser(description='Update from tag')
parser.add_argument('--from_tag', '--from_tag', metavar='from_tag', type=str,
parser.add_argument('-from_tag', '--from_tag', metavar='from_tag', type=str,
help='Tag to update from', required=False)
parser.add_argument('-to_tag','--to_tag', metavar='to_tag', type=str,
help='Tag to update to', required=False)
Expand Down