diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82f56b5..a1cf3c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -72,7 +70,7 @@ 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 @@ -80,14 +78,14 @@ jobs: - 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 diff --git a/Makefile b/Makefile index 4f30ba3..082faf5 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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