Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3db5770

Browse files
committed
use toxiproxy instead of blockade
1 parentdee86bd commit3db5770

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
whileself.running:
112112
msg=yieldfromself.child_pipe.coro_recv()
113113
ifmsg=='status':
114-
print('evloop: got status request')
114+
#print('evloop: got status request')
115115
serialized_aggs= {}
116116
forname,aggregateinself.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
defexec_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
defget_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
returnresp
203202

204203
defstop(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
importunittest
22
importtime
33
importsubprocess
4-
fromlib.bank_clientimportMtmClient
54
importdatetime
65

6+
fromtoxiproxyimportToxiproxy
7+
fromlib.bank_clientimportMtmClient
8+
9+
710
classRecoveryTest(unittest.TestCase):
811
@classmethod
912
defsetUpClass(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
deftearDownClass(self):
@@ -38,13 +45,14 @@ def test_normal_operations(self):
3845
deftest_node_partition(self):
3946
print('### nodePartitionTest ###')
4047

41-
subprocess.check_call(['blockade','partition','node3'])
42-
print('### blockade node3 ###')
48+
print('### split node3 ###')
49+
forproxyin ['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-
foriinrange(3):
55+
foriinrange(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+
forproxyin ['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-
foriinrange(20):
72+
foriinrange(5):
6473
print(i,datetime.datetime.now())
6574
time.sleep(3)
6675
aggs=self.client.get_status()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp