@@ -16,16 +16,22 @@ use test_helpers::{maybe_start_logging, now, random_topic_name, record};
16
16
async fn test_plain ( ) {
17
17
maybe_start_logging ( ) ;
18
18
19
- let connection = maybe_skip_kafka_integration ! ( ) ;
20
- ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
19
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
20
+ ClientBuilder :: new ( test_cfg. bootstrap_brokers )
21
+ . build ( )
22
+ . await
23
+ . unwrap ( ) ;
21
24
}
22
25
23
26
#[ tokio:: test]
24
27
async fn test_topic_crud ( ) {
25
28
maybe_start_logging ( ) ;
26
29
27
- let connection = maybe_skip_kafka_integration ! ( ) ;
28
- let client = ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
30
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
31
+ let client = ClientBuilder :: new ( test_cfg. bootstrap_brokers )
32
+ . build ( )
33
+ . await
34
+ . unwrap ( ) ;
29
35
let controller_client = client. controller_client ( ) . unwrap ( ) ;
30
36
let topics = client. list_topics ( ) . await . unwrap ( ) ;
31
37
@@ -77,10 +83,13 @@ async fn test_topic_crud() {
77
83
async fn test_partition_client ( ) {
78
84
maybe_start_logging ( ) ;
79
85
80
- let connection = maybe_skip_kafka_integration ! ( ) ;
86
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
81
87
let topic_name = random_topic_name ( ) ;
82
88
83
- let client = ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
89
+ let client = ClientBuilder :: new ( test_cfg. bootstrap_brokers )
90
+ . build ( )
91
+ . await
92
+ . unwrap ( ) ;
84
93
85
94
let controller_client = client. controller_client ( ) . unwrap ( ) ;
86
95
controller_client
@@ -134,8 +143,8 @@ async fn test_tls() {
134
143
. with_single_cert ( vec ! [ producer_root] , private_key)
135
144
. unwrap ( ) ;
136
145
137
- let connection = maybe_skip_kafka_integration ! ( ) ;
138
- ClientBuilder :: new ( connection )
146
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
147
+ ClientBuilder :: new ( test_cfg . bootstrap_brokers )
139
148
. tls_config ( Arc :: new ( config) )
140
149
. build ( )
141
150
. await
@@ -147,14 +156,11 @@ async fn test_tls() {
147
156
async fn test_socks5 ( ) {
148
157
maybe_start_logging ( ) ;
149
158
150
- // e.g. "my-connection-kafka-bootstrap:9092"
151
- let connection = maybe_skip_kafka_integration ! ( ) ;
152
- // e.g. "localhost:1080"
153
- let proxy = maybe_skip_SOCKS_PROXY ! ( ) ;
159
+ let test_cfg = maybe_skip_kafka_integration ! ( socks5) ;
154
160
let topic_name = random_topic_name ( ) ;
155
161
156
- let client = ClientBuilder :: new ( connection )
157
- . socks5_proxy ( proxy )
162
+ let client = ClientBuilder :: new ( test_cfg . bootstrap_brokers )
163
+ . socks5_proxy ( test_cfg . socks5_proxy . unwrap ( ) )
158
164
. build ( )
159
165
. await
160
166
. unwrap ( ) ;
@@ -186,11 +192,14 @@ async fn test_socks5() {
186
192
async fn test_produce_empty ( ) {
187
193
maybe_start_logging ( ) ;
188
194
189
- let connection = maybe_skip_kafka_integration ! ( ) ;
195
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
190
196
let topic_name = random_topic_name ( ) ;
191
197
let n_partitions = 2 ;
192
198
193
- let client = ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
199
+ let client = ClientBuilder :: new ( test_cfg. bootstrap_brokers )
200
+ . build ( )
201
+ . await
202
+ . unwrap ( ) ;
194
203
let controller_client = client. controller_client ( ) . unwrap ( ) ;
195
204
controller_client
196
205
. create_topic ( & topic_name, n_partitions, 1 , 5_000 )
@@ -208,11 +217,14 @@ async fn test_produce_empty() {
208
217
async fn test_consume_empty ( ) {
209
218
maybe_start_logging ( ) ;
210
219
211
- let connection = maybe_skip_kafka_integration ! ( ) ;
220
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
212
221
let topic_name = random_topic_name ( ) ;
213
222
let n_partitions = 2 ;
214
223
215
- let client = ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
224
+ let client = ClientBuilder :: new ( test_cfg. bootstrap_brokers )
225
+ . build ( )
226
+ . await
227
+ . unwrap ( ) ;
216
228
let controller_client = client. controller_client ( ) . unwrap ( ) ;
217
229
controller_client
218
230
. create_topic ( & topic_name, n_partitions, 1 , 5_000 )
@@ -232,11 +244,14 @@ async fn test_consume_empty() {
232
244
async fn test_consume_offset_out_of_range ( ) {
233
245
maybe_start_logging ( ) ;
234
246
235
- let connection = maybe_skip_kafka_integration ! ( ) ;
247
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
236
248
let topic_name = random_topic_name ( ) ;
237
249
let n_partitions = 2 ;
238
250
239
- let client = ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
251
+ let client = ClientBuilder :: new ( test_cfg. bootstrap_brokers )
252
+ . build ( )
253
+ . await
254
+ . unwrap ( ) ;
240
255
let controller_client = client. controller_client ( ) . unwrap ( ) ;
241
256
controller_client
242
257
. create_topic ( & topic_name, n_partitions, 1 , 5_000 )
@@ -268,11 +283,11 @@ async fn test_consume_offset_out_of_range() {
268
283
async fn test_get_offset ( ) {
269
284
maybe_start_logging ( ) ;
270
285
271
- let connection = maybe_skip_kafka_integration ! ( ) ;
286
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
272
287
let topic_name = random_topic_name ( ) ;
273
288
let n_partitions = 1 ;
274
289
275
- let client = ClientBuilder :: new ( connection . clone ( ) )
290
+ let client = ClientBuilder :: new ( test_cfg . bootstrap_brokers . clone ( ) )
276
291
. build ( )
277
292
. await
278
293
. unwrap ( ) ;
@@ -336,10 +351,13 @@ async fn test_get_offset() {
336
351
async fn test_produce_consume_size_cutoff ( ) {
337
352
maybe_start_logging ( ) ;
338
353
339
- let connection = maybe_skip_kafka_integration ! ( ) ;
354
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
340
355
let topic_name = random_topic_name ( ) ;
341
356
342
- let client = ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
357
+ let client = ClientBuilder :: new ( test_cfg. bootstrap_brokers )
358
+ . build ( )
359
+ . await
360
+ . unwrap ( ) ;
343
361
let controller_client = client. controller_client ( ) . unwrap ( ) ;
344
362
controller_client
345
363
. create_topic ( & topic_name, 1 , 1 , 5_000 )
@@ -409,10 +427,13 @@ async fn test_produce_consume_size_cutoff() {
409
427
async fn test_consume_midbatch ( ) {
410
428
maybe_start_logging ( ) ;
411
429
412
- let connection = maybe_skip_kafka_integration ! ( ) ;
430
+ let test_cfg = maybe_skip_kafka_integration ! ( ) ;
413
431
let topic_name = random_topic_name ( ) ;
414
432
415
- let client = ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
433
+ let client = ClientBuilder :: new ( test_cfg. bootstrap_brokers )
434
+ . build ( )
435
+ . await
436
+ . unwrap ( ) ;
416
437
let controller_client = client. controller_client ( ) . unwrap ( ) ;
417
438
controller_client
418
439
. create_topic ( & topic_name, 1 , 1 , 5_000 )
@@ -454,10 +475,13 @@ async fn test_consume_midbatch() {
454
475
async fn test_delete_records ( ) {
455
476
maybe_start_logging ( ) ;
456
477
457
- let connection = maybe_skip_kafka_integration ! ( ) ;
478
+ let test_cfg = maybe_skip_kafka_integration ! ( delete ) ;
458
479
let topic_name = random_topic_name ( ) ;
459
480
460
- let client = ClientBuilder :: new ( connection) . build ( ) . await . unwrap ( ) ;
481
+ let client = ClientBuilder :: new ( test_cfg. bootstrap_brokers )
482
+ . build ( )
483
+ . await
484
+ . unwrap ( ) ;
461
485
let controller_client = client. controller_client ( ) . unwrap ( ) ;
462
486
controller_client
463
487
. create_topic ( & topic_name, 1 , 1 , 5_000 )
@@ -498,7 +522,10 @@ async fn test_delete_records() {
498
522
let offset_4 = offsets[ 0 ] ;
499
523
500
524
// delete from the middle of the 2nd batch
501
- maybe_skip_delete ! ( partition_client, offset_3) ;
525
+ partition_client
526
+ . delete_records ( offset_3, 1_000 )
527
+ . await
528
+ . unwrap ( ) ;
502
529
503
530
// fetching data before the record fails
504
531
let err = partition_client
0 commit comments