Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgrespro/testgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.9.2
Choose a base ref
...
head repository: postgrespro/testgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 9,401 additions and 2,801 deletions.
  1. +1 −0 .gitignore
  2. +18 −15 .travis.yml
  3. +118 −0 Dockerfile--altlinux_10.tmpl
  4. +118 −0 Dockerfile--altlinux_11.tmpl
  5. +62 −0 Dockerfile--std-all.tmpl
  6. +22 −0 Dockerfile--std.tmpl
  7. +96 −0 Dockerfile--std2-all.tmpl
  8. +73 −0 Dockerfile--ubuntu_24_04.tmpl
  9. +0 −23 Dockerfile.tmpl
  10. +4 −4 README.md
  11. +0 −2 docker-compose.yml
  12. +0 −2 mk_dockerfile.sh
  13. +9 −0 pytest.ini
  14. +14 −22 run_tests.sh
  15. +68 −0 run_tests2.sh
  16. +4 −4 setup.py
  17. +5 −2 testgres/__init__.py
  18. +1 −3 testgres/api.py
  19. +35 −10 testgres/backup.py
  20. +25 −8 testgres/cache.py
  21. +8 −1 testgres/config.py
  22. +12 −10 testgres/connection.py
  23. +4 −0 testgres/consts.py
  24. +16 −3 testgres/exceptions.py
  25. +64 −0 testgres/impl/port_manager__generic.py
  26. +33 −0 testgres/impl/port_manager__this_host.py
  27. +985 −177 testgres/node.py
  28. +55 −0 testgres/operations/helpers.py
  29. +354 −97 testgres/operations/local_ops.py
  30. +48 −14 testgres/operations/os_ops.py
  31. +57 −0 testgres/operations/raise_error.py
  32. +539 −167 testgres/operations/remote_ops.py
  33. +8 −0 testgres/plugins/__init__.py
  34. +57 −0 testgres/plugins/pg_probackup2/README.md
  35. 0 testgres/plugins/pg_probackup2/__init__.py
  36. 0 testgres/plugins/pg_probackup2/pg_probackup2/__init__.py
  37. +863 −0 testgres/plugins/pg_probackup2/pg_probackup2/app.py
  38. +349 −0 testgres/plugins/pg_probackup2/pg_probackup2/gdb.py
  39. +226 −0 testgres/plugins/pg_probackup2/pg_probackup2/init_helpers.py
  40. 0 testgres/plugins/pg_probackup2/pg_probackup2/storage/__init__.py
  41. +104 −0 testgres/plugins/pg_probackup2/pg_probackup2/storage/fs_backup.py
  42. 0 testgres/plugins/pg_probackup2/pg_probackup2/tests/__init__.py
  43. +104 −0 testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py
  44. +18 −0 testgres/plugins/pg_probackup2/setup.py
  45. +10 −0 testgres/port_manager.py
  46. +103 −37 testgres/utils.py
  47. 0 tests/__init__.py
  48. +989 −0 tests/conftest.py
  49. 0 tests/helpers/__init__.py
  50. +78 −0 tests/helpers/global_data.py
  51. +12 −0 tests/helpers/run_conditions.py
  52. +41 −0 tests/test_config.py
  53. +80 −0 tests/test_conftest.py--devel
  54. +1,115 −0 tests/test_os_ops_common.py
  55. +60 −0 tests/test_os_ops_local.py
  56. +79 −0 tests/test_os_ops_remote.py
  57. +0 −195 tests/test_remote.py
  58. +0 −1,009 tests/test_simple.py
  59. +0 −996 tests/test_simple_remote.py
  60. +1,590 −0 tests/test_testgres_common.py
  61. +414 −0 tests/test_testgres_local.py
  62. +190 −0 tests/test_testgres_remote.py
  63. +63 −0 tests/test_utils.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
dist/
build/
docs/build/
logs/

env/
venv/
33 changes: 18 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -8,27 +8,30 @@ services:
- docker

install:
- ./mk_dockerfile.sh
- docker-compose build
- docker build --build-arg PG_VERSION="${PG_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" -t tests -f Dockerfile--${TEST_PLATFORM}.tmpl .

