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

Commit3f9c618

Browse files
committed
Merge with master
2 parents0611d10 +7847380 commit3f9c618

File tree

4 files changed

+39
-19
lines changed

4 files changed

+39
-19
lines changed

‎testgres/node.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ def set_auto_conf(self, options, config='postgresql.auto.conf', rm_options={}):
16411641

16421642
self.os_ops.write(path,auto_conf,truncate=True)
16431643

1644-
defupgrade_from(self,old_node):
1644+
defupgrade_from(self,old_node,options=None):
16451645
"""
16461646
Upgrade this node from an old node using pg_upgrade.
16471647
@@ -1654,6 +1654,9 @@ def upgrade_from(self, old_node):
16541654
ifnotos.path.exists(self.data_dir):
16551655
self.init()
16561656

1657+
ifnotoptions:
1658+
options= []
1659+
16571660
pg_upgrade_binary=self._get_bin_path("pg_upgrade")
16581661

16591662
ifnotos.path.exists(pg_upgrade_binary):
@@ -1668,6 +1671,7 @@ def upgrade_from(self, old_node):
16681671
"--old-port",str(old_node.port),
16691672
"--new-port",str(self.port),
16701673
]
1674+
upgrade_command+=options
16711675

16721676
returnself.os_ops.exec_command(upgrade_command)
16731677

‎testgres/operations/remote_ops.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ def __init__(self, conn_params: ConnectionParams):
4848
super().__init__(conn_params.username)
4949
self.conn_params=conn_params
5050
self.host=conn_params.host
51-
self.ssh_key=conn_params.ssh_key
5251
self.port=conn_params.port
52+
self.ssh_key=conn_params.ssh_key
5353
self.ssh_cmd= ["-o StrictHostKeyChecking=no"]
54+
self.ssh_args= []
5455
ifself.ssh_key:
55-
self.ssh_cmd+= ["-i",self.ssh_key]
56+
self.ssh_args+= ["-i",self.ssh_key]
5657
ifself.port:
57-
self.ssh_cmd+= ["-p",self.port]
58+
self.ssh_args+= ["-p",self.port]
5859
self.remote=True
5960
self.username=conn_params.usernameorself.get_user()
6061
self.tunnel_process=None
@@ -113,9 +114,9 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
113114
"""
114115
ssh_cmd= []
115116
ifisinstance(cmd,str):
116-
ssh_cmd= ['ssh',f"{self.username}@{self.host}"]+self.ssh_cmd+ [cmd]
117+
ssh_cmd= ['ssh',f"{self.username}@{self.host}"]+self.ssh_args+ [cmd]
117118
elifisinstance(cmd,list):
118-
ssh_cmd= ['ssh',f"{self.username}@{self.host}"]+self.ssh_cmd+cmd
119+
ssh_cmd= ['ssh',f"{self.username}@{self.host}"]+self.ssh_args+cmd
119120
process=subprocess.Popen(ssh_cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
120121
ifget_process:
121122
returnprocess
@@ -264,9 +265,9 @@ def mkdtemp(self, prefix=None):
264265
- prefix (str): The prefix of the temporary directory name.
265266
"""
266267
ifprefix:
267-
command= ["ssh"+f"{self.username}@{self.host}"]+self.ssh_cmd+ [f"mktemp -d{prefix}XXXXX"]
268+
command= ["ssh"]+self.ssh_args+ [f"{self.username}@{self.host}",f"mktemp -d{prefix}XXXXX"]
268269
else:
269-
command= ["ssh",f"{self.username}@{self.host}"]+self.ssh_cmd+ ["mktemp -d"]
270+
command= ["ssh"]+self.ssh_args+ [f"{self.username}@{self.host}","mktemp -d"]
270271

271272
result=subprocess.run(command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,text=True)
272273

@@ -309,11 +310,11 @@ def write(self, filename, data, truncate=False, binary=False, read_and_write=Fal
309310
mode="r+b"ifbinaryelse"r+"
310311

311312
withtempfile.NamedTemporaryFile(mode=mode,delete=False)astmp_file:
312-
#Because inscpwe set up port using -P option
313-
scp_ssh_cmd= ['-P'ifx=='-p'elsexforxinself.ssh_cmd]
313+
#Forscpthe port is specified by a "-P" option
314+
scp_args= ['-P'ifx=='-p'elsexforxinself.ssh_args]
314315

315316
ifnottruncate:
316-
scp_cmd= ['scp']+scp_ssh_cmd+ [f"{self.username}@{self.host}:{filename}",tmp_file.name]
317+
scp_cmd= ['scp']+scp_args+ [f"{self.username}@{self.host}:{filename}",tmp_file.name]
317318
subprocess.run(scp_cmd,check=False)# The file might not exist yet
318319
tmp_file.seek(0,os.SEEK_END)
319320

@@ -329,11 +330,11 @@ def write(self, filename, data, truncate=False, binary=False, read_and_write=Fal
329330
tmp_file.write(data)
330331

331332
tmp_file.flush()
332-
scp_cmd= ['scp']+scp_ssh_cmd+ [tmp_file.name,f"{self.username}@{self.host}:{filename}"]
333+
scp_cmd= ['scp']+scp_args+ [tmp_file.name,f"{self.username}@{self.host}:{filename}"]
333334
subprocess.run(scp_cmd,check=True)
334335

335336
remote_directory=os.path.dirname(filename)
336-
mkdir_cmd= ['ssh',f"{self.username}@{self.host}"]+self.ssh_cmd+ [f"mkdir -p{remote_directory}"]
337+
mkdir_cmd= ['ssh']+self.ssh_args+ [f"{self.username}@{self.host}",f"mkdir -p{remote_directory}"]
337338
subprocess.run(mkdir_cmd,check=True)
338339

339340
os.remove(tmp_file.name)
@@ -398,7 +399,7 @@ def get_pid(self):
398399
returnint(self.exec_command("echo $$",encoding=get_default_encoding()))
399400

400401
defget_process_children(self,pid):
401-
command= ["ssh",f"{self.username}@{self.host}"]+self.ssh_cmd+ [f"pgrep -P{pid}"]
402+
command= ["ssh"]+self.ssh_args+ [f"{self.username}@{self.host}",f"pgrep -P{pid}"]
402403

403404
result=subprocess.run(command,stdout=subprocess.PIPE,stderr=subprocess.PIPE,text=True)
404405

‎testgres/plugins/pg_probackup2/pg_probackup2/app.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(self, test_class: unittest.TestCase,
5656
self.verbose=init_params.verbose
5757
self.archive_compress=init_params.archive_compress
5858
self.test_class.output=None
59+
self.execution_time=None
5960

6061
defrun(self,command,gdb=False,old_binary=False,return_id=True,env=None,
6162
skip_log_directory=False,expect_error=False,use_backup_dir=True):
@@ -113,16 +114,17 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
113114
cmdline= ['gdbserver']+ ['localhost:'+str(gdb_port)]+cmdline
114115
print("pg_probackup gdb suspended, waiting gdb connection on localhost:{0}".format(gdb_port))
115116

117+
start_time=time.time()
116118
self.test_class.output=subprocess.check_output(
117119
cmdline,
118120
stderr=subprocess.STDOUT,
119121
env=env
120122
).decode('utf-8',errors='replace')
123+
end_time=time.time()
124+
self.execution_time=end_time-start_time
125+
121126
ifcommand[0]=='backup'andreturn_id:
122-
# return backup ID
123-
forlineinself.test_class.output.splitlines():
124-
if'INFO: Backup'and'completed'inline:
125-
result=line.split()[2]
127+
result=self.get_backup_id()
126128
else:
127129
result=self.test_class.output
128130
ifexpect_errorisTrue:
@@ -139,6 +141,19 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
139141
else:
140142
raiseProbackupException(self.test_class.output,self.test_class.cmd)
141143

144+
defget_backup_id(self):
145+
ifinit_params.major_version>2:
146+
pattern=re.compile(r"Backup (.*) completed successfully.")
147+
forlineinself.test_class.output.splitlines():
148+
match=pattern.search(line)
149+
ifmatch:
150+
returnmatch.group(1)
151+
else:
152+
forlineinself.test_class.output.splitlines():
153+
if'INFO: Backup'and'completed'inline:
154+
returnline.split()[2]
155+
returnNone
156+
142157
definit(self,options=None,old_binary=False,skip_log_directory=False,expect_error=False,use_backup_dir=True):
143158
ifoptionsisNone:
144159
options= []

‎testgres/plugins/pg_probackup2/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
fromdistutils.coreimportsetup
55

66
setup(
7-
version='0.0.2',
7+
version='0.0.3',
88
name='testgres_pg_probackup2',
99
packages=['pg_probackup2','pg_probackup2.storage'],
1010
description='Plugin for testgres that manages pg_probackup2',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp