11import unittest
22import time
33import subprocess
4- from lib .bank_client import MtmClient
54import datetime
65
6+ from toxiproxy import Toxiproxy
7+ from lib .bank_client import MtmClient
8+
9+
710class RecoveryTest (unittest .TestCase ):
811 @classmethod
912 def setUpClass (self ):
1013 subprocess .check_call (['docker-compose' ,'up' ,
1114 '--force-recreate' ,
1215 '-d' ])
16+
17+ # XXX: add normal wait here
1318 time .sleep (30 )
1419 self .client = MtmClient ([
1520 "dbname=regression user=postgres host=127.0.0.1 port=15432" ,
1621 "dbname=regression user=postgres host=127.0.0.1 port=15433" ,
1722 "dbname=regression user=postgres host=127.0.0.1 port=15434"
1823 ], n_accounts = 1000 )
1924 self .client .bgrun ()
20- time .sleep (5 )
25+
26+ self .toxiproxy = Toxiproxy () #Toxiproxy(server_host="toxi")
27+
2128
2229 @classmethod
2330 def tearDownClass (self ):
@@ -38,13 +45,14 @@ def test_normal_operations(self):
3845 def test_node_partition (self ):
3946 print ('### nodePartitionTest ###' )
4047
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 ()
4351
4452 # clear tx history
4553 self .client .get_status ()
4654
47- for i in range (3 ):
55+ for i in range (5 ):
4856 print (i , datetime .datetime .now ())
4957 time .sleep (3 )
5058 aggs = self .client .get_status ()
@@ -54,13 +62,14 @@ def test_node_partition(self):
5462 # self.assertTrue( aggs['transfer_2']['finish']['commit'] == 0 )
5563 self .assertTrue ( aggs ['sumtotal_0' ]['isolation' ] + aggs ['sumtotal_1' ]['isolation' ] + aggs ['sumtotal_2' ]['isolation' ] == 0 )
5664
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 ()
5968
6069 # clear tx history
6170 self .client .get_status ()
6271
63- for i in range (20 ):
72+ for i in range (5 ):
6473 print (i , datetime .datetime .now ())
6574 time .sleep (3 )
6675 aggs = self .client .get_status ()
0 commit comments