Skip to content

Commit

Permalink
Pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
postgres-dev committed Aug 10, 2023
1 parent 80e3777 commit 676f3d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ jobs:
working-directory: ptrack
- name: Install Postgres
run: |
rm -rf /home/dev/pgsql
git clean -ffdx
if [ "$TESTS" = tap -a "$MODE" = legacy ]; then
./configure CFLAGS='-DEXEC_BACKEND' --disable-atomics --prefix=$PREFIX --enable-debug --enable-cassert --enable-depend --enable-tap-tests --quiet
else
Expand All @@ -72,22 +70,22 @@ jobs:
echo $PREFIX/bin >> $GITHUB_PATH
working-directory: postgres
- name: Install Ptrack
run: git clean -ffdx; make install USE_PGXS=1
run: make install USE_PGXS=1
working-directory: ptrack
- name: Install Pg_probackup
run: make install USE_PGXS=1 PG_CONFIG=$PREFIX/bin/pg_config top_srcdir=../postgres
working-directory: pg_probackup
- name: Install additional packages
run: |
apt update &&
apt install -y python3-pip python3-six &&
apt install -y python3-pip python3-six python3-pytest python3-pytest-xdist &&
pip3 install --no-input testgres
# All steps have been so far executed by root but ptrack tests run from an
# unprivileged user so change some permissions
- name: Adjust the permissions of ptrack test folders
run: |
mkdir pg_probackup/tests/tmp_dirs
chown "dev:" ptrack pg_probackup/tests/tmp_dirs
chown -R "dev:" pg_probackup ptrack
- name: Test
run: make test-${{ matrix.tests }} USE_PGXS=1 PG_CONFIG=$PREFIX/bin/pg_config
working-directory: ptrack
Expand Down
18 changes: 7 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ endif

# Assuming make is started in the ptrack directory
patch:
ifndef PG_BRANCH
$(error PG_BRANCH is not defined. Set it to the desired PostgreSQL repository branch name (e.g. REL_15_STABLE).)
endif
@cd $(top_builddir) && \
echo Applying the ptrack patch... && \
git apply --verbose --3way $(CURDIR)/patches/${PG_BRANCH}-ptrack-core.diff
Expand Down Expand Up @@ -62,19 +59,18 @@ pg_probackup_dir ?= $(CURDIR)/../pg_probackup
# Pg_probackup's Makefile uses top_srcdir when building via PGXS so set it when calling this target
install-pg-probackup:
echo PATH=$$PATH
export PATH=/home/dev/pgsql/bin:$$PATH; echo PATHnew=$$PATH; $(MAKE) -j $(nproc) -C $(pg_probackup_dir) install USE_PGXS=$(USE_PGXS) PG_CONFIG=$(PG_CONFIG) top_srcdir=$(CURDIR)/../postgres
export $(MAKE) -j $(nproc) -C $(pg_probackup_dir) install USE_PGXS=$(USE_PGXS) PG_CONFIG=$(PG_CONFIG) top_srcdir=$(top_srcdir)

PYTEST_PROCESSES ?= $(shell nproc)
test-python:
cd $(pg_probackup_dir); \
env="PG_PROBACKUP_PTRACK=ON PG_CONFIG=$(PG_CONFIG)"; \
if [ "$(TEST_MODE)" = basic ]; then \
env="$$env PG_PROBACKUP_TEST_BASIC=ON"; \
env="$$env PG_PROBACKUP_TEST_BASIC=ON"; \
elif [ "$(TEST_MODE)" = paranoia ]; then \
env="$$env PG_PROBACKUP_PARANOIA=ON"; \
env="$$env PG_PROBACKUP_PARANOIA=ON"; \
fi; \
if [ "$(TESTS)" = python ]; then \
tests=tests.ptrack_test; \
else \
tests=tests.ptrack_test.PtrackTest."$(TESTS)"; \
if [ ! "$(TESTS)" = python ]; then \
test_filter=" -k '$(TESTS)'"; \
fi; \
env $$env python3 -m unittest -v "$$tests"
env $$env python3 -m pytest -svv -n $(PYTEST_PROCESSES)$$test_filter tests/ptrack_test.py

0 comments on commit 676f3d5

Please sign in to comment.