Skip to content

Commit

Permalink
Update supported python and postgres versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ettanany committed Jun 17, 2024
1 parent d28945a commit e7338aa
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- id: checkout-code
Expand Down
18 changes: 9 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Requirements
============

PGHoard can backup and restore PostgreSQL versions 9.6 and above, but is
only tested and actively developed with version 10 and above.
only tested and actively developed with version 12 and above.

The daemon is implemented in Python and is tested and developed with version
3.8 and above. The following Python modules are required:
Expand Down Expand Up @@ -128,35 +128,35 @@ Vagrant
=======

The Vagrantfile can be used to setup a vagrant development environment. The vagrant environment has
python 3.8, 3.9 and 3.10 virtual environments and installations of postgresql 10, 11 and 12, 13 and 14.
python 3.8, 3.9, 3.10, 3.11 and 3.12 virtual environments and installations of postgresql 12, 13, 14, 15 and 16.

By default vagrant up will start a Virtualbox environment. The Vagrantfile will also work for libvirt, just prefix
``VAGRANT_DEFAULT_PROVIDER=libvirt`` to the ``vagrant up`` command.

Any combination of Python (3.8, 3.9 and 3.10) and Postgresql (10, 11, 12, 13 and 14)
Any combination of Python (3.8, 3.9, 3.10, 3.11 and 3.12) and Postgresql (12, 13, 14, 15 and 16)

Bring up vagrant instance and connect via ssh::

vagrant up
vagrant ssh
vagrant@ubuntu2004:~$ cd /vagrant

Test with Python 3.8 and Postgresql 11::
Test with Python 3.8 and Postgresql 12::

vagrant@ubuntu2004:~$ source ~/venv3.8/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=11 make unittest
vagrant@ubuntu2004:~$ PG_VERSION=12 make unittest
vagrant@ubuntu2004:~$ deactivate

Test with Python 3.9 and Postgresql 12::
Test with Python 3.9 and Postgresql 13::

vagrant@ubuntu2004:~$ source ~/venv3.9/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=12 make unittest
vagrant@ubuntu2004:~$ PG_VERSION=13 make unittest
vagrant@ubuntu2004:~$ deactivate

Test with Python 3.10 and Postgresql 13::
Test with Python 3.10 and Postgresql 14::

vagrant@ubuntu2004:~$ source ~/venv3.10/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=13 make unittest
vagrant@ubuntu2004:~$ PG_VERSION=14 make unittest
vagrant@ubuntu2004:~$ deactivate

And so on
Expand Down
6 changes: 3 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Vagrant.configure("2") do |config|
sed -i "s/^#start_conf.*/start_conf='manual'/g" /etc/postgresql-common/createcluster.conf
sed -i "s/^#create_main_cluster.*/create_main_cluster=false/g" /etc/postgresql-common/createcluster.conf
apt-get install -y python{3.8,3.9,3.10} python{3.8,3.9,3.10}-dev python{3.8,3.9,3.10}-venv
apt-get install -y postgresql-{11,12,13,14,15,16} postgresql-server-dev-{11,12,13,14,15,16}
apt-get install -y python{3.8,3.9,3.10,3.11,3.12} python{3.8,3.9,3.10,3.11,3.12}-dev python{3.8,3.9,3.10,3.11,3.12}-venv
apt-get install -y postgresql-{11,12,13,14,15,16} postgresql-server-dev-{12,13,14,15,16}
username="$(< /dev/urandom tr -dc a-z | head -c${1:-32};echo;)"
password=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;)
Expand Down Expand Up @@ -68,7 +68,7 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script, privileged: true

$script = <<-SCRIPT
versions=(3.8 3.9 3.10)
versions=(3.8 3.9 3.10 3.11 3.12)
for version in "${versions[@]}"; do
python${version} -m venv venv${version}
source ~/venv${version}/bin/activate
Expand Down
16 changes: 8 additions & 8 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,35 @@ Vagrant
=======

The Vagrantfile can be used to setup a vagrant development environment. The vagrant environment has
python 3.8, 3.9 and 3.10 virtual environments and installations of postgresql 10, 11 and 12, 13 and 14.
python 3.8, 3.9, 3.10, 3.11 and 3.12 virtual environments and installations of postgresql 12, 13, 14, 15 and 16.

By default vagrant up will start a Virtualbox environment. The Vagrantfile will also work for libvirt, just prefix
``VAGRANT_DEFAULT_PROVIDER=libvirt`` to the ``vagrant up`` command.

Any combination of Python (3.8, 3.9 and 3.10) and Postgresql (10, 11, 12, 13 and 14)
Any combination of Python (3.8, 3.9, 3.10, 3.11 and 3.12) and Postgresql (12, 13, 14, 15 and 16)

