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

Commit513bc48

Browse files
committed
tests: remove psycopg2
1 parentb4442c5 commit513bc48

File tree

4 files changed

+46
-70
lines changed

4 files changed

+46
-70
lines changed

‎tests/Readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Run suit of basic simple tests:
3232
3333
Usage:
3434
pip install testgres
35-
pip install psycopg2
3635
export PG_CONFIG=/path/to/pg_config
3736
python -m unittest [-v] tests[.specific_module][.class.test]
3837
```

‎tests/delta.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
fromtestgresimportQueryException
66
importsubprocess
77
importtime
8+
fromthreadingimportThread
89

910

1011
module_name='delta'
@@ -522,48 +523,40 @@ def test_delta_vacuum_full(self):
522523
" as id from generate_series(0,1000000) i"
523524
)
524525

525-
# create async connection
526-
conn=self.get_async_connect(port=node.port)
526+
pg_connect=node.connect("postgres",autocommit=True)
527527

528-
self.wait(conn)
529-
530-
acurs=conn.cursor()
531-
acurs.execute("select pg_backend_pid()")
532-
533-
self.wait(conn)
534-
pid=acurs.fetchall()[0][0]
535-
print(pid)
536-
537-
gdb=self.gdb_attach(pid)
528+
gdb=self.gdb_attach(pg_connect.pid)
538529
gdb.set_breakpoint('reform_and_rewrite_tuple')
539530

540531
gdb.continue_execution_until_running()
541532

542-
acurs.execute("VACUUM FULL t_heap")
533+
process=Thread(
534+
target=pg_connect.execute,args=["VACUUM FULL t_heap"])
535+
process.start()
543536

544-
ifgdb.stopped_in_breakpoint():
545-
gdb.continue_execution_until_break(20)
537+
whilenotgdb.stopped_in_breakpoint:
538+
sleep(1)
546539

547-
self.backup_node(
548-
backup_dir,'node',node,
549-
backup_type='delta',options=['--stream']
550-
)
540+
gdb.continue_execution_until_break(20)
551541

552542
self.backup_node(
553543
backup_dir,'node',node,
554-
backup_type='delta',options=['--stream']
555-
)
544+
backup_type='delta',options=['--stream'])
545+
556546
ifself.paranoia:
557547
pgdata=self.pgdata_content(node.data_dir)
558548

549+
gdb.remove_all_breakpoints()
550+
gdb._execute('detach')
551+
process.join()
552+
559553
old_tablespace=self.get_tblspace_path(node,'somedata')
560554
new_tablespace=self.get_tblspace_path(node_restored,'somedata_new')
561555

562556
self.restore_node(
563557
backup_dir,'node',node_restored,
564558
options=["-j","4","-T","{0}={1}".format(
565-
old_tablespace,new_tablespace)]
566-
)
559+
old_tablespace,new_tablespace)])
567560

568561
# Physical comparison
569562
ifself.paranoia:
@@ -1125,7 +1118,6 @@ def test_delta_corruption_heal_via_ptrack_1(self):
11251118
backup_type="delta",
11261119
options=["-j","4","--stream",'--log-level-file=verbose'])
11271120

1128-
11291121
# open log file and check
11301122
withopen(os.path.join(backup_dir,'log','pg_probackup.log'))asf:
11311123
log_content=f.read()
@@ -1254,9 +1246,9 @@ def test_delta_nullified_heap_page_backup(self):
12541246
backup_dir,'node',node)
12551247

12561248
# Nullify some block in PostgreSQL
1257-
file=os.path.join(node.data_dir,file_path).replace("\\","/")
1249+
file=os.path.join(node.data_dir,file_path).replace("\\","/")
12581250
ifos.name=='nt':
1259-
file=file.replace("\\","/")
1251+
file=file.replace("\\","/")
12601252

12611253
withopen(file,'r+b',0)asf:
12621254
f.seek(8192)
@@ -1281,7 +1273,7 @@ def test_delta_nullified_heap_page_backup(self):
12811273
content)
12821274
self.assertNotIn(
12831275
"Skipping blknum: 1 in file: {0}".format(file),
1284-
content)
1276+
content)
12851277

12861278
# Restore DELTA backup
12871279
node_restored=self.make_simple_node(

‎tests/helpers/ptrack_helpers.py

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
importre
1010
importgetpass
1111
importselect
12-
importpsycopg2
1312
fromtimeimportsleep
1413
importre
1514
importjson
@@ -1408,31 +1407,6 @@ def compare_pgdata(self, original_pgdata, restored_pgdata):
14081407
fail=True
14091408
self.assertFalse(fail,error_message)
14101409

1411-
defget_async_connect(self,database=None,host=None,port=5432):
1412-
ifnotdatabase:
1413-
database='postgres'
1414-
ifnothost:
1415-
host='127.0.0.1'
1416-
1417-
returnpsycopg2.connect(
1418-
database='postgres',
1419-
host='127.0.0.1',
1420-
port=port,
1421-
async_=True
1422-
)
1423-
1424-
defwait(self,connection):
1425-
whileTrue:
1426-
state=connection.poll()
1427-
ifstate==psycopg2.extensions.POLL_OK:
1428-
break
1429-
elifstate==psycopg2.extensions.POLL_WRITE:
1430-
select.select([], [connection.fileno()], [])
1431-
elifstate==psycopg2.extensions.POLL_READ:
1432-
select.select([connection.fileno()], [], [])
1433-
else:
1434-
raisepsycopg2.OperationalError('poll() returned %s'%state)
1435-
14361410
defgdb_attach(self,pid):
14371411
returnGDBobj([str(pid)],self.verbose,attach=True)
14381412

@@ -1540,7 +1514,7 @@ def remove_all_breakpoints(self):
15401514
return
15411515

15421516
raiseGdbException(
1543-
'Failed toset breakpoint.\n Output:\n {0}'.format(result)
1517+
'Failed toremove breakpoints.\n Output:\n {0}'.format(result)
15441518
)
15451519

15461520
defrun_until_break(self):
@@ -1632,6 +1606,18 @@ def _execute(self, cmd, running=True):
16321606
self.proc.stdin.flush()
16331607
self.proc.stdin.write(cmd+'\n')
16341608
self.proc.stdin.flush()
1609+
sleep(1)
1610+
1611+
# look for command we just send
1612+
whileTrue:
1613+
line=self.proc.stdout.readline()
1614+
ifself.verbose:
1615+
print(repr(line))
1616+
1617+
ifcmdnotinline:
1618+
continue
1619+
else:
1620+
break
16351621

16361622
whileTrue:
16371623
line=self.proc.stdout.readline()

‎tests/ptrack.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importshutil
88
importsys
99
importtime
10+
fromthreadingimportThread
1011

1112

1213
module_name='ptrack'
@@ -213,27 +214,21 @@ def test_ptrack_vacuum_full(self):
213214
" as id from generate_series(0,1000000) i"
214215
)
215216

216-
# create async connection
217-
conn=self.get_async_connect(port=node.port)
217+
pg_connect=node.connect("postgres",autocommit=True)
218218

219-
self.wait(conn)
220-
221-
acurs=conn.cursor()
222-
acurs.execute("select pg_backend_pid()")
223-
224-
self.wait(conn)
225-
pid=acurs.fetchall()[0][0]
226-
print(pid)
227-
228-
gdb=self.gdb_attach(pid)
219+
gdb=self.gdb_attach(pg_connect.pid)
229220
gdb.set_breakpoint('reform_and_rewrite_tuple')
230221

231222
gdb.continue_execution_until_running()
232223

233-
acurs.execute("VACUUM FULL t_heap")
224+
process=Thread(
225+
target=pg_connect.execute,args=["VACUUM FULL t_heap"])
226+
process.start()
234227

235-
ifgdb.stopped_in_breakpoint():
236-
gdb.continue_execution_until_break(20)
228+
whilenotgdb.stopped_in_breakpoint:
229+
sleep(1)
230+
231+
gdb.continue_execution_until_break(20)
237232

238233
self.backup_node(
239234
backup_dir,'node',node,backup_type='ptrack')
@@ -244,6 +239,10 @@ def test_ptrack_vacuum_full(self):
244239
ifself.paranoia:
245240
pgdata=self.pgdata_content(node.data_dir)
246241

242+
gdb.remove_all_breakpoints()
243+
gdb._execute('detach')
244+
process.join()
245+
247246
old_tablespace=self.get_tblspace_path(node,'somedata')
248247
new_tablespace=self.get_tblspace_path(node_restored,'somedata_new')
249248

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp