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

Commitf0ed19f

Browse files
committed
check data identity in tests
1 parentc94bbba commitf0ed19f

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

‎tests2/lib/bank_client.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,24 @@ def initdb(self):
109109
cur.close()
110110
conn.close()
111111

112+
defis_data_identic(self):
113+
hashes=set()
114+
115+
fordsninself.dsns:
116+
con=psycopg2.connect(dsn)
117+
cur=con.cursor()
118+
cur.execute("""
119+
select
120+
md5('(' || string_agg(uid::text || ', ' || amount::text , '),(') || ')')
121+
from
122+
(select * from bank_test order by uid) t;""")
123+
hashes.add(cur.fetchone()[0])
124+
cur.close()
125+
con.close()
126+
127+
print(hashes)
128+
return (len(hashes)==1)
129+
112130
@asyncio.coroutine
113131
defstatus(self):
114132
whileself.running:
@@ -168,7 +186,7 @@ def exec_tx(self, tx_block, aggname_prefix, conn_i):
168186
yieldfromasyncio.sleep(0.01)
169187
exceptBaseExceptionase:
170188
agg.finish_tx(str(e).strip())
171-
print('Catch exception ',e)
189+
print('Catch exception ',str(e).strip())
172190
# Give evloop some free time.
173191
# In case of continuous excetions we can loop here without returning
174192
# back to event loop and block it

‎tests2/test_recovery.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def performFailure(self, failure):
6868
classRecoveryTest(unittest.TestCase,TestHelper):
6969

7070
@classmethod
71-
defsetUpClass(self):
71+
defsetUpClass(cls):
7272
subprocess.check_call(['docker-compose','up',
7373
'--force-recreate',
7474
'--build',
@@ -77,17 +77,21 @@ def setUpClass(self):
7777
# XXX: add normal wait here
7878
time.sleep(TEST_SETUP_TIME)
7979

80-
self.client=MtmClient([
80+
cls.client=MtmClient([
8181
"dbname=regression user=postgres host=127.0.0.1 port=15432",
8282
"dbname=regression user=postgres host=127.0.0.1 port=15433",
8383
"dbname=regression user=postgres host=127.0.0.1 port=15434"
8484
],n_accounts=1000)
85-
self.client.bgrun()
85+
cls.client.bgrun()
8686

8787
@classmethod
88-
deftearDownClass(self):
88+
deftearDownClass(cls):
8989
print('tearDown')
90-
self.client.stop()
90+
cls.client.stop()
91+
92+
ifnotcls.client.is_data_identic():
93+
raiseAssertionError('Different data on nodes')
94+
9195
# XXX: check nodes data identity here
9296
# subprocess.check_call(['docker-compose','down'])
9397

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp