@@ -149,9 +149,9 @@ def test__reset_offset(fetcher, mocker):
149
149
assert fetcher ._subscriptions .assignment [tp ].position == 1001
150
150
151
151
152
- def test__send_offset_requests (fetcher , mocker ):
153
- tp = TopicPartition ("topic_send_offset " , 1 )
154
- mocked_send = mocker .patch .object (fetcher , "_send_offset_request " )
152
+ def test__send_list_offsets_requests (fetcher , mocker ):
153
+ tp = TopicPartition ("topic_send_list_offsets " , 1 )
154
+ mocked_send = mocker .patch .object (fetcher , "_send_list_offsets_request " )
155
155
send_futures = []
156
156
157
157
def send_side_effect (* args , ** kw ):
@@ -168,19 +168,19 @@ def send_side_effect(*args, **kw):
168
168
[None , - 1 ], itertools .cycle ([0 ]))
169
169
170
170
# Leader == None
171
- fut = fetcher ._send_offset_requests ({tp : 0 })
171
+ fut = fetcher ._send_list_offsets_requests ({tp : 0 })
172
172
assert fut .failed ()
173
173
assert isinstance (fut .exception , StaleMetadata )
174
174
assert not mocked_send .called
175
175
176
176
# Leader == -1
177
- fut = fetcher ._send_offset_requests ({tp : 0 })
177
+ fut = fetcher ._send_list_offsets_requests ({tp : 0 })
178
178
assert fut .failed ()
179
179
assert isinstance (fut .exception , LeaderNotAvailableError )
180
180
assert not mocked_send .called
181
181
182
182
# Leader == 0, send failed
183
- fut = fetcher ._send_offset_requests ({tp : 0 })
183
+ fut = fetcher ._send_list_offsets_requests ({tp : 0 })
184
184
assert not fut .is_done
185
185
assert mocked_send .called
186
186
# Check that we bound the futures correctly to chain failure
@@ -189,7 +189,7 @@ def send_side_effect(*args, **kw):
189
189
assert isinstance (fut .exception , NotLeaderForPartitionError )
190
190
191
191
# Leader == 0, send success
192
- fut = fetcher ._send_offset_requests ({tp : 0 })
192
+ fut = fetcher ._send_list_offsets_requests ({tp : 0 })
193
193
assert not fut .is_done
194
194
assert mocked_send .called
195
195
# Check that we bound the futures correctly to chain success
@@ -198,12 +198,12 @@ def send_side_effect(*args, **kw):
198
198
assert fut .value == {tp : (10 , 10000 )}
199
199
200
200
201
- def test__send_offset_requests_multiple_nodes (fetcher , mocker ):
202
- tp1 = TopicPartition ("topic_send_offset " , 1 )
203
- tp2 = TopicPartition ("topic_send_offset " , 2 )
204
- tp3 = TopicPartition ("topic_send_offset " , 3 )
205
- tp4 = TopicPartition ("topic_send_offset " , 4 )
206
- mocked_send = mocker .patch .object (fetcher , "_send_offset_request " )
201
+ def test__send_list_offsets_requests_multiple_nodes (fetcher , mocker ):
202
+ tp1 = TopicPartition ("topic_send_list_offsets " , 1 )
203
+ tp2 = TopicPartition ("topic_send_list_offsets " , 2 )
204
+ tp3 = TopicPartition ("topic_send_list_offsets " , 3 )
205
+ tp4 = TopicPartition ("topic_send_list_offsets " , 4 )
206
+ mocked_send = mocker .patch .object (fetcher , "_send_list_offsets_request " )
207
207
send_futures = []
208
208
209
209
def send_side_effect (node_id , timestamps ):
@@ -218,7 +218,7 @@ def send_side_effect(node_id, timestamps):
218
218
219
219
# -- All node succeeded case
220
220
tss = OrderedDict ([(tp1 , 0 ), (tp2 , 0 ), (tp3 , 0 ), (tp4 , 0 )])
221
- fut = fetcher ._send_offset_requests (tss )
221
+ fut = fetcher ._send_list_offsets_requests (tss )
222
222
assert not fut .is_done
223
223
assert mocked_send .call_count == 2
224
224
@@ -244,7 +244,7 @@ def send_side_effect(node_id, timestamps):
244
244
245
245
# -- First succeeded second not
246
246
del send_futures [:]
247
- fut = fetcher ._send_offset_requests (tss )
247
+ fut = fetcher ._send_list_offsets_requests (tss )
248
248
assert len (send_futures ) == 2
249
249
send_futures [0 ][2 ].success ({tp1 : (11 , 1001 )})
250
250
send_futures [1 ][2 ].failure (UnknownTopicOrPartitionError (tp1 ))
@@ -253,22 +253,22 @@ def send_side_effect(node_id, timestamps):
253
253
254
254
# -- First fails second succeeded
255
255
del send_futures [:]
256
- fut = fetcher ._send_offset_requests (tss )
256
+ fut = fetcher ._send_list_offsets_requests (tss )
257
257
assert len (send_futures ) == 2
258
258
send_futures [0 ][2 ].failure (UnknownTopicOrPartitionError (tp1 ))
259
259
send_futures [1 ][2 ].success ({tp1 : (11 , 1001 )})
260
260
assert fut .failed ()
261
261
assert isinstance (fut .exception , UnknownTopicOrPartitionError )
262
262
263
263
264
- def test__handle_offset_response_v1 (fetcher , mocker ):
264
+ def test__handle_list_offsets_response_v1 (fetcher , mocker ):
265
265
# Broker returns UnsupportedForMessageFormatError, will omit partition
266
266
fut = Future ()
267
267
res = ListOffsetsResponse [1 ]([
268
268
("topic" , [(0 , 43 , - 1 , - 1 )]),
269
269
("topic" , [(1 , 0 , 1000 , 9999 )])
270
270
])
271
- fetcher ._handle_offset_response (fut , res )
271
+ fetcher ._handle_list_offsets_response (fut , res )
272
272
assert fut .succeeded ()
273
273
assert fut .value == {TopicPartition ("topic" , 1 ): (9999 , 1000 )}
274
274
@@ -277,7 +277,7 @@ def test__handle_offset_response_v1(fetcher, mocker):
277
277
res = ListOffsetsResponse [1 ]([
278
278
("topic" , [(0 , 6 , - 1 , - 1 )]),
279
279
])
280
- fetcher ._handle_offset_response (fut , res )
280
+ fetcher ._handle_list_offsets_response (fut , res )
281
281
assert fut .failed ()
282
282
assert isinstance (fut .exception , NotLeaderForPartitionError )
283
283
@@ -286,7 +286,7 @@ def test__handle_offset_response_v1(fetcher, mocker):
286
286
res = ListOffsetsResponse [1 ]([
287
287
("topic" , [(0 , 3 , - 1 , - 1 )]),
288
288
])
289
- fetcher ._handle_offset_response (fut , res )
289
+ fetcher ._handle_list_offsets_response (fut , res )
290
290
assert fut .failed ()
291
291
assert isinstance (fut .exception , UnknownTopicOrPartitionError )
292
292
@@ -299,19 +299,19 @@ def test__handle_offset_response_v1(fetcher, mocker):
299
299
("topic" , [(2 , 3 , - 1 , - 1 )]),
300
300
("topic" , [(3 , 0 , 1000 , 9999 )])
301
301
])
302
- fetcher ._handle_offset_response (fut , res )
302
+ fetcher ._handle_list_offsets_response (fut , res )
303
303
assert fut .failed ()
304
304
assert isinstance (fut .exception , NotLeaderForPartitionError )
305
305
306
306
307
- def test__handle_offset_response_v2_v3 (fetcher , mocker ):
307
+ def test__handle_list_offsets_response_v2_v3 (fetcher , mocker ):
308
308
# including a throttle_time shouldnt cause issues
309
309
fut = Future ()
310
310
res = ListOffsetsResponse [2 ](
311
311
123 , # throttle_time_ms
312
312
[("topic" , [(0 , 0 , 1000 , 9999 )])
313
313
])
314
- fetcher ._handle_offset_response (fut , res )
314
+ fetcher ._handle_list_offsets_response (fut , res )
315
315
assert fut .succeeded ()
316
316
assert fut .value == {TopicPartition ("topic" , 0 ): (9999 , 1000 )}
317
317
@@ -321,7 +321,7 @@ def test__handle_offset_response_v2_v3(fetcher, mocker):
321
321
123 , # throttle_time_ms
322
322
[("topic" , [(0 , 0 , 1000 , 9999 )])
323
323
])
324
- fetcher ._handle_offset_response (fut , res )
324
+ fetcher ._handle_list_offsets_response (fut , res )
325
325
assert fut .succeeded ()
326
326
assert fut .value == {TopicPartition ("topic" , 0 ): (9999 , 1000 )}
327
327
0 commit comments