Bring up vagrant instance and connect via ssh::

vagrant up
vagrant ssh
vagrant@ubuntu2004:~$ cd /vagrant

Test with Python 3.8 and Postgresql 11::
Test with Python 3.8 and Postgresql 12::

vagrant@ubuntu2004:~$ source ~/venv3.8/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=11 make unittest
vagrant@ubuntu2004:~$ PG_VERSION=12 make unittest
vagrant@ubuntu2004:~$ deactivate

Test with Python 3.9 and Postgresql 12::
Test with Python 3.9 and Postgresql 13::

vagrant@ubuntu2004:~$ source ~/venv3.9/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=12 make unittest
vagrant@ubuntu2004:~$ PG_VERSION=13 make unittest
vagrant@ubuntu2004:~$ deactivate

Test with Python 3.10 and Postgresql 13::
Test with Python 3.10 and Postgresql 14::

vagrant@ubuntu2004:~$ source ~/venv3.10/bin/activate
vagrant@ubuntu2004:~$ PG_VERSION=13 make unittest
vagrant@ubuntu2004:~$ PG_VERSION=14 make unittest
vagrant@ubuntu2004:~$ deactivate

And so on
Expand Down
4 changes: 2 additions & 2 deletions pghoard/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import time
from contextlib import suppress
from dataclasses import dataclass, field
from distutils.version import LooseVersion
from distutils.version import Version
from pathlib import Path
from queue import Queue
from threading import Thread
Expand Down Expand Up @@ -415,7 +415,7 @@ def extract_pghoard_delta_metadata(fileobj: FileLike) -> Dict[str, Any]:


def get_pg_wal_directory(config):
if LooseVersion(config["pg_data_directory_version"]) >= "10":
if Version(config["pg_data_directory_version"]) >= "10":
return os.path.join(config["pg_data_directory"], "pg_wal")
return os.path.join(config["pg_data_directory"], "pg_xlog")

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers=[
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Database :: Database Engines/Servers",
"Topic :: Software Development :: Libraries",
]
Expand Down
4 changes: 2 additions & 2 deletions test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
import os
# pylint: disable=attribute-defined-outside-init
from distutils.version import LooseVersion
from distutils.version import Version
from shutil import rmtree
from tempfile import mkdtemp

Expand Down Expand Up @@ -84,7 +84,7 @@ def config_template(self, override=None):
"json_state_file_path": os.path.join(self.temp_dir, "state.json"),
"pg_basebackup_path": os.path.join(bindir, "pg_basebackup"),
}
if LooseVersion(ver) >= "10":
if Version(ver) >= "10":
config["backup_sites"][self.test_site]["pg_receivexlog_path"] = os.path.join(bindir, "pg_receivewal")
if override:
all_site_overrides = override.pop("backup_sites", None)
Expand Down
6 changes: 3 additions & 3 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import time
from contextlib import suppress
from dataclasses import dataclass
from distutils.version import LooseVersion
from distutils.version import Version
from pathlib import Path
from typing import Callable, Dict, Iterator, Optional, Sequence, Union
from unittest import SkipTest
Expand All @@ -35,7 +35,7 @@

logutil.configure_logging()

DEFAULT_PG_VERSIONS = ["16", "15", "14", "13", "12", "11", "10"]
DEFAULT_PG_VERSIONS = ["16", "15", "14", "13", "12"]


def port_is_listening(hostname: str, port: int, timeout: float = 0.5) -> bool:
Expand Down Expand Up @@ -255,7 +255,7 @@ def fixture_recovery_db(pg_version: str) -> Iterator[PGTester]:
"recovery_target_timeline = 'latest'",
"restore_command = 'false'",
]
if LooseVersion(pg.pgver) >= "12":
if Version(pg.pgver) >= "12":
with open(os.path.join(pg.pgdata, "standby.signal"), "w") as fp:
pass

Expand Down
4 changes: 2 additions & 2 deletions test/test_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import threading
import time
from collections import deque
from distutils.version import LooseVersion
from distutils.version import Version
from http.client import HTTPConnection
from queue import Queue
from unittest import mock
Expand Down Expand Up @@ -314,7 +314,7 @@ def write_dummy_wal(inc):
"recovery_target_timeline = 'latest'",
"restore_command = 'false'",
]
if LooseVersion(db.pgver) >= "12":
if Version(db.pgver) >= "12":
with open(os.path.join(db.pgdata, "standby.signal"), "w") as fp:
pass

Expand Down

0 comments on commit e7338aa

Please sign in to comment.