Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support rel14#63

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kulaginm merged 4 commits intomasterfromsupport_rel14
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
19 changes: 11 additions & 8 deletions.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
sudo: required
os: linux

dist: bionic

language: python

Expand All@@ -18,14 +20,15 @@ notifications:
on_failure: always

env:
- 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
- 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=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
1 change: 0 additions & 1 deletiontestgres/backup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@ class NodeBackup(object):
"""
Smart object responsible for backups
"""

@property
def log_file(self):
return os.path.join(self.base_dir, BACKUP_LOG_FILE)
Expand Down
1 change: 0 additions & 1 deletiontestgres/cache.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@ def cached_initdb(data_dir, logfile=None, params=None):
"""
Perform initdb or use cached node files.
"""

def call_initdb(initdb_dir, log=None):
try:
_params = [get_bin_path("initdb"), "-D", initdb_dir, "-N"]
Expand Down
1 change: 0 additions & 1 deletiontestgres/config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,7 +43,6 @@ class GlobalConfig(object):

_cached_initdb_dir = None
""" underlying class attribute for cached_initdb_dir property """

@property
def cached_initdb_dir(self):
""" path to a temp directory for cached initdb. """
Expand Down
12 changes: 5 additions & 7 deletionstestgres/connection.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,6 @@ class NodeConnection(object):
"""
Transaction wrapper returned by Node
"""

