|
6 | 6 | class RecoveryTest(unittest.TestCase): |
7 | 7 | @classmethod |
8 | 8 | def setUpClass(self): |
9 | | - #subprocess.check_call(['blockade','up']) |
10 | 9 | self.clients = ClientCollection([ |
11 | 10 | "dbname=postgres host=127.0.0.1 user=postgres", |
12 | 11 | "dbname=postgres host=127.0.0.1 user=postgres port=5433", |
13 | 12 | "dbname=postgres host=127.0.0.1 user=postgres port=5434" |
14 | 13 | ]) |
| 14 | + self.clients.start() |
| 15 | + time.sleep(5) |
15 | 16 |
|
16 | 17 | @classmethod |
17 | 18 | def tearDownClass(self): |
18 | 19 | print('tearDown') |
19 | | - #subprocess.check_call(['blockade','join']) |
20 | | - |
21 | | - # in case of error |
22 | 20 | self.clients.stop() |
23 | | - #self.clients[0].cleanup() |
24 | 21 |
|
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 ###') |
27 | 34 |
|
28 | | - time.sleep(10) |
29 | 35 | subprocess.check_call(['blockade','partition','node3']) |
30 | 36 | print('### blockade node3 ###') |
31 | 37 |
|
32 | | - self.clients.set_acc_to_tx(10000) |
33 | | - self.clients.start() |
| 38 | + # clear tx history |
| 39 | + self.clients.aggregate(echo=False) |
34 | 40 |
|
35 | | - for i in range(10): |
| 41 | + for i in range(3): |
36 | 42 | 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'] ) |
39 | 47 |
|
40 | 48 | subprocess.check_call(['blockade','join']) |
41 | 49 | print('### deblockade node3 ###') |
42 | 50 |
|
| 51 | + # clear tx history |
| 52 | + self.clients.aggregate(echo=False) |
| 53 | + |
43 | 54 | for i in range(1000): |
44 | 55 | 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) |
53 | 58 |
|
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() |
108 | 59 |
|
109 | 60 | if __name__ == '__main__': |
110 | 61 | unittest.main() |
|
0 commit comments