11import unittest
22import time
33import subprocess
4- # from lib.bank_client import*
5- from client2 import MtmClient
4+ from lib .bank_client import MtmClient
5+ # from client2 import MtmClient
66import datetime
77
88class RecoveryTest (unittest .TestCase ):
99@classmethod
1010def setUpClass (self ):
11+ subprocess .check_call (['docker-compose' ,'up' ,
12+ '--force-recreate' ,
13+ '-d' ])
14+ time .sleep (30 )
1115self .client = MtmClient ([
12- "dbname=postgres user=postgres host=127.0.0.1 port=5435 " ,
13- "dbname=postgres user=postgres host=127.0.0.1 port=5433 " ,
14- "dbname=postgres user=postgres host=127.0.0.1 port=5434 "
16+ "dbname=regression user=postgres host=127.0.0.1 port=15432 " ,
17+ "dbname=regression user=postgres host=127.0.0.1 port=15433 " ,
18+ "dbname=regression user=postgres host=127.0.0.1 port=15434 "
1519 ],n_accounts = 1000 )
1620self .client .bgrun ()
1721time .sleep (5 )
@@ -21,52 +25,53 @@ def tearDownClass(self):
2125print ('tearDown' )
2226self .client .stop ()
2327
24- # def test_normal_operations(self):
25- # print('### normalOpsTest ###')
26-
27- # for i in range(3):
28- # time.sleep(3)
29- # aggs = self.clients.aggregate()
30- # for agg in aggs:
31- # # there were some commits
32- # self.assertTrue( agg['transfer'] > 0 )
33-
34- def test_node_partition (self ):
35- print ('### nodePartitionTest ###' )
36-
37- subprocess .check_call (['blockade' ,'partition' ,'node3' ])
38- print ('### blockade node3 ###' )
39-
40- # clear tx history
41- self .client .get_status ()
28+ def test_normal_operations (self ):
29+ print ('### normalOpsTest ###' )
4230
4331for i in range (3 ):
44- print (i ,datetime .datetime .now ())
4532time .sleep (3 )
4633aggs = self .client .get_status ()
4734MtmClient .print_aggregates (aggs )
48- # self.assertTrue( aggs['transfer_0']['finish']['commit'] > 0 )
49- # self.assertTrue( aggs['transfer_1']['finish']['commit'] > 0 )
50- # self.assertTrue( aggs['transfer_2']['finish']['commit'] == 0 )
51- self .assertTrue (aggs ['sumtotal_0' ]['isolation' ]+ aggs ['sumtotal_1' ]['isolation' ]+ aggs ['sumtotal_2' ]['isolation' ]== 0 )
35+ # for agg in aggs:
36+ # # there were some commits
37+ # self.assertTrue( agg['transfer'] > 0 )
5238
53- subprocess . check_call ([ 'blockade' , 'join' ])
54- print ('###deblockade node3 ###' )
39+ # def test_node_partition(self):
40+ # print('###nodePartitionTest ###')
5541
56- # clear tx history
57- self . client . get_status ( )
42+ # subprocess.check_call(['blockade','partition','node3'])
43+ # print('### blockade node3 ###' )
5844
59- for i in range (20 ):
60- print (i ,datetime .datetime .now ())
61- time .sleep (3 )
62- aggs = self .client .get_status ()
63- MtmClient .print_aggregates (aggs )
64- self .assertTrue (aggs ['sumtotal_0' ]['isolation' ]+ aggs ['sumtotal_1' ]['isolation' ]+ aggs ['sumtotal_2' ]['isolation' ]== 0 )
45+ # # clear tx history
46+ # self.client.get_status()
47+
48+ # for i in range(3):
49+ # print(i, datetime.datetime.now())
50+ # time.sleep(3)
51+ # aggs = self.client.get_status()
52+ # MtmClient.print_aggregates(aggs)
53+ # # self.assertTrue( aggs['transfer_0']['finish']['commit'] > 0 )
54+ # # self.assertTrue( aggs['transfer_1']['finish']['commit'] > 0 )
55+ # # self.assertTrue( aggs['transfer_2']['finish']['commit'] == 0 )
56+ # self.assertTrue( aggs['sumtotal_0']['isolation'] + aggs['sumtotal_1']['isolation'] + aggs['sumtotal_2']['isolation'] == 0 )
57+
58+ # subprocess.check_call(['blockade','join'])
59+ # print('### deblockade node3 ###')
6560
66- # check that during last aggregation all nodes were working
67- self .assertTrue (aggs ['transfer_0' ]['finish' ]['commit' ]> 0 )
68- self .assertTrue (aggs ['transfer_1' ]['finish' ]['commit' ]> 0 )
69- self .assertTrue (aggs ['transfer_2' ]['finish' ]['commit' ]> 0 )
61+ # # clear tx history
62+ # self.client.get_status()
63+
64+ # for i in range(20):
65+ # print(i, datetime.datetime.now())
66+ # time.sleep(3)
67+ # aggs = self.client.get_status()
68+ # MtmClient.print_aggregates(aggs)
69+ # self.assertTrue( aggs['sumtotal_0']['isolation'] + aggs['sumtotal_1']['isolation'] + aggs['sumtotal_2']['isolation'] == 0 )
70+
71+ # # check that during last aggregation all nodes were working
72+ # self.assertTrue( aggs['transfer_0']['finish']['commit'] > 0 )
73+ # self.assertTrue( aggs['transfer_1']['finish']['commit'] > 0 )
74+ # self.assertTrue( aggs['transfer_2']['finish']['commit'] > 0 )
7075
7176
7277