Skip to content

Commit 59befec

Browse files
committed
Add actual asserts to mmts recovery test
1 parent 646f16c commit 59befec

File tree

5 files changed

+37
-84
lines changed

5 files changed

+37
-84
lines changed

contrib/mmts/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ USER postgres
3131
ENV CFLAGS -O0
3232
WORKDIR /pg
3333

34-
ENV REBUILD 2
34+
ENV REBUILD 5
3535

3636
RUN cd /pg && \
3737
git clone https://github.com/postgrespro/postgres_cluster.git --depth 1 && \

contrib/mmts/tests2/docker-entrypoint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ if [ "$1" = 'postgres' ]; then
6868
listen_addresses='*'
6969
max_prepared_transactions = 100
7070
synchronous_commit = off
71+
fsync = off
7172
wal_level = logical
7273
max_worker_processes = 30
7374
max_replication_slots = 10
7475
max_wal_senders = 10
7576
shared_preload_libraries = 'raftable,multimaster'
76-
default_transaction_isolation = 'repeatable read'
77+
default_transaction_isolation = 'repeatable read'
7778
log_checkpoints = on
79+
checkpoint_timeout = 30
7880
log_autovacuum_min_duration = 0
7981
8082
raftable.id = $NODE_ID

contrib/mmts/tests2/lib/bank_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ def stop(self):
3333
for client in self._clients:
3434
client.stop()
3535

36-
def print_agg(self):
36+
def aggregate(self, echo=True):
3737
aggs = []
3838
for client in self._clients:
3939
aggs.append(client.history.aggregate())
4040

41+
if not echo:
42+
return aggs
43+
4144
columns = ['running', 'running_latency', 'max_latency', 'finish']
4245

4346
print("\t\t", end="")
@@ -61,10 +64,7 @@ def print_agg(self):
6164

6265
print("")
6366

64-
def set_acc_to_tx(self, max_acc):
65-
for client in self._clients:
66-
client.set_acc_to_tx(max_acc)
67-
67+
return aggs
6868

6969
class BankClient(object):
7070

@@ -141,7 +141,7 @@ def exec_tx(self, name, tx_block):
141141
tx_block(conn, cur)
142142
self.history.register_finish(event_id, 'Commit')
143143
except psycopg2.Error as e:
144-
print("=== node%d: %s" % (self.node_id, e.pgerror))
144+
# print("=== node%d: %s" % (self.node_id, e.pgerror))
145145
self.history.register_finish(event_id, e.pgerror)
146146
#time.sleep(0.2)
147147

contrib/mmts/tests2/lib/event_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def aggregate(self):
8585
self.events = []
8686

8787
for value in self.running_events.itervalues():
88-
print(value)
88+
# print(value)
8989

9090
if value['name'] not in agg:
9191
agg[value['name']] = copy.deepcopy(self.agg_template)

contrib/mmts/tests2/test_recovery.py

Lines changed: 26 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -6,105 +6,56 @@
66
class RecoveryTest(unittest.TestCase):
77
@classmethod
88
def setUpClass(self):
9-
#subprocess.check_call(['blockade','up'])
109
self.clients = ClientCollection([
1110
"dbname=postgres host=127.0.0.1 user=postgres",
1211
"dbname=postgres host=127.0.0.1 user=postgres port=5433",
1312
"dbname=postgres host=127.0.0.1 user=postgres port=5434"
1413
])
14+
self.clients.start()
15+
time.sleep(5)
1516

1617
@classmethod
1718
def tearDownClass(self):
1819
print('tearDown')
19-
#subprocess.check_call(['blockade','join'])
20-
21-
# in case of error
2220
self.clients.stop()
23-
#self.clients[0].cleanup()
2421

25-
def test_0_0_0(self):
26-
print('### normalOpsTest ###')
22+
# def test_normal_operations(self):
23+
# print('### normalOpsTest ###')
24+
25+
# for i in range(3):
26+
# time.sleep(3)
27+
# aggs = self.clients.aggregate()
28+
# for agg in aggs:
29+
# # there were some commits
30+
# self.assertTrue( agg['transfer'] > 0 )
31+
32+
def test_node_prtition(self):
33+
print('### nodePartitionTest ###')
2734

28-
time.sleep(10)
2935
subprocess.check_call(['blockade','partition','node3'])
3036
print('### blockade node3 ###')
3137

32-
self.clients.set_acc_to_tx(10000)
33-
self.clients.start()
38+
# clear tx history
39+
self.clients.aggregate(echo=False)
3440

35-
for i in range(10):
41+
for i in range(3):
3642
time.sleep(3)
37-
self.clients.print_agg()
38-
print("\n")
43+
aggs = self.clients.aggregate()
44+
self.assertTrue( aggs[0]['transfer']['finish']['Commit'] > 0 )
45+
self.assertTrue( aggs[1]['transfer']['finish']['Commit'] > 0 )
46+
self.assertTrue( 'Commit' not in aggs[2]['transfer'] )
3947

4048
subprocess.check_call(['blockade','join'])
4149
print('### deblockade node3 ###')
4250

51+
# clear tx history
52+
self.clients.aggregate(echo=False)
53+
4354
for i in range(1000):
4455
time.sleep(3)
45-
t = datetime.datetime.now()
46-
self.clients.print_agg()
47-
print("took %f seconds" % ( (datetime.datetime.now()-t).total_seconds(),))
48-
print("\n")
49-
50-
self.clients.stop()
51-
52-
56+
aggs = self.clients.aggregate()
57+
print(i, aggs)
5358

54-
# def test_0_normal_operation(self):
55-
# print('### normalOpsTest ###')
56-
#
57-
# self.clients.set_acc_to_tx(10000)
58-
# self.clients.start()
59-
#
60-
# for i in range(5):
61-
# time.sleep(3)
62-
# for client in self.clients:
63-
# agg = client.history.aggregate()
64-
# print(agg)
65-
# self.assertTrue(agg['transfer']['finish']['Commit'] > 0)
66-
# print("\n")
67-
#
68-
# self.clients.stop()
69-
#
70-
# def test_1_distributed_deadlock(self):
71-
# print('### DDD test ###')
72-
#
73-
# self.clients.set_acc_to_tx(10)
74-
# self.clients.start()
75-
#
76-
# for i in range(5):
77-
# time.sleep(3)
78-
# for client in self.clients:
79-
# agg = client.history.aggregate()
80-
# print(agg)
81-
# self.assertTrue(agg['transfer']['finish']['Commit'] > 0)
82-
# print("\n")
83-
#
84-
# self.clients.stop()
85-
#
86-
# def test_2_node_disconnect(self):
87-
# print('### disconnectTest ###')
88-
#
89-
# self.clients.set_acc_to_tx(10000)
90-
# self.clients.start()
91-
#
92-
# subprocess.check_call(['blockade','partition','node3'])
93-
# print('Node3 disconnected')
94-
#
95-
# # give cluster some time to discover problem
96-
# time.sleep(3)
97-
#
98-
# for i in range(5):
99-
# time.sleep(3)
100-
# for client in self.clients:
101-
# agg = client.history.aggregate()
102-
# print(agg)
103-
# self.assertTrue(agg['transfer']['finish']['Commit'] > 0)
104-
# print("\n")
105-
#
106-
# subprocess.check_call(['blockade','join'])
107-
# self.clients.stop()
10859

10960
if __name__ == '__main__':
11061
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy