@@ -92,6 +92,9 @@ def test_01_roundrobin(self):
92
92
self .set_cluster_ro ([False , False , True , False , True ])
93
93
RW_ports = set ([str (self .addrs [0 ]['port' ]), str (self .addrs [1 ]['port' ]), str (self .addrs [3 ]['port' ])])
94
94
RO_ports = set ([str (self .addrs [2 ]['port' ]), str (self .addrs [4 ]['port' ])])
95
+ all_ports = set ()
96
+ for addr in self .addrs :
97
+ all_ports .add (str (addr ['port' ]))
95
98
96
99
conn = tarantool .ConnectionPool (addrs = self .addrs , user = 'test' , password = 'test' )
97
100
@@ -119,37 +122,27 @@ def test_01_roundrobin(self):
119
122
120
123
self .assertSetEqual (PREFER_RO_ports_result , RO_ports )
121
124
122
- def test_02_roundrobin_all_ro ( self ):
125
+ # Expect PREFER_RW iterate through all instances if there are no RW.
123
126
self .set_cluster_ro ([True , True , True , True , True ])
124
- all_ports = set ()
125
- for addr in self .addrs :
126
- all_ports .add (str (addr ['port' ]))
127
-
128
- conn = tarantool .ConnectionPool (addrs = self .addrs , user = 'test' , password = 'test' )
127
+ conn .update_ro_info ()
129
128
130
- # Expect PREFER_RW iterate through all instances if there are no RW.
131
- PREFER_RW_ports_result = set ()
129
+ PREFER_RW_ports_result_all_ro = set ()
132
130
for i in range (len (self .servers )):
133
131
resp = conn .eval ('return box.cfg.listen' , mode = tarantool .Mode .PREFER_RW )
134
- PREFER_RW_ports_result .add (resp .data [0 ])
132
+ PREFER_RW_ports_result_all_ro .add (resp .data [0 ])
135
133
136
- self .assertSetEqual (PREFER_RW_ports_result , all_ports )
134
+ self .assertSetEqual (PREFER_RW_ports_result_all_ro , all_ports )
137
135
138
- def test_03_roundrobin_all_rw ( self ):
136
+ # Expect PREFER_RO iterate through all instances if there are no RO.
139
137
self .set_cluster_ro ([False , False , False , False , False ])
140
- all_ports = set ()
141
- for addr in self .addrs :
142
- all_ports .add (str (addr ['port' ]))
138
+ conn .update_ro_info ()
143
139
144
- conn = tarantool .ConnectionPool (addrs = self .addrs , user = 'test' , password = 'test' )
145
-
146
- # Expect PREFER_RO iterate through all instances if there are no RO.
147
- PREFER_RO_ports_result = set ()
140
+ PREFER_RO_ports_result_all_rw = set ()
148
141
for i in range (len (self .servers )):
149
142
resp = conn .eval ('return box.cfg.listen' , mode = tarantool .Mode .PREFER_RO )
150
- PREFER_RO_ports_result .add (resp .data [0 ])
143
+ PREFER_RO_ports_result_all_rw .add (resp .data [0 ])
151
144
152
- self .assertSetEqual (PREFER_RO_ports_result , all_ports )
145
+ self .assertSetEqual (PREFER_RO_ports_result_all_rw , all_ports )
153
146
154
147
def tearDown (self ):
155
148
for srv in self .servers :
0 commit comments