script:
- docker-compose run $(bash <(curl -s https://codecov.io/env)) tests
- docker run $(bash <(curl -s https://codecov.io/env)) -t tests

notifications:
email:
on_success: change
on_failure: always

env:
- PYTHON_VERSION=3 PG_VERSION=14
- PYTHON_VERSION=3 PG_VERSION=13
- PYTHON_VERSION=3 PG_VERSION=12
- PYTHON_VERSION=3 PG_VERSION=11
- PYTHON_VERSION=3 PG_VERSION=10
# - PYTHON_VERSION=3 PG_VERSION=9.6
# - PYTHON_VERSION=3 PG_VERSION=9.5
# - PYTHON_VERSION=3 PG_VERSION=9.4
# - PYTHON_VERSION=2 PG_VERSION=10
# - PYTHON_VERSION=2 PG_VERSION=9.6
# - PYTHON_VERSION=2 PG_VERSION=9.5
# - PYTHON_VERSION=2 PG_VERSION=9.4
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.8.0 PG_VERSION=17
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.8 PG_VERSION=17
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.9 PG_VERSION=17
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.10 PG_VERSION=17
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.11 PG_VERSION=17
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=16
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=15
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=14
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=13
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=12
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=11
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=10
- TEST_PLATFORM=std-all PYTHON_VERSION=3 PG_VERSION=17
- TEST_PLATFORM=ubuntu_24_04 PYTHON_VERSION=3 PG_VERSION=17
- TEST_PLATFORM=altlinux_10 PYTHON_VERSION=3 PG_VERSION=17
- TEST_PLATFORM=altlinux_11 PYTHON_VERSION=3 PG_VERSION=17
118 changes: 118 additions & 0 deletions Dockerfile--altlinux_10.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
ARG PG_VERSION
ARG PYTHON_VERSION

# --------------------------------------------- base1
FROM alt:p10 as base1
ARG PG_VERSION

RUN apt-get update
RUN apt-get install -y sudo curl ca-certificates
RUN apt-get update
RUN apt-get install -y openssh-server openssh-clients
RUN apt-get install -y time

# RUN apt-get install -y mc

RUN apt-get install -y libsqlite3-devel

EXPOSE 22

RUN ssh-keygen -A

# --------------------------------------------- postgres
FROM base1 as base1_with_dev_tools

RUN apt-get update

RUN apt-get install -y git
RUN apt-get install -y gcc
RUN apt-get install -y make

RUN apt-get install -y meson
RUN apt-get install -y flex
RUN apt-get install -y bison

RUN apt-get install -y pkg-config
RUN apt-get install -y libssl-devel
RUN apt-get install -y libicu-devel
RUN apt-get install -y libzstd-devel
RUN apt-get install -y zlib-devel
RUN apt-get install -y liblz4-devel
RUN apt-get install -y libzstd-devel
RUN apt-get install -y libxml2-devel

# --------------------------------------------- postgres
FROM base1_with_dev_tools as base1_with_pg-17

RUN git clone https://github.com/postgres/postgres.git -b REL_17_STABLE /pg/postgres/source

WORKDIR /pg/postgres/source

RUN ./configure --prefix=/pg/postgres/install --with-zlib --with-openssl --without-readline --with-lz4 --with-zstd --with-libxml
RUN make -j 4 install
RUN make -j 4 -C contrib install

# SETUP PG_CONFIG
# When pg_config symlink in /usr/local/bin it returns a real (right) result of --bindir
RUN ln -s /pg/postgres/install/bin/pg_config -t /usr/local/bin

# SETUP PG CLIENT LIBRARY
# libpq.so.5 is enough
RUN ln -s /pg/postgres/install/lib/libpq.so.5.17 /usr/lib64/libpq.so.5

# --------------------------------------------- base2_with_python-3
FROM base1_with_pg-${PG_VERSION} as base2_with_python-3
RUN apt-get install -y python3
RUN apt-get install -y python3-dev
RUN apt-get install -y python3-module-virtualenv
RUN apt-get install -y python3-modules-sqlite3

# AltLinux does not have "generic" virtualenv utility. Let's create it.
RUN if [[ -f "/usr/bin/virtualenv" ]] ; then \
echo AAA; \
elif [[ -f "/usr/bin/virtualenv3" ]] ; then \
ln -s /usr/bin/virtualenv3 /usr/bin/virtualenv; \
else \
echo "/usr/bin/virtualenv is not created!"; \
exit 1; \
fi

ENV PYTHON_VERSION=3

# --------------------------------------------- final
FROM base2_with_python-${PYTHON_VERSION} as final

RUN adduser test -G wheel

# It enables execution of "sudo service ssh start" without password
RUN sh -c "echo \"WHEEL_USERS ALL=(ALL:ALL) NOPASSWD: ALL\"" >> /etc/sudoers

ADD . /pg/testgres
WORKDIR /pg/testgres
RUN chown -R test /pg/testgres

ENV LANG=C.UTF-8

USER test

RUN chmod 700 ~/
RUN mkdir -p ~/.ssh

#
# Altlinux 10 and 11 too slowly create a new SSH connection (x6).
#
# So, we exclude the "remote" tests until this problem has been resolved.
#

ENTRYPOINT sh -c " \
set -eux; \
echo HELLO FROM ENTRYPOINT; \
echo HOME DIR IS [`realpath ~/`]; \
sudo /usr/sbin/sshd; \
ssh-keyscan -H localhost >> ~/.ssh/known_hosts; \
ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts; \
ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -N ''; \
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys; \
chmod 600 ~/.ssh/authorized_keys; \
ls -la ~/.ssh/; \
TEST_FILTER=\"TestTestgresLocal or TestOsOpsLocal or local\" bash ./run_tests.sh;"
118 changes: 118 additions & 0 deletions Dockerfile--altlinux_11.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
ARG PG_VERSION
ARG PYTHON_VERSION

# --------------------------------------------- base1
FROM alt:p11 as base1
ARG PG_VERSION

RUN apt-get update
RUN apt-get install -y sudo curl ca-certificates
RUN apt-get update
RUN apt-get install -y openssh-server openssh-clients
RUN apt-get install -y time

# RUN apt-get install -y mc

RUN apt-get install -y libsqlite3-devel

EXPOSE 22

RUN ssh-keygen -A

# --------------------------------------------- postgres
FROM base1 as base1_with_dev_tools

RUN apt-get update

RUN apt-get install -y git
RUN apt-get install -y gcc
RUN apt-get install -y make

RUN apt-get install -y meson
RUN apt-get install -y flex
RUN apt-get install -y bison

RUN apt-get install -y pkg-config
RUN apt-get install -y libssl-devel
RUN apt-get install -y libicu-devel
RUN apt-get install -y libzstd-devel
RUN apt-get install -y zlib-devel
RUN apt-get install -y liblz4-devel
RUN apt-get install -y libzstd-devel
RUN apt-get install -y libxml2-devel

# --------------------------------------------- postgres
FROM base1_with_dev_tools as base1_with_pg-17

RUN git clone https://github.com/postgres/postgres.git -b REL_17_STABLE /pg/postgres/source

WORKDIR /pg/postgres/source

RUN ./configure --prefix=/pg/postgres/install --with-zlib --with-openssl --without-readline --with-lz4 --with-zstd --with-libxml
RUN make -j 4 install
RUN make -j 4 -C contrib install

# SETUP PG_CONFIG
# When pg_config symlink in /usr/local/bin it returns a real (right) result of --bindir
RUN ln -s /pg/postgres/install/bin/pg_config -t /usr/local/bin

# SETUP PG CLIENT LIBRARY
# libpq.so.5 is enough
RUN ln -s /pg/postgres/install/lib/libpq.so.5.17 /usr/lib64/libpq.so.5

# --------------------------------------------- base2_with_python-3
FROM base1_with_pg-${PG_VERSION} as base2_with_python-3
RUN apt-get install -y python3
RUN apt-get install -y python3-dev
RUN apt-get install -y python3-module-virtualenv
RUN apt-get install -y python3-modules-sqlite3

# AltLinux does not have "generic" virtualenv utility. Let's create it.
RUN if [[ -f "/usr/bin/virtualenv" ]] ; then \
echo AAA; \
elif [[ -f "/usr/bin/virtualenv3" ]] ; then \
ln -s /usr/bin/virtualenv3 /usr/bin/virtualenv; \
else \
echo "/usr/bin/virtualenv is not created!"; \
exit 1; \
fi

ENV PYTHON_VERSION=3

# --------------------------------------------- final
FROM base2_with_python-${PYTHON_VERSION} as final

RUN adduser test -G wheel

# It enables execution of "sudo service ssh start" without password
RUN sh -c "echo \"WHEEL_USERS ALL=(ALL:ALL) NOPASSWD: ALL\"" >> /etc/sudoers

ADD . /pg/testgres
WORKDIR /pg/testgres
RUN chown -R test /pg/testgres

ENV LANG=C.UTF-8

USER test

RUN chmod 700 ~/
RUN mkdir -p ~/.ssh

#
# Altlinux 10 and 11 too slowly create a new SSH connection (x6).
#
# So, we exclude the "remote" tests until this problem has been resolved.
#

ENTRYPOINT sh -c " \
set -eux; \
echo HELLO FROM ENTRYPOINT; \
echo HOME DIR IS [`realpath ~/`]; \
sudo /usr/sbin/sshd; \
ssh-keyscan -H localhost >> ~/.ssh/known_hosts; \
ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts; \
ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -N ''; \
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys; \
chmod 600 ~/.ssh/authorized_keys; \
ls -la ~/.ssh/; \
TEST_FILTER=\"TestTestgresLocal or TestOsOpsLocal or local\" bash ./run_tests.sh;"
62 changes: 62 additions & 0 deletions Dockerfile--std-all.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
ARG PG_VERSION
ARG PYTHON_VERSION

# --------------------------------------------- base1
FROM postgres:${PG_VERSION}-alpine as base1

# --------------------------------------------- base2_with_python-3
FROM base1 as base2_with_python-3
RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers py-virtualenv
ENV PYTHON_VERSION=3

# --------------------------------------------- final
FROM base2_with_python-${PYTHON_VERSION} as final

#RUN apk add --no-cache mc

# Full version of "ps" command
RUN apk add --no-cache procps

RUN apk add --no-cache openssh
RUN apk add --no-cache sudo

ENV LANG=C.UTF-8

RUN addgroup -S sudo
RUN adduser postgres sudo

EXPOSE 22
RUN ssh-keygen -A

ADD . /pg/testgres
WORKDIR /pg/testgres
RUN chown -R postgres:postgres /pg

# It allows to use sudo without password
RUN sh -c "echo \"postgres ALL=(ALL:ALL) NOPASSWD:ALL\"">>/etc/sudoers

# THIS CMD IS NEEDED TO CONNECT THROUGH SSH WITHOUT PASSWORD
RUN sh -c "echo "postgres:*" | chpasswd -e"

USER postgres

# THIS CMD IS NEEDED TO CONNECT THROUGH SSH WITHOUT PASSWORD
RUN chmod 700 ~/

RUN mkdir -p ~/.ssh
#RUN chmod 700 ~/.ssh

#ENTRYPOINT PYTHON_VERSION=${PYTHON_VERSION} bash run_tests.sh

ENTRYPOINT sh -c " \
set -eux; \
echo HELLO FROM ENTRYPOINT; \
echo HOME DIR IS [`realpath ~/`]; \
ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -N ''; \
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys; \
chmod 600 ~/.ssh/authorized_keys; \
ls -la ~/.ssh/; \
sudo /usr/sbin/sshd; \
ssh-keyscan -H localhost >> ~/.ssh/known_hosts; \
ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts; \
TEST_FILTER=\"\" bash run_tests.sh;"
22 changes: 22 additions & 0 deletions Dockerfile--std.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG PG_VERSION
ARG PYTHON_VERSION

# --------------------------------------------- base1
FROM postgres:${PG_VERSION}-alpine as base1

# --------------------------------------------- base2_with_python-3
FROM base1 as base2_with_python-3
RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers py-virtualenv
ENV PYTHON_VERSION=3

# --------------------------------------------- final
FROM base2_with_python-${PYTHON_VERSION} as final

ENV LANG=C.UTF-8

ADD . /pg/testgres
WORKDIR /pg/testgres
RUN chown -R postgres:postgres /pg

USER postgres
ENTRYPOINT bash run_tests.sh
Loading