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

Commit72e6d5d

Browse files
author
v.shepard
committed
PBCKP-152 fixed test_simple and test_remote
1 parent8c373e6 commit72e6d5d

File tree

15 files changed

+353
-304
lines changed

15 files changed

+353
-304
lines changed

‎setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"psutil",
1414
"packaging",
1515
"paramiko",
16-
"fabric"
16+
"fabric",
17+
"sshtunnel"
1718
]
1819

1920
# Add compatibility enum class

‎testgres/backup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self,
7777
"-D",data_dir,
7878
"-X",xlog_method.value
7979
]# yapf: disable
80-
execute_utility(_params,self.log_file,self.os_ops)
80+
execute_utility(_params,self.log_file)
8181

8282
def__enter__(self):
8383
returnself
@@ -139,7 +139,7 @@ def spawn_primary(self, name=None, destroy=True):
139139

140140
# Build a new PostgresNode
141141
NodeClass=self.original_node.__class__
142-
withclean_on_error(NodeClass(name=name,base_dir=base_dir))asnode:
142+
withclean_on_error(NodeClass(name=name,base_dir=base_dir,os_ops=self.original_node.os_ops))asnode:
143143

144144
# New nodes should always remove dir tree
145145
node._should_rm_dirs=True

‎testgres/cache.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ def cached_initdb(data_dir, logfile=None, params=None, os_ops: OsOperations = Lo
2626
"""
2727
Perform initdb or use cached node files.
2828
"""
29-
testgres_config.os_ops=os_ops
3029

31-
defcall_initdb(initdb_dir,log=None):
30+
defcall_initdb(initdb_dir,log=logfile):
3231
try:
3332
_params= [get_bin_path("initdb"),"-D",initdb_dir,"-N"]
34-
execute_utility(_params+ (paramsor []),log,os_ops)
33+
execute_utility(_params+ (paramsor []),log)
3534
exceptExecUtilExceptionase:
3635
raise_from(InitNodeException("Failed to run initdb"),e)
3736

@@ -62,7 +61,7 @@ def call_initdb(initdb_dir, log=None):
6261

6362
# XXX: build new WAL segment with our system id
6463
_params= [get_bin_path("pg_resetwal"),"-D",data_dir,"-f"]
65-
execute_utility(_params,logfile,os_ops=os_ops)
64+
execute_utility(_params,logfile)
6665

6766
exceptExecUtilExceptionase:
6867
msg="Failed to reset WAL for system id"

‎testgres/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
fromcontextlibimportcontextmanager
88

99
from .constsimportTMP_CACHE
10+
from .operations.os_opsimportOsOperations
1011
from .operations.local_opsimportLocalOperations
1112

1213

@@ -121,6 +122,11 @@ def copy(self):
121122

122123
returncopy.copy(self)
123124

125+
@staticmethod
126+
defset_os_ops(os_ops:OsOperations):
127+
testgres_config.os_ops=os_ops
128+
testgres_config.cached_initdb_dir=os_ops.mkdtemp(prefix=TMP_CACHE)
129+
124130

125131
# cached dirs to be removed
126132
cached_initdb_dirs=set()

‎testgres/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self,
3737

3838
# Set default arguments
3939
dbname=dbnameordefault_dbname()
40-
username=usernameordefault_username(node.os_ops)
40+
username=usernameordefault_username()
4141

4242
self._node=node
4343

‎testgres/defaults.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
importstruct
33
importuuid
44

5-
from .operations.local_opsimportLocalOperations
5+
from .configimporttestgres_configastconf
66

77

88
defdefault_dbname():
@@ -13,11 +13,11 @@ def default_dbname():
1313
return'postgres'
1414

1515

16-
defdefault_username(os_ops=LocalOperations()):
16+
defdefault_username():
1717
"""
1818
Return default username (current user).
1919
"""
20-
returnos_ops.get_user()
20+
returntconf.os_ops.get_user()
2121

2222

2323
defgenerate_app_name():
@@ -28,7 +28,7 @@ def generate_app_name():
2828
return'testgres-{}'.format(str(uuid.uuid4()))
2929

3030

31-
defgenerate_system_id(os_ops=LocalOperations()):
31+
defgenerate_system_id():
3232
"""
3333
Generate a new 64-bit unique system identifier for node.
3434
"""
@@ -43,7 +43,7 @@ def generate_system_id(os_ops=LocalOperations()):
4343
system_id=0
4444
system_id|= (secs<<32)
4545
system_id|= (usecs<<12)
46-
system_id|= (os_ops.get_pid()&0xFFF)
46+
system_id|= (tconf.os_ops.get_pid()&0xFFF)
4747

4848
# pack ULL in native byte order
4949
returnstruct.pack('=Q',system_id)

‎testgres/logger.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
importthreading
66
importtime
77

8-
98
# create logger
109
log=logging.getLogger('Testgres')
11-
log.setLevel(logging.DEBUG)
12-
# create console handler and set level to debug
13-
ch=logging.StreamHandler()
14-
ch.setLevel(logging.DEBUG)
15-
# create formatter
16-
formatter=logging.Formatter('\n%(asctime)s - %(name)s[%(levelname)s]: %(message)s')
17-
# add formatter to ch
18-
ch.setFormatter(formatter)
19-
# add ch to logger
20-
log.addHandler(ch)
10+
11+
ifnotlog.handlers:
12+
log.setLevel(logging.WARN)
13+
# create console handler and set level to debug
14+
ch=logging.StreamHandler()
15+
ch.setLevel(logging.WARN)
16+
# create formatter
17+
formatter=logging.Formatter('\n%(asctime)s - %(name)s[%(levelname)s]: %(message)s')
18+
# add formatter to ch
19+
ch.setFormatter(formatter)
20+
# add ch to logger
21+
log.addHandler(ch)
2122

2223

2324
classTestgresLogger(threading.Thread):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp