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

Commit 3db5770

Browse files
committed
use toxiproxy instead of blockade
1 parent dee86bd commit 3db5770

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

tests2/lib/bank_client.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,16 @@ def status(self):
111111
while self.running:
112112
msg = yield from self.child_pipe.coro_recv()
113113
if msg == 'status':
114-
print('evloop: got status request')
114+
# print('evloop: got status request')
115115
serialized_aggs = {}
116116
for name, aggregate in self.aggregates.items():
117117
serialized_aggs[name] = aggregate.as_dict()
118118
aggregate.clear_values()
119119
self.child_pipe.send(serialized_aggs)
120-
print('evloop: sent status response')
120+
# print('evloop: sent status response')
121121
else:
122122
print('evloop: unknown message')
123123

124-
125124
@asyncio.coroutine
126125
def exec_tx(self, tx_block, aggname_prefix, conn_i):
127126
aggname = "%s_%i" % (aggname_prefix, conn_i)
@@ -194,11 +193,11 @@ def bgrun(self):
194193
self.evloop_process.start()
195194

196195
def get_status(self):
197-
print('test: sending status request')
196+
# print('test: sending status request')
198197
self.parent_pipe.send('status')
199-
print('test: awaitng status response')
198+
# print('test: awaitng status response')
200199
resp = self.parent_pipe.recv()
201-
print('test: got status response')
200+
# print('test: got status response')
202201
return resp
203202

204203
def stop(self):

tests2/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
psycopg2
22
aiopg
33
aioprocessing
4+
git+git://github.com/douglas/toxiproxy-python.git

tests2/test_recovery.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
import unittest
22
import time
33
import subprocess
4-
from lib.bank_client import MtmClient
54
import datetime
65

6+
from toxiproxy import Toxiproxy
7+
from lib.bank_client import MtmClient
8+
9+
710
class 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

Comments
 (0)