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

Commitae55833

Browse files
committed
Merge branch 'master' into no-port-for
2 parents85e9b4d +4024049 commitae55833

13 files changed

+101
-108
lines changed

‎.travis.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
sudo:required
1+
os:linux
2+
3+
dist:bionic
24

35
language:python
46

@@ -18,14 +20,15 @@ notifications:
1820
on_failure:always
1921

2022
env:
21-
-PYTHON_VERSION=2 PG_VERSION=10
22-
-PYTHON_VERSION=2 PG_VERSION=9.6
23-
-PYTHON_VERSION=2 PG_VERSION=9.5
24-
-PYTHON_VERSION=2 PG_VERSION=9.4
23+
-PYTHON_VERSION=3 PG_VERSION=14
2524
-PYTHON_VERSION=3 PG_VERSION=13
2625
-PYTHON_VERSION=3 PG_VERSION=12
2726
-PYTHON_VERSION=3 PG_VERSION=11
2827
-PYTHON_VERSION=3 PG_VERSION=10
29-
-PYTHON_VERSION=3 PG_VERSION=9.6
30-
-PYTHON_VERSION=3 PG_VERSION=9.5
31-
-PYTHON_VERSION=3 PG_VERSION=9.4
28+
# - PYTHON_VERSION=3 PG_VERSION=9.6
29+
# - PYTHON_VERSION=3 PG_VERSION=9.5
30+
# - PYTHON_VERSION=3 PG_VERSION=9.4
31+
# - PYTHON_VERSION=2 PG_VERSION=10
32+
# - PYTHON_VERSION=2 PG_VERSION=9.6
33+
# - PYTHON_VERSION=2 PG_VERSION=9.5
34+
# - PYTHON_VERSION=2 PG_VERSION=9.4

‎setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
readme=f.read()
2222

2323
setup(
24-
version='1.8.4',
24+
version='1.8.5',
2525
name='testgres',
2626
packages=['testgres'],
2727
description='Testing utility for PostgreSQL and its extensions',

‎testgres/backup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class NodeBackup(object):
2929
"""
3030
Smart object responsible for backups
3131
"""
32-
3332
@property
3433
deflog_file(self):
3534
returnos.path.join(self.base_dir,BACKUP_LOG_FILE)

‎testgres/cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def cached_initdb(data_dir, logfile=None, params=None):
2525
"""
2626
Perform initdb or use cached node files.
2727
"""
28-
2928
defcall_initdb(initdb_dir,log=None):
3029
try:
3130
_params= [get_bin_path("initdb"),"-D",initdb_dir,"-N"]

‎testgres/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class GlobalConfig(object):
4343

4444
_cached_initdb_dir=None
4545
""" underlying class attribute for cached_initdb_dir property """
46-
4746
@property
4847
defcached_initdb_dir(self):
4948
""" path to a temp directory for cached initdb. """

‎testgres/connection.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class NodeConnection(object):
2828
"""
2929
Transaction wrapper returned by Node
3030
"""
31-
3231
def__init__(self,
3332
node,
3433
dbname=None,
@@ -42,12 +41,11 @@ def __init__(self,
4241

4342
self._node=node
4443

45-
self._connection=pglib.connect(
46-
database=dbname,
47-
user=username,
48-
password=password,
49-
host=node.host,
50-
port=node.port)
44+
self._connection=pglib.connect(database=dbname,
45+
user=username,
46+
password=password,
47+
host=node.host,
48+
port=node.port)
5149

5250
self._connection.autocommit=autocommit
5351
self._cursor=self.connection.cursor()

‎testgres/decorators.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def method_decorator(decorator):
5050
"""
5151
Convert a function decorator into a method decorator.
5252
"""
53-
5453
def_dec(func):
5554
def_wrapper(self,*args,**kwargs):
5655
@decorator

‎testgres/logger.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class TestgresLogger(threading.Thread):
1010
"""
1111
Helper class to implement reading from log files.
1212
"""
13-
1413
def__init__(self,node_name,log_file_name):
1514
threading.Thread.__init__(self)
1615

‎testgres/node.py

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
importsubprocess
77
importtime
88

9-
fromcollectionsimportIterable
9+
try:
10+
fromcollections.abcimportIterable
11+
exceptImportError:
12+
fromcollectionsimportIterable
13+
1014
fromshutilimportrmtree
1115
fromsiximportraise_from,iteritems,text_type
1216
fromtempfileimportmkstemp,mkdtemp
@@ -91,7 +95,6 @@ class ProcessProxy(object):
9195
process: wrapped psutill.Process object
9296
ptype: instance of ProcessType
9397
"""
94-
9598
def__init__(self,process,ptype=None):
9699
self.process=process
97100
self.ptype=ptypeorProcessType.from_process(process)
@@ -196,7 +199,6 @@ def auxiliary_processes(self):
196199
Returns a list of auxiliary processes.
197200
Each process is represented by :class:`.ProcessProxy` object.
198201
"""
199-
200202
defis_aux(process):
201203
returnprocess.ptype!=ProcessType.Unknown
202204

@@ -430,10 +432,9 @@ def init(self, initdb_params=None, **kwargs):
430432
"""
431433

432434
# initialize this PostgreSQL node
433-
cached_initdb(
434-
data_dir=self.data_dir,
435-
logfile=self.utils_log_file,
436-
params=initdb_params)
435+
cached_initdb(data_dir=self.data_dir,
436+
logfile=self.utils_log_file,
437+
params=initdb_params)
437438

438439
# initialize default config files
439440
self.default_conf(**kwargs)
@@ -480,8 +481,8 @@ def default_conf(self,
480481
ifallow_streaming:
481482
# get auth method for host or local users
482483
defget_auth_method(t):
483-
returnnext((s.split()[-1]forsinlines
484-
ifs.startswith(t)),'trust')
484+
returnnext((s.split()[-1]
485+
forsinlinesifs.startswith(t)),'trust')
485486

486487
# get auth methods
487488
auth_local=get_auth_method('local')
@@ -760,12 +761,11 @@ def promote(self, dbname=None, username=None):
760761
ifself._pg_version<'10':
761762
check_query="SELECT pg_is_in_recovery()"
762763

763-
self.poll_query_until(
764-
query=check_query,
765-
expected=False,
766-
dbname=dbname,
767-
username=username,
768-
max_attempts=0)# infinite
764+
self.poll_query_until(query=check_query,
765+
expected=False,
766+
dbname=dbname,
767+
username=username,
768+
max_attempts=0)# infinite
769769

770770
# node becomes master itself
771771
self._master=None
@@ -884,11 +884,10 @@ def psql(self,
884884
psql_params.append(dbname)
885885

886886
# start psql process
887-
process=subprocess.Popen(
888-
psql_params,
889-
stdin=subprocess.PIPE,
890-
stdout=subprocess.PIPE,
891-
stderr=subprocess.PIPE)
887+
process=subprocess.Popen(psql_params,
888+
stdin=subprocess.PIPE,
889+
stdout=subprocess.PIPE,
890+
stderr=subprocess.PIPE)
892891

893892
# wait until it finishes and get stdout and stderr
894893
out,err=process.communicate(input=input)
@@ -1043,11 +1042,10 @@ def poll_query_until(self,
10431042
attempts=0
10441043
whilemax_attempts==0orattempts<max_attempts:
10451044
try:
1046-
res=self.execute(
1047-
dbname=dbname,
1048-
query=query,
1049-
username=username,
1050-
commit=commit)
1045+
res=self.execute(dbname=dbname,
1046+
query=query,
1047+
username=username,
1048+
commit=commit)
10511049

10521050
ifexpectedisNoneandresisNone:
10531051
return# done
@@ -1165,8 +1163,8 @@ def set_synchronous_standbys(self, standbys):
11651163
standbys=First(1,standbys)
11661164
else:
11671165
ifisinstance(standbys,Iterable):
1168-
standbys=u", ".join(
1169-
u"\"{}\"".format(r.name)forrinstandbys)
1166+
standbys=u", ".join(u"\"{}\"".format(r.name)
1167+
forrinstandbys)
11701168
else:
11711169
raiseTestgresException("Feature isn't supported in "
11721170
"Postgres 9.5 and below")
@@ -1195,11 +1193,10 @@ def catchup(self, dbname=None, username=None):
11951193
username=username)[0][0]# yapf: disable
11961194

11971195
# wait until this LSN reaches replica
1198-
self.poll_query_until(
1199-
query=wait_lsn.format(lsn),
1200-
dbname=dbname,
1201-
username=username,
1202-
max_attempts=0)# infinite
1196+
self.poll_query_until(query=wait_lsn.format(lsn),
1197+
dbname=dbname,
1198+
username=username,
1199+
max_attempts=0)# infinite
12031200
exceptExceptionase:
12041201
raise_from(CatchUpException("Failed to catch up",poll_lsn),e)
12051202

@@ -1215,7 +1212,11 @@ def publish(self, name, **kwargs):
12151212
"""
12161213
returnPublication(name=name,node=self,**kwargs)
12171214

1218-
defsubscribe(self,publication,name,dbname=None,username=None,
1215+
defsubscribe(self,
1216+
publication,
1217+
name,
1218+
dbname=None,
1219+
username=None,
12191220
**params):
12201221
"""
12211222
Create subscription for logical replication

‎testgres/pubsub.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ def drop(self, dbname=None, username=None):
7777
"""
7878
Drop publication
7979
"""
80-
self.node.execute(
81-
"drop publication {}".format(self.name),
82-
dbname=dbname,
83-
username=username)
80+
self.node.execute("drop publication {}".format(self.name),
81+
dbname=dbname,
82+
username=username)
8483

8584
defadd_tables(self,tables,dbname=None,username=None):
8685
"""
@@ -94,10 +93,9 @@ def add_tables(self, tables, dbname=None, username=None):
9493
raiseValueError("Tables list is empty")
9594

9695
query="alter publication {} add table {}"
97-
self.node.execute(
98-
query.format(self.name,", ".join(tables)),
99-
dbname=dbnameorself.dbname,
100-
username=usernameorself.username)
96+
self.node.execute(query.format(self.name,", ".join(tables)),
97+
dbname=dbnameorself.dbname,
98+
username=usernameorself.username)
10199

102100

103101
classSubscription(object):
@@ -165,19 +163,17 @@ def refresh(self, copy_data=True, dbname=None, username=None):
165163
Disables the running subscription.
166164
"""
167165
query="alter subscription {} refresh publication with (copy_data={})"
168-
self.node.execute(
169-
query.format(self.name,copy_data),
170-
dbname=dbname,
171-
username=username)
166+
self.node.execute(query.format(self.name,copy_data),
167+
dbname=dbname,
168+
username=username)
172169

173170
defdrop(self,dbname=None,username=None):
174171
"""
175172
Drops subscription
176173
"""
177-
self.node.execute(
178-
"drop subscription {}".format(self.name),
179-
dbname=dbname,
180-
username=username)
174+
self.node.execute("drop subscription {}".format(self.name),
175+
dbname=dbname,
176+
username=username)
181177

182178
defcatchup(self,username=None):
183179
"""
@@ -191,7 +187,9 @@ def catchup(self, username=None):
191187
dbname=None,
192188
username=None)[0][0]# yapf: disable
193189
# create dummy xact, as LR replicates only on commit.
194-
self.pub.node.execute(query="select txid_current()",dbname=None,username=None)
190+
self.pub.node.execute(query="select txid_current()",
191+
dbname=None,
192+
username=None)
195193
query="""
196194
select '{}'::pg_lsn - replay_lsn <= 0
197195
from pg_catalog.pg_stat_replication where application_name = '{}'

‎testgres/standby.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ class First:
1616
standbys (:obj:`list` of :class:`.PostgresNode`): the list of standby
1717
nodes
1818
"""
19-
2019
def__init__(self,sync_num,standbys):
2120
self.sync_num=sync_num
2221
self.standbys=standbys
2322

2423
def__str__(self):
25-
returnu"{} ({})".format(self.sync_num,u", ".join(
26-
u"\"{}\"".format(r.name)forrinself.standbys))
24+
returnu"{} ({})".format(
25+
self.sync_num,
26+
u", ".join(u"\"{}\"".format(r.name)forrinself.standbys))
2727

2828

2929
@six.python_2_unicode_compatible
@@ -39,11 +39,11 @@ class Any:
3939
standbys (:obj:`list` of :class:`.PostgresNode`): the list of standby
4040
nodes
4141
"""
42-
4342
def__init__(self,sync_num,standbys):
4443
self.sync_num=sync_num
4544
self.standbys=standbys
4645

4746
def__str__(self):
48-
returnu"ANY {} ({})".format(self.sync_num,u", ".join(
49-
u"\"{}\"".format(r.name)forrinself.standbys))
47+
returnu"ANY {} ({})".format(
48+
self.sync_num,
49+
u", ".join(u"\"{}\"".format(r.name)forrinself.standbys))

‎testgres/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ def execute_utility(args, logfile=None):
7070
process=subprocess.Popen(
7171
args,# util + params
7272
stdout=buf,
73-
stderr=subprocess.STDOUT
74-
)
73+
stderr=subprocess.STDOUT)
7574
process.communicate()
7675

7776
# get result
@@ -113,8 +112,10 @@ def execute_utility(args, logfile=None):
113112
exit_code=process.returncode
114113
ifexit_code:
115114
message='Utility exited with non-zero code'
116-
raiseExecUtilException(
117-
message=message,command=command,exit_code=exit_code,out=out)
115+
raiseExecUtilException(message=message,
116+
command=command,
117+
exit_code=exit_code,
118+
out=out)
118119

119120
returnout
120121

@@ -153,7 +154,6 @@ def get_pg_config(pg_config_path=None):
153154
Return output of pg_config (provided that it is installed).
154155
NOTE: this fuction caches the result by default (see GlobalConfig).
155156
"""
156-
157157
defcache_pg_config_data(cmd):
158158
# execute pg_config and get the output
159159
out=subprocess.check_output([cmd]).decode('utf-8')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp