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

Commit abb4ff1

Browse files
committed
Add actual asserts to mmts recovery test
1 parent 287d783 commit abb4ff1

File tree

5 files changed

+39
-80
lines changed

5 files changed

+39
-80
lines changed

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 && \

tests2/docker-entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,16 @@ 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'
78+
log_checkpoints = on
79+
checkpoint_timeout = 30
80+
log_autovacuum_min_duration = 0
7781
7882
raftable.id = $NODE_ID
7983
raftable.peers = '$RAFT_PEERS'

tests2/lib/bank_client.py

Lines changed: 6 additions & 2 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,6 +64,7 @@ def print_agg(self):
6164

6265
print("")
6366

67+
return aggs
6468

6569
class BankClient(object):
6670

@@ -137,7 +141,7 @@ def exec_tx(self, name, tx_block):
137141
tx_block(conn, cur)
138142
self.history.register_finish(event_id, 'Commit')
139143
except psycopg2.Error as e:
140-
print("=== node%d: %s" % (self.node_id, e.pgerror))
144+
# print("=== node%d: %s" % (self.node_id, e.pgerror))
141145
self.history.register_finish(event_id, e.pgerror)
142146
#time.sleep(0.2)
143147

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)

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
subprocess.check_call(['blockade','join'])
11061
print("Node3 joined back")

0 commit comments

Comments
 (0)