Skip to content

[PBCKP-289] fix distutils deprecation warnings #71

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

Merged
merged 2 commits into from
Oct 4, 2022
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
18 changes: 9 additions & 9 deletions testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def _create_recovery_conf(self, username, slot=None):
"primary_conninfo='{}'\n"
).format(options_string(**conninfo)) # yapf: disable
# Since 12 recovery.conf had disappeared
if self.version >= '12':
if self.version >= PgVer('12'):
signal_name = os.path.join(self.data_dir, "standby.signal")
# cross-python touch(). It is vulnerable to races, but who cares?
with open(signal_name, 'a'):
Expand Down Expand Up @@ -371,7 +371,7 @@ def _create_recovery_conf(self, username, slot=None):

line += "primary_slot_name={}\n".format(slot)

if self.version >= '12':
if self.version >= PgVer('12'):
self.append_conf(line=line)
else:
self.append_conf(filename=RECOVERY_CONF_FILE, line=line)
Expand Down Expand Up @@ -517,9 +517,9 @@ def get_auth_method(t):
# binary replication
if allow_streaming:
# select a proper wal_level for PostgreSQL
wal_level = 'replica' if self._pg_version >= '9.6' else 'hot_standby'
wal_level = 'replica' if self._pg_version >= PgVer('9.6') else 'hot_standby'

if self._pg_version < '13':
if self._pg_version < PgVer('13'):
self.append_conf(hot_standby=True,
wal_keep_segments=WAL_KEEP_SEGMENTS,
wal_level=wal_level) # yapf: disable
Expand All @@ -530,7 +530,7 @@ def get_auth_method(t):

# logical replication
if allow_logical:
if self._pg_version < '10':
if self._pg_version < PgVer('10'):
raise InitNodeException("Logical replication is only "
"available on PostgreSQL 10 and newer")

Expand Down Expand Up @@ -616,7 +616,7 @@ def get_control_data(self):

# this one is tricky (blame PG 9.4)
_params = [get_bin_path("pg_controldata")]
_params += ["-D"] if self._pg_version >= '9.5' else []
_params += ["-D"] if self._pg_version >= PgVer('9.5') else []
_params += [self.data_dir]

data = execute_utility(_params, self.utils_log_file)
Expand Down Expand Up @@ -758,7 +758,7 @@ def promote(self, dbname=None, username=None):

# for versions below 10 `promote` is asynchronous so we need to wait
# until it actually becomes writable
if self._pg_version < '10':
if self._pg_version < PgVer('10'):
check_query = "SELECT pg_is_in_recovery()"

self.poll_query_until(query=check_query,
Expand Down Expand Up @@ -1158,7 +1158,7 @@ def set_synchronous_standbys(self, standbys):
master.restart()

"""
if self._pg_version >= '9.6':
if self._pg_version >= PgVer('9.6'):
if isinstance(standbys, Iterable):
standbys = First(1, standbys)
else:
Expand All @@ -1179,7 +1179,7 @@ def catchup(self, dbname=None, username=None):
if not self.master:
raise TestgresException("Node doesn't have a master")

if self._pg_version >= '10':
if self._pg_version >= PgVer('10'):
poll_lsn = "select pg_catalog.pg_current_wal_lsn()::text"
wait_lsn = "select pg_catalog.pg_last_wal_replay_lsn() >= '{}'::pg_lsn"
else:
Expand Down
4 changes: 2 additions & 2 deletions testgres/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import tempfile

from contextlib import contextmanager
from distutils.version import LooseVersion
from packaging.version import Version
from distutils.spawn import find_executable
from six import iteritems

Expand All @@ -25,7 +25,7 @@
bound_ports = set()

# re-export version type
PgVer = LooseVersion
PgVer = Version


def reserve_port():
Expand Down
10 changes: 8 additions & 2 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,16 +896,22 @@ def test_version_management(self):
a = PgVer('10.0')
b = PgVer('10')
c = PgVer('9.6.5')
d = PgVer('15.0')
e = PgVer('15rc1')
f = PgVer('15beta4')

self.assertTrue(a > b)
self.assertTrue(a == b)
self.assertTrue(b > c)
self.assertTrue(a > c)
self.assertTrue(d > e)
self.assertTrue(e > f)
self.assertTrue(d > f)

version = get_pg_version()
with get_new_node() as node:
self.assertTrue(isinstance(version, six.string_types))
self.assertTrue(isinstance(node.version, PgVer))
self.assertEqual(node.version, str(version))
self.assertEqual(node.version, PgVer(version))

def test_child_pids(self):
master_processes = [
Expand Down