1
1
import unittest
2
2
import time
3
3
import subprocess
4
- from lib .bank_client import MtmClient
5
4
import datetime
6
5
6
+ from toxiproxy import Toxiproxy
7
+ from lib .bank_client import MtmClient
8
+
9
+
7
10
class RecoveryTest (unittest .TestCase ):
8
11
@classmethod
9
12
def setUpClass (self ):
10
13
subprocess .check_call (['docker-compose' ,'up' ,
11
14
'--force-recreate' ,
12
15
'-d' ])
16
+
17
+ # XXX: add normal wait here
13
18
time .sleep (30 )
14
19
self .client = MtmClient ([
15
20
"dbname=regression user=postgres host=127.0.0.1 port=15432" ,
16
21
"dbname=regression user=postgres host=127.0.0.1 port=15433" ,
17
22
"dbname=regression user=postgres host=127.0.0.1 port=15434"
18
23
], n_accounts = 1000 )
19
24
self .client .bgrun ()
20
- time .sleep (5 )
25
+
26
+ self .toxiproxy = Toxiproxy () #Toxiproxy(server_host="toxi")
27
+
21
28
22
29
@classmethod
23
30
def tearDownClass (self ):
@@ -38,13 +45,14 @@ def test_normal_operations(self):
38
45
def test_node_partition (self ):
39
46
print ('### nodePartitionTest ###' )
40
47
41
- subprocess .check_call (['blockade' ,'partition' ,'node3' ])
42
- print ('### blockade node3 ###' )
48
+ print ('### split node3 ###' )
49
+ for proxy in ['rep31' , 'rep32' , 'rep23' , 'rep13' , 'arb31' , 'arb32' , 'arb23' , 'arb13' ]:
50
+ self .toxiproxy .get_proxy (proxy ).disable ()
43
51
44
52
# clear tx history
45
53
self .client .get_status ()
46
54
47
- for i in range (3 ):
55
+ for i in range (5 ):
48
56
print (i , datetime .datetime .now ())
49
57
time .sleep (3 )
50
58
aggs = self .client .get_status ()
@@ -54,13 +62,14 @@ def test_node_partition(self):
54
62
# self.assertTrue( aggs['transfer_2']['finish']['commit'] == 0 )
55
63
self .assertTrue ( aggs ['sumtotal_0' ]['isolation' ] + aggs ['sumtotal_1' ]['isolation' ] + aggs ['sumtotal_2' ]['isolation' ] == 0 )
56
64
57
- subprocess .check_call (['blockade' ,'join' ])
58
- print ('### deblockade node3 ###' )
65
+ print ('### join node3 ###' )
66
+ for proxy in ['rep31' , 'rep32' , 'rep23' , 'rep13' , 'arb31' , 'arb32' , 'arb23' , 'arb13' ]:
67
+ self .toxiproxy .get_proxy (proxy ).enable ()
59
68
60
69
# clear tx history
61
70
self .client .get_status ()
62
71
63
- for i in range (20 ):
72
+ for i in range (5 ):
64
73
print (i , datetime .datetime .now ())
65
74
time .sleep (3 )
66
75
aggs = self .client .get_status ()
0 commit comments