def __init__(self,
node,
dbname=None,
Expand All@@ -42,12 +41,11 @@ def __init__(self,

self._node = node

self._connection = pglib.connect(
database=dbname,
user=username,
password=password,
host=node.host,
port=node.port)
self._connection = pglib.connect(database=dbname,
user=username,
password=password,
host=node.host,
port=node.port)

self._connection.autocommit = autocommit
self._cursor = self.connection.cursor()
Expand Down
1 change: 0 additions & 1 deletiontestgres/decorators.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,7 +50,6 @@ def method_decorator(decorator):
"""
Convert a function decorator into a method decorator.
"""

def _dec(func):
def _wrapper(self, *args, **kwargs):
@decorator
Expand Down
1 change: 0 additions & 1 deletiontestgres/logger.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,6 @@ class TestgresLogger(threading.Thread):
"""
Helper class to implement reading from log files.
"""

def __init__(self, node_name, log_file_name):
threading.Thread.__init__(self)

Expand Down
61 changes: 29 additions & 32 deletionstestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -91,7 +91,6 @@ class ProcessProxy(object):
process: wrapped psutill.Process object
ptype: instance of ProcessType
"""

def __init__(self, process, ptype=None):
self.process = process
self.ptype = ptype or ProcessType.from_process(process)
Expand DownExpand Up@@ -196,7 +195,6 @@ def auxiliary_processes(self):
Returns a list of auxiliary processes.
Each process is represented by :class:`.ProcessProxy` object.
"""

def is_aux(process):
return process.ptype != ProcessType.Unknown

Expand DownExpand Up@@ -430,10 +428,9 @@ def init(self, initdb_params=None, **kwargs):
"""

# initialize this PostgreSQL node
cached_initdb(
data_dir=self.data_dir,
logfile=self.utils_log_file,
params=initdb_params)
cached_initdb(data_dir=self.data_dir,
logfile=self.utils_log_file,
params=initdb_params)

# initialize default config files
self.default_conf(**kwargs)
Expand DownExpand Up@@ -480,8 +477,8 @@ def default_conf(self,
if allow_streaming:
# get auth method for host or local users
def get_auth_method(t):
return next((s.split()[-1] for s in lines
if s.startswith(t)), 'trust')
return next((s.split()[-1]
for s in linesif s.startswith(t)), 'trust')

# get auth methods
auth_local = get_auth_method('local')
Expand DownExpand Up@@ -760,12 +757,11 @@ def promote(self, dbname=None, username=None):
if self._pg_version < '10':
check_query = "SELECT pg_is_in_recovery()"

self.poll_query_until(
query=check_query,
expected=False,
dbname=dbname,
username=username,
max_attempts=0) # infinite
self.poll_query_until(query=check_query,
expected=False,
dbname=dbname,
username=username,
max_attempts=0) # infinite

# node becomes master itself
self._master = None
Expand DownExpand Up@@ -884,11 +880,10 @@ def psql(self,
psql_params.append(dbname)

# start psql process
process = subprocess.Popen(
psql_params,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
process = subprocess.Popen(psql_params,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

# wait until it finishes and get stdout and stderr
out, err = process.communicate(input=input)
Expand DownExpand Up@@ -1043,11 +1038,10 @@ def poll_query_until(self,
attempts = 0
while max_attempts == 0 or attempts < max_attempts:
try:
res = self.execute(
dbname=dbname,
query=query,
username=username,
commit=commit)
res = self.execute(dbname=dbname,
query=query,
username=username,
commit=commit)

if expected is None and res is None:
return # done
Expand DownExpand Up@@ -1165,8 +1159,8 @@ def set_synchronous_standbys(self, standbys):
standbys = First(1, standbys)
else:
if isinstance(standbys, Iterable):
standbys = u", ".join(
u"\"{}\"".format(r.name) for r in standbys)
standbys = u", ".join(u"\"{}\"".format(r.name)
for r in standbys)
else:
raise TestgresException("Feature isn't supported in "
"Postgres 9.5 and below")
Expand DownExpand Up@@ -1195,11 +1189,10 @@ def catchup(self, dbname=None, username=None):
username=username)[0][0] # yapf: disable

# wait until this LSN reaches replica
self.poll_query_until(
query=wait_lsn.format(lsn),
dbname=dbname,
username=username,
max_attempts=0) # infinite
self.poll_query_until(query=wait_lsn.format(lsn),
dbname=dbname,
username=username,
max_attempts=0) # infinite
except Exception as e:
raise_from(CatchUpException("Failed to catch up", poll_lsn), e)

Expand All@@ -1215,7 +1208,11 @@ def publish(self, name, **kwargs):
"""
return Publication(name=name, node=self, **kwargs)

def subscribe(self, publication, name, dbname=None, username=None,
def subscribe(self,
publication,
name,
dbname=None,
username=None,
**params):
"""
Create subscription for logical replication
Expand Down
32 changes: 15 additions & 17 deletionstestgres/pubsub.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,10 +77,9 @@ def drop(self, dbname=None, username=None):
"""
Drop publication
"""
self.node.execute(
"drop publication {}".format(self.name),
dbname=dbname,
username=username)
self.node.execute("drop publication {}".format(self.name),
dbname=dbname,
username=username)

def add_tables(self, tables, dbname=None, username=None):
"""
Expand All@@ -94,10 +93,9 @@ def add_tables(self, tables, dbname=None, username=None):
raise ValueError("Tables list is empty")

query = "alter publication {} add table {}"
self.node.execute(
query.format(self.name, ", ".join(tables)),
dbname=dbname or self.dbname,
username=username or self.username)
self.node.execute(query.format(self.name, ", ".join(tables)),
dbname=dbname or self.dbname,
username=username or self.username)


class Subscription(object):
Expand DownExpand Up@@ -165,19 +163,17 @@ def refresh(self, copy_data=True, dbname=None, username=None):
Disables the running subscription.
"""
query = "alter subscription {} refresh publication with (copy_data={})"
self.node.execute(
query.format(self.name, copy_data),
dbname=dbname,
username=username)
self.node.execute(query.format(self.name, copy_data),
dbname=dbname,
username=username)

def drop(self, dbname=None, username=None):
"""
Drops subscription
"""
self.node.execute(
"drop subscription {}".format(self.name),
dbname=dbname,
username=username)
self.node.execute("drop subscription {}".format(self.name),
dbname=dbname,
username=username)

def catchup(self, username=None):
"""
Expand All@@ -191,7 +187,9 @@ def catchup(self, username=None):
dbname=None,
username=None)[0][0] # yapf: disable
# create dummy xact, as LR replicates only on commit.
self.pub.node.execute(query="select txid_current()", dbname=None, username=None)
self.pub.node.execute(query="select txid_current()",
dbname=None,
username=None)
query = """
select '{}'::pg_lsn - replay_lsn <= 0
from pg_catalog.pg_stat_replication where application_name = '{}'
Expand Down
12 changes: 6 additions & 6 deletionstestgres/standby.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,14 +16,14 @@ class First:
standbys (:obj:`list` of :class:`.PostgresNode`): the list of standby
nodes
"""

def __init__(self, sync_num, standbys):
self.sync_num = sync_num
self.standbys = standbys

def __str__(self):
return u"{} ({})".format(self.sync_num, u", ".join(
u"\"{}\"".format(r.name) for r in self.standbys))
return u"{} ({})".format(
self.sync_num,
u", ".join(u"\"{}\"".format(r.name) for r in self.standbys))


@six.python_2_unicode_compatible
Expand All@@ -39,11 +39,11 @@ class Any:
standbys (:obj:`list` of :class:`.PostgresNode`): the list of standby
nodes
"""

def __init__(self, sync_num, standbys):
self.sync_num = sync_num
self.standbys = standbys

def __str__(self):
return u"ANY {} ({})".format(self.sync_num, u", ".join(
u"\"{}\"".format(r.name) for r in self.standbys))
return u"ANY {} ({})".format(
self.sync_num,
u", ".join(u"\"{}\"".format(r.name) for r in self.standbys))
10 changes: 5 additions & 5 deletionstestgres/utils.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,7 @@ def execute_utility(args, logfile=None):
process = subprocess.Popen(
args, # util + params
stdout=buf,
stderr=subprocess.STDOUT
)
stderr=subprocess.STDOUT)
process.communicate()

# get result
Expand DownExpand Up@@ -110,8 +109,10 @@ def execute_utility(args, logfile=None):
exit_code = process.returncode
if exit_code:
message = 'Utility exited with non-zero code'
raise ExecUtilException(
message=message, command=command, exit_code=exit_code, out=out)
raise ExecUtilException(message=message,
command=command,
exit_code=exit_code,
out=out)

return out

Expand DownExpand Up@@ -150,7 +151,6 @@ def get_pg_config(pg_config_path=None):
Return output of pg_config (provided that it is installed).
NOTE: this fuction caches the result by default (see GlobalConfig).
"""

def cache_pg_config_data(cmd):
# execute pg_config and get the output
out = subprocess.check_output([cmd]).decode('utf-8')
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp