Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 170469d

Browse files
committed
enable asserts in test; more detailed info on isolation errors
1 parent 5e6e9fc commit 170469d

File tree

2 files changed

+53
-10
lines changed

2 files changed

+53
-10
lines changed

tests2/client2.py

+42-5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@ def __init__(self, dsns, n_accounts=100000):
5151
self.aggregates = {}
5252
self.initdb()
5353
self.running = True
54+
self.nodes_state_fields = ["id", "disabled", "disconnected", "catchUp", "slotLag",
55+
"avgTransDelay", "lastStatusChange", "oldestSnapshot", "SenderPid",
56+
"SenderStartTime ", "ReceiverPid", "ReceiverStartTime", "connStr"]
57+
self.oops = '''
58+
. . .
59+
\|/
60+
`--+--'
61+
/|\
62+
' | '
63+
|
64+
|
65+
,--'#`--.
66+
|#######|
67+
_.-'#######`-._
68+
,-'###############`-.
69+
,'#####################`,
70+
/#########################\
71+
|###########################|
72+
|#############################|
73+
|#############################|
74+
|#############################|
75+
|#############################|
76+
|###########################|
77+
\#########################/
78+
`.#####################,'
79+
`._###############_,'
80+
`--..#####..--'
81+
'''
5482

5583
def initdb(self):
5684
conn = psycopg2.connect(self.dsns[0])
@@ -94,14 +122,14 @@ def exec_tx(self, tx_block, aggname_prefix, conn_i):
94122
agg.start_tx()
95123
try:
96124
yield from cur.execute('commit')
97-
yield from tx_block(conn, cur)
125+
yield from tx_block(conn, cur, agg)
98126
agg.finish_tx('commit')
99127
except psycopg2.Error as e:
100128
agg.finish_tx(e.pgerror)
101129
print("We've count to infinity!")
102130

103131
@asyncio.coroutine
104-
def transfer_tx(self, conn, cur):
132+
def transfer_tx(self, conn, cur, agg):
105133
amount = 1
106134
# to avoid deadlocks:
107135
from_uid = random.randint(1, self.n_accounts - 2)
@@ -118,12 +146,21 @@ def transfer_tx(self, conn, cur):
118146
yield from cur.execute('commit')
119147

120148
@asyncio.coroutine
121-
def total_tx(self, conn, cur):
149+
def total_tx(self, conn, cur, agg):
122150
yield from cur.execute('select sum(amount) from bank_test')
123151
total = yield from cur.fetchone()
124152
if total[0] != 0:
125-
print('Isolation error, totel = ', total[0])
126-
self.isolation += 1
153+
agg.isolation += 1
154+
print(self.oops)
155+
print('Isolation error, total = ', total[0])
156+
yield from cur.execute('select * from mtm.get_nodes_state()')
157+
nodes_state = yield from cur.fetchall()
158+
for i, col in enumerate(self.nodes_state_fields):
159+
print("%17s" % col, end="\t")
160+
for j in range(3):
161+
print("%19s" % nodes_state[j][i], end="\t")
162+
print("\n")
163+
127164

128165
def run(self):
129166
# asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

tests2/test_recovery.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,33 @@ def test_node_partition(self):
4040
# clear tx history
4141
self.client.get_status()
4242

43-
for i in range(10):
43+
for i in range(3):
4444
print(i, datetime.datetime.now())
4545
time.sleep(3)
4646
aggs = self.client.get_status()
4747
MtmClient.print_aggregates(aggs)
48-
#self.assertTrue( aggs[0]['transfer']['finish']['Commit'] > 0 )
49-
#self.assertTrue( aggs[1]['transfer']['finish']['Commit'] > 0 )
50-
#self.assertTrue( 'Commit' not in aggs[2]['transfer']['finish'] )
48+
self.assertTrue( aggs['transfer_0']['finish']['commit'] > 0 )
49+
self.assertTrue( aggs['transfer_1']['finish']['commit'] > 0 )
50+
# self.assertTrue( aggs['transfer_2']['finish']['commit'] == 0 )
5151

5252
subprocess.check_call(['blockade','join'])
5353
print('### deblockade node3 ###')
5454

5555
# clear tx history
5656
self.client.get_status()
5757

58-
for i in range(30):
58+
for i in range(20):
5959
print(i, datetime.datetime.now())
6060
time.sleep(3)
6161
aggs = self.client.get_status()
6262
MtmClient.print_aggregates(aggs)
6363

64+
# check that during last aggregation all nodes were working
65+
self.assertTrue( aggs['transfer_0']['finish']['commit'] > 0 )
66+
self.assertTrue( aggs['transfer_1']['finish']['commit'] > 0 )
67+
self.assertTrue( aggs['transfer_2']['finish']['commit'] > 0 )
68+
69+
6470

6571
subprocess.check_call(['blockade','join'])
6672
print("Node3 joined back")

0 commit comments

Comments
 (0)