rdkafka 0.21.1.alpha2 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/renovate.json CHANGED
@@ -14,5 +14,79 @@
14
14
  ],
15
15
  "minimumReleaseAge": "7 days"
16
16
  }
17
+ ],
18
+ "customManagers": [
19
+ {
20
+ "customType": "regex",
21
+ "managerFilePatterns": [
22
+ "/^ext/build_common\\.sh$/"
23
+ ],
24
+ "matchStrings": [
25
+ "readonly OPENSSL_VERSION=\"(?<currentValue>.*)\""
26
+ ],
27
+ "depNameTemplate": "openssl/openssl",
28
+ "datasourceTemplate": "github-releases",
29
+ "extractVersionTemplate": "^OpenSSL_(?<version>.*)$"
30
+ },
31
+ {
32
+ "customType": "regex",
33
+ "managerFilePatterns": [
34
+ "/^ext/build_common\\.sh$/"
35
+ ],
36
+ "matchStrings": [
37
+ "readonly CYRUS_SASL_VERSION=\"(?<currentValue>.*)\""
38
+ ],
39
+ "depNameTemplate": "cyrusimap/cyrus-sasl",
40
+ "datasourceTemplate": "github-releases",
41
+ "extractVersionTemplate": "^cyrus-sasl-(?<version>.*)$"
42
+ },
43
+ {
44
+ "customType": "regex",
45
+ "managerFilePatterns": [
46
+ "/^ext/build_common\\.sh$/"
47
+ ],
48
+ "matchStrings": [
49
+ "readonly ZLIB_VERSION=\"(?<currentValue>.*)\""
50
+ ],
51
+ "depNameTemplate": "madler/zlib",
52
+ "datasourceTemplate": "github-releases",
53
+ "extractVersionTemplate": "^v(?<version>.*)$"
54
+ },
55
+ {
56
+ "customType": "regex",
57
+ "managerFilePatterns": [
58
+ "/^ext/build_common\\.sh$/"
59
+ ],
60
+ "matchStrings": [
61
+ "readonly ZSTD_VERSION=\"(?<currentValue>.*)\""
62
+ ],
63
+ "depNameTemplate": "facebook/zstd",
64
+ "datasourceTemplate": "github-releases",
65
+ "extractVersionTemplate": "^v(?<version>.*)$"
66
+ },
67
+ {
68
+ "customType": "regex",
69
+ "managerFilePatterns": [
70
+ "/^ext/build_common\\.sh$/"
71
+ ],
72
+ "matchStrings": [
73
+ "readonly KRB5_VERSION=\"(?<currentValue>.*)\""
74
+ ],
75
+ "depNameTemplate": "krb5/krb5",
76
+ "datasourceTemplate": "github-releases",
77
+ "extractVersionTemplate": "^krb5-(?<version>.*)$"
78
+ },
79
+ {
80
+ "customType": "regex",
81
+ "managerFilePatterns": [
82
+ "/^ext/build_common\\.sh$/"
83
+ ],
84
+ "matchStrings": [
85
+ "readonly LIBRDKAFKA_VERSION=\"(?<currentValue>.*)\""
86
+ ],
87
+ "depNameTemplate": "confluentinc/librdkafka",
88
+ "datasourceTemplate": "github-releases",
89
+ "extractVersionTemplate": "^v(?<version>.*)$"
90
+ }
17
91
  ]
18
92
  }
@@ -295,6 +295,8 @@ expect(ex.broker_message).to match(/Topic name.*is invalid: .* contains one or m
295
295
  expect(resources_results.first.type).to eq(2)
296
296
  expect(resources_results.first.name).to eq(topic_name)
297
297
 
298
+ sleep(1)
299
+
298
300
  ret_config = admin.describe_configs(resources_with_configs).wait.resources.first.configs.find do |config|
299
301
  config.name == 'delete.retention.ms'
300
302
  end
@@ -325,6 +327,9 @@ expect(ex.broker_message).to match(/Topic name.*is invalid: .* contains one or m
325
327
  expect(resources_results.size).to eq(1)
326
328
  expect(resources_results.first.type).to eq(2)
327
329
  expect(resources_results.first.name).to eq(topic_name)
330
+
331
+ sleep(1)
332
+
328
333
  ret_config = admin.describe_configs(resources_with_configs).wait.resources.first.configs.find do |config|
329
334
  config.name == 'delete.retention.ms'
330
335
  end
@@ -356,6 +361,8 @@ expect(ex.broker_message).to match(/Topic name.*is invalid: .* contains one or m
356
361
  expect(resources_results.first.type).to eq(2)
357
362
  expect(resources_results.first.name).to eq(topic_name)
358
363
 
364
+ sleep(1)
365
+
359
366
  ret_config = admin.describe_configs(resources_with_configs).wait.resources.first.configs.find do |config|
360
367
  config.name == 'cleanup.policy'
361
368
  end
@@ -387,6 +394,8 @@ expect(ex.broker_message).to match(/Topic name.*is invalid: .* contains one or m
387
394
  expect(resources_results.first.type).to eq(2)
388
395
  expect(resources_results.first.name).to eq(topic_name)
389
396
 
397
+ sleep(1)
398
+
390
399
  ret_config = admin.describe_configs(resources_with_configs).wait.resources.first.configs.find do |config|
391
400
  config.name == 'cleanup.policy'
392
401
  end
@@ -504,7 +513,7 @@ expect(ex.broker_message).to match(/Topic name.*is invalid: .* contains one or m
504
513
  end
505
514
  end
506
515
 
507
- describe "#ACL tests" do
516
+ describe "#ACL tests for topic resource" do
508
517
  let(:non_existing_resource_name) {"non-existing-topic"}
509
518
  before do
510
519
  #create topic for testing acl
@@ -606,6 +615,207 @@ expect(ex.broker_message).to match(/Topic name.*is invalid: .* contains one or m
606
615
  end
607
616
  end
608
617
 
618
+ describe "#ACL tests for transactional_id" do
619
+ let(:transactional_id_resource_name) {"test-transactional-id"}
620
+ let(:non_existing_transactional_id) {"non-existing-transactional-id"}
621
+ let(:transactional_id_resource_type) { Rdkafka::Bindings::RD_KAFKA_RESOURCE_TRANSACTIONAL_ID }
622
+ let(:transactional_id_resource_pattern_type) { Rdkafka::Bindings::RD_KAFKA_RESOURCE_PATTERN_LITERAL }
623
+ let(:transactional_id_principal) { "User:test-user" }
624
+ let(:transactional_id_host) { "*" }
625
+ let(:transactional_id_operation) { Rdkafka::Bindings::RD_KAFKA_ACL_OPERATION_WRITE }
626
+ let(:transactional_id_permission_type) { Rdkafka::Bindings::RD_KAFKA_ACL_PERMISSION_TYPE_ALLOW }
627
+
628
+ after do
629
+ # Clean up any ACLs that might have been created during tests
630
+ begin
631
+ delete_acl_handle = admin.delete_acl(
632
+ resource_type: transactional_id_resource_type,
633
+ resource_name: nil,
634
+ resource_pattern_type: transactional_id_resource_pattern_type,
635
+ principal: transactional_id_principal,
636
+ host: transactional_id_host,
637
+ operation: transactional_id_operation,
638
+ permission_type: transactional_id_permission_type
639
+ )
640
+ delete_acl_handle.wait(max_wait_timeout: 15.0)
641
+ rescue
642
+ # Ignore cleanup errors
643
+ end
644
+ end
645
+
646
+ describe "#create_acl" do
647
+ it "creates acl for a transactional_id" do
648
+ create_acl_handle = admin.create_acl(
649
+ resource_type: transactional_id_resource_type,
650
+ resource_name: transactional_id_resource_name,
651
+ resource_pattern_type: transactional_id_resource_pattern_type,
652
+ principal: transactional_id_principal,
653
+ host: transactional_id_host,
654
+ operation: transactional_id_operation,
655
+ permission_type: transactional_id_permission_type
656
+ )
657
+ create_acl_report = create_acl_handle.wait(max_wait_timeout: 15.0)
658
+ expect(create_acl_report.rdkafka_response).to eq(0)
659
+ expect(create_acl_report.rdkafka_response_string).to eq("")
660
+ end
661
+
662
+ it "creates acl for a non-existing transactional_id" do
663
+ # ACL creation for transactional_ids that don't exist will still get created successfully
664
+ create_acl_handle = admin.create_acl(
665
+ resource_type: transactional_id_resource_type,
666
+ resource_name: non_existing_transactional_id,
667
+ resource_pattern_type: transactional_id_resource_pattern_type,
668
+ principal: transactional_id_principal,
669
+ host: transactional_id_host,
670
+ operation: transactional_id_operation,
671
+ permission_type: transactional_id_permission_type
672
+ )
673
+ create_acl_report = create_acl_handle.wait(max_wait_timeout: 15.0)
674
+ expect(create_acl_report.rdkafka_response).to eq(0)
675
+ expect(create_acl_report.rdkafka_response_string).to eq("")
676
+
677
+ # Clean up the ACL that was created for the non-existing transactional_id
678
+ delete_acl_handle = admin.delete_acl(
679
+ resource_type: transactional_id_resource_type,
680
+ resource_name: non_existing_transactional_id,
681
+ resource_pattern_type: transactional_id_resource_pattern_type,
682
+ principal: transactional_id_principal,
683
+ host: transactional_id_host,
684
+ operation: transactional_id_operation,
685
+ permission_type: transactional_id_permission_type
686
+ )
687
+ delete_acl_report = delete_acl_handle.wait(max_wait_timeout: 15.0)
688
+ expect(delete_acl_handle[:response]).to eq(0)
689
+ expect(delete_acl_report.deleted_acls.size).to eq(1)
690
+ end
691
+ end
692
+
693
+ describe "#describe_acl" do
694
+ it "describes acl of a transactional_id that does not exist" do
695
+ describe_acl_handle = admin.describe_acl(
696
+ resource_type: transactional_id_resource_type,
697
+ resource_name: non_existing_transactional_id,
698
+ resource_pattern_type: transactional_id_resource_pattern_type,
699
+ principal: transactional_id_principal,
700
+ host: transactional_id_host,
701
+ operation: transactional_id_operation,
702
+ permission_type: transactional_id_permission_type
703
+ )
704
+ describe_acl_report = describe_acl_handle.wait(max_wait_timeout: 15.0)
705
+ expect(describe_acl_handle[:response]).to eq(0)
706
+ expect(describe_acl_report.acls.size).to eq(0)
707
+ end
708
+
709
+ it "creates acls and describes the newly created transactional_id acls" do
710
+ # Create first ACL
711
+ create_acl_handle = admin.create_acl(
712
+ resource_type: transactional_id_resource_type,
713
+ resource_name: "test_transactional_id_1",
714
+ resource_pattern_type: transactional_id_resource_pattern_type,
715
+ principal: transactional_id_principal,
716
+ host: transactional_id_host,
717
+ operation: transactional_id_operation,
718
+ permission_type: transactional_id_permission_type
719
+ )
720
+ create_acl_report = create_acl_handle.wait(max_wait_timeout: 15.0)
721
+ expect(create_acl_report.rdkafka_response).to eq(0)
722
+ expect(create_acl_report.rdkafka_response_string).to eq("")
723
+
724
+ # Create second ACL
725
+ create_acl_handle = admin.create_acl(
726
+ resource_type: transactional_id_resource_type,
727
+ resource_name: "test_transactional_id_2",
728
+ resource_pattern_type: transactional_id_resource_pattern_type,
729
+ principal: transactional_id_principal,
730
+ host: transactional_id_host,
731
+ operation: transactional_id_operation,
732
+ permission_type: transactional_id_permission_type
733
+ )
734
+ create_acl_report = create_acl_handle.wait(max_wait_timeout: 15.0)
735
+ expect(create_acl_report.rdkafka_response).to eq(0)
736
+ expect(create_acl_report.rdkafka_response_string).to eq("")
737
+
738
+ # Since we create and immediately check, this is slow on loaded CIs, hence we wait
739
+ sleep(2)
740
+
741
+ # Describe ACLs - filter by transactional_id resource type
742
+ describe_acl_handle = admin.describe_acl(
743
+ resource_type: transactional_id_resource_type,
744
+ resource_name: nil,
745
+ resource_pattern_type: Rdkafka::Bindings::RD_KAFKA_RESOURCE_PATTERN_ANY,
746
+ principal: transactional_id_principal,
747
+ host: transactional_id_host,
748
+ operation: transactional_id_operation,
749
+ permission_type: transactional_id_permission_type
750
+ )
751
+ describe_acl_report = describe_acl_handle.wait(max_wait_timeout: 15.0)
752
+ expect(describe_acl_handle[:response]).to eq(0)
753
+ expect(describe_acl_report.acls.length).to eq(2)
754
+ end
755
+ end
756
+
757
+ describe "#delete_acl" do
758
+ it "deletes acl of a transactional_id that does not exist" do
759
+ delete_acl_handle = admin.delete_acl(
760
+ resource_type: transactional_id_resource_type,
761
+ resource_name: non_existing_transactional_id,
762
+ resource_pattern_type: transactional_id_resource_pattern_type,
763
+ principal: transactional_id_principal,
764
+ host: transactional_id_host,
765
+ operation: transactional_id_operation,
766
+ permission_type: transactional_id_permission_type
767
+ )
768
+ delete_acl_report = delete_acl_handle.wait(max_wait_timeout: 15.0)
769
+ expect(delete_acl_handle[:response]).to eq(0)
770
+ expect(delete_acl_report.deleted_acls.size).to eq(0)
771
+ end
772
+
773
+ it "creates transactional_id acls and deletes the newly created acls" do
774
+ # Create first ACL
775
+ create_acl_handle = admin.create_acl(
776
+ resource_type: transactional_id_resource_type,
777
+ resource_name: "test_transactional_id_1",
778
+ resource_pattern_type: transactional_id_resource_pattern_type,
779
+ principal: transactional_id_principal,
780
+ host: transactional_id_host,
781
+ operation: transactional_id_operation,
782
+ permission_type: transactional_id_permission_type
783
+ )
784
+ create_acl_report = create_acl_handle.wait(max_wait_timeout: 15.0)
785
+ expect(create_acl_report.rdkafka_response).to eq(0)
786
+ expect(create_acl_report.rdkafka_response_string).to eq("")
787
+
788
+ # Create second ACL
789
+ create_acl_handle = admin.create_acl(
790
+ resource_type: transactional_id_resource_type,
791
+ resource_name: "test_transactional_id_2",
792
+ resource_pattern_type: transactional_id_resource_pattern_type,
793
+ principal: transactional_id_principal,
794
+ host: transactional_id_host,
795
+ operation: transactional_id_operation,
796
+ permission_type: transactional_id_permission_type
797
+ )
798
+ create_acl_report = create_acl_handle.wait(max_wait_timeout: 15.0)
799
+ expect(create_acl_report.rdkafka_response).to eq(0)
800
+ expect(create_acl_report.rdkafka_response_string).to eq("")
801
+
802
+ # Delete ACLs - resource_name nil to delete all ACLs with any resource name and matching all other filters
803
+ delete_acl_handle = admin.delete_acl(
804
+ resource_type: transactional_id_resource_type,
805
+ resource_name: nil,
806
+ resource_pattern_type: transactional_id_resource_pattern_type,
807
+ principal: transactional_id_principal,
808
+ host: transactional_id_host,
809
+ operation: transactional_id_operation,
810
+ permission_type: transactional_id_permission_type
811
+ )
812
+ delete_acl_report = delete_acl_handle.wait(max_wait_timeout: 15.0)
813
+ expect(delete_acl_handle[:response]).to eq(0)
814
+ expect(delete_acl_report.deleted_acls.length).to eq(2)
815
+ end
816
+ end
817
+ end
818
+
609
819
  describe('Group tests') do
610
820
  describe "#delete_group" do
611
821
  describe("with an existing group") do
@@ -622,7 +832,12 @@ expect(ex.broker_message).to match(/Topic name.*is invalid: .* contains one or m
622
832
 
623
833
  consumer.subscribe(topic_name)
624
834
  wait_for_assignment(consumer)
625
- message = consumer.poll(100)
835
+
836
+ message = nil
837
+
838
+ 10.times do
839
+ message ||= consumer.poll(100)
840
+ end
626
841
 
627
842
  expect(message).to_not be_nil
628
843
 
@@ -77,30 +77,6 @@ describe Rdkafka::Bindings do
77
77
  end
78
78
  end
79
79
 
80
- describe "partitioner" do
81
- let(:partition_key) { ('a'..'z').to_a.shuffle.take(15).join('') }
82
- let(:partition_count) { rand(50) + 1 }
83
-
84
- it "should return the same partition for a similar string and the same partition count" do
85
- result_1 = Rdkafka::Bindings.partitioner(partition_key, partition_count)
86
- result_2 = Rdkafka::Bindings.partitioner(partition_key, partition_count)
87
- expect(result_1).to eq(result_2)
88
- end
89
-
90
- it "should match the old partitioner" do
91
- result_1 = Rdkafka::Bindings.partitioner(partition_key, partition_count)
92
- result_2 = (Zlib.crc32(partition_key) % partition_count)
93
- expect(result_1).to eq(result_2)
94
- end
95
-
96
- it "should return the partition calculated by the specified partitioner" do
97
- result_1 = Rdkafka::Bindings.partitioner(partition_key, partition_count, "murmur2")
98
- ptr = FFI::MemoryPointer.from_string(partition_key)
99
- result_2 = Rdkafka::Bindings.rd_kafka_msg_partitioner_murmur2(nil, ptr, partition_key.size, partition_count, nil, nil)
100
- expect(result_1).to eq(result_2)
101
- end
102
- end
103
-
104
80
  describe "stats callback" do
105
81
  context "without a stats callback" do
106
82
  it "should do nothing" do
@@ -170,8 +170,16 @@ describe Rdkafka::Consumer do
170
170
  end
171
171
 
172
172
  describe "#seek" do
173
+ let(:topic) { "it-#{SecureRandom.uuid}" }
174
+
175
+ before do
176
+ admin = rdkafka_producer_config.admin
177
+ admin.create_topic(topic, 1, 1).wait
178
+ admin.close
179
+ end
180
+
173
181
  it "should raise an error when seeking fails" do
174
- fake_msg = OpenStruct.new(topic: "consume_test_topic", partition: 0, offset: 0)
182
+ fake_msg = OpenStruct.new(topic: topic, partition: 0, offset: 0)
175
183
 
176
184
  expect(Rdkafka::Bindings).to receive(:rd_kafka_seek).and_return(20)
177
185
  expect {
@@ -181,9 +189,12 @@ describe Rdkafka::Consumer do
181
189
 
182
190
  context "subscription" do
183
191
  let(:timeout) { 1000 }
192
+ # Some specs here test the manual offset commit hence we want to ensure, that we have some
193
+ # offsets in-memory that we can manually commit
194
+ let(:consumer) { rdkafka_consumer_config('auto.commit.interval.ms': 60_000).consumer }
184
195
 
185
196
  before do
186
- consumer.subscribe("consume_test_topic")
197
+ consumer.subscribe(topic)
187
198
 
188
199
  # 1. partitions are assigned
189
200
  wait_for_assignment(consumer)
@@ -196,7 +207,7 @@ describe Rdkafka::Consumer do
196
207
 
197
208
  def send_one_message(val)
198
209
  producer.produce(
199
- topic: "consume_test_topic",
210
+ topic: topic,
200
211
  payload: "payload #{val}",
201
212
  key: "key 1",
202
213
  partition: 0
@@ -211,7 +222,7 @@ describe Rdkafka::Consumer do
211
222
 
212
223
  # 4. pause the subscription
213
224
  tpl = Rdkafka::Consumer::TopicPartitionList.new
214
- tpl.add_topic("consume_test_topic", 1)
225
+ tpl.add_topic(topic, 1)
215
226
  consumer.pause(tpl)
216
227
 
217
228
  # 5. seek to previous message
@@ -219,7 +230,7 @@ describe Rdkafka::Consumer do
219
230
 
220
231
  # 6. resume the subscription
221
232
  tpl = Rdkafka::Consumer::TopicPartitionList.new
222
- tpl.add_topic("consume_test_topic", 1)
233
+ tpl.add_topic(topic, 1)
223
234
  consumer.resume(tpl)
224
235
 
225
236
  # 7. ensure same message is read again
@@ -227,7 +238,7 @@ describe Rdkafka::Consumer do
227
238
 
228
239
  # This is needed because `enable.auto.offset.store` is true but when running in CI that
229
240
  # is overloaded, offset store lags
230
- sleep(2)
241
+ sleep(1)
231
242
 
232
243
  consumer.commit
233
244
  expect(message1.offset).to eq message2.offset
@@ -259,10 +270,17 @@ describe Rdkafka::Consumer do
259
270
  end
260
271
 
261
272
  describe "#seek_by" do
262
- let(:topic) { "consume_test_topic" }
273
+ let(:consumer) { rdkafka_consumer_config('auto.commit.interval.ms': 60_000).consumer }
274
+ let(:topic) { "it-#{SecureRandom.uuid}" }
263
275
  let(:partition) { 0 }
264
276
  let(:offset) { 0 }
265
277
 
278
+ before do
279
+ admin = rdkafka_producer_config.admin
280
+ admin.create_topic(topic, 1, 1).wait
281
+ admin.close
282
+ end
283
+
266
284
  it "should raise an error when seeking fails" do
267
285
  expect(Rdkafka::Bindings).to receive(:rd_kafka_seek).and_return(20)
268
286
  expect {
@@ -588,12 +606,18 @@ describe Rdkafka::Consumer do
588
606
 
589
607
  describe "#store_offset" do
590
608
  let(:consumer) { rdkafka_consumer_config('enable.auto.offset.store': false).consumer }
609
+ let(:metadata) { SecureRandom.uuid }
610
+ let(:group_id) { SecureRandom.uuid }
611
+ let(:base_config) do
612
+ {
613
+ 'group.id': group_id,
614
+ 'enable.auto.offset.store': false,
615
+ 'enable.auto.commit': false
616
+ }
617
+ end
591
618
 
592
619
  before do
593
- config = {}
594
- config[:'enable.auto.offset.store'] = false
595
- config[:'enable.auto.commit'] = false
596
- @new_consumer = rdkafka_consumer_config(config).consumer
620
+ @new_consumer = rdkafka_consumer_config(base_config).consumer
597
621
  @new_consumer.subscribe("consume_test_topic")
598
622
  wait_for_assignment(@new_consumer)
599
623
  end
@@ -795,12 +819,14 @@ describe Rdkafka::Consumer do
795
819
  end
796
820
 
797
821
  it "should return a message if there is one" do
822
+ topic = "it-#{SecureRandom.uuid}"
823
+
798
824
  producer.produce(
799
- topic: "consume_test_topic",
825
+ topic: topic,
800
826
  payload: "payload 1",
801
827
  key: "key 1"
802
828
  ).wait
803
- consumer.subscribe("consume_test_topic")
829
+ consumer.subscribe(topic)
804
830
  message = consumer.each {|m| break m}
805
831
 
806
832
  expect(message).to be_a Rdkafka::Consumer::Message
@@ -1000,7 +1026,7 @@ describe Rdkafka::Consumer do
1000
1026
  after { Rdkafka::Config.statistics_callback = nil }
1001
1027
 
1002
1028
  let(:consumer) do
1003
- config = rdkafka_consumer_config('statistics.interval.ms': 100)
1029
+ config = rdkafka_consumer_config('statistics.interval.ms': 500)
1004
1030
  config.consumer_poll_set = false
1005
1031
  config.consumer
1006
1032
  end
@@ -1097,7 +1123,8 @@ describe Rdkafka::Consumer do
1097
1123
  :assign => [ nil ],
1098
1124
  :assignment => nil,
1099
1125
  :committed => [],
1100
- :query_watermark_offsets => [ nil, nil ]
1126
+ :query_watermark_offsets => [ nil, nil ],
1127
+ :assignment_lost? => []
1101
1128
  }.each do |method, args|
1102
1129
  it "raises an exception if #{method} is called" do
1103
1130
  expect {
@@ -1212,4 +1239,36 @@ describe Rdkafka::Consumer do
1212
1239
  end
1213
1240
  end
1214
1241
  end
1242
+
1243
+ describe "when reaching eof on a topic and eof reporting enabled" do
1244
+ let(:consumer) { rdkafka_consumer_config(:"enable.partition.eof" => true).consumer }
1245
+
1246
+ it "should return proper details" do
1247
+ (0..2).each do |i|
1248
+ producer.produce(
1249
+ topic: "consume_test_topic",
1250
+ key: "key lag #{i}",
1251
+ partition: i
1252
+ ).wait
1253
+ end
1254
+
1255
+ # Consume to the end
1256
+ consumer.subscribe("consume_test_topic")
1257
+ eof_count = 0
1258
+ eof_error = nil
1259
+
1260
+ loop do
1261
+ begin
1262
+ consumer.poll(100)
1263
+ rescue Rdkafka::RdkafkaError => error
1264
+ if error.is_partition_eof?
1265
+ eof_error = error
1266
+ end
1267
+ break if eof_error
1268
+ end
1269
+ end
1270
+
1271
+ expect(eof_error.code).to eq(:partition_eof)
1272
+ end
1273
+ end
1215
1274
  end
@@ -30,7 +30,7 @@ describe Rdkafka::Metadata do
30
30
  it "#brokers returns our single broker" do
31
31
  expect(subject.brokers.length).to eq(1)
32
32
  expect(subject.brokers[0][:broker_id]).to eq(1)
33
- expect(subject.brokers[0][:broker_name]).to eq("127.0.0.1")
33
+ expect(%w[127.0.0.1 localhost]).to include(subject.brokers[0][:broker_name])
34
34
  expect(subject.brokers[0][:broker_port]).to eq(9092)
35
35
  end
36
36
 
@@ -53,7 +53,7 @@ describe Rdkafka::Metadata do
53
53
  it "#brokers returns our single broker" do
54
54
  expect(subject.brokers.length).to eq(1)
55
55
  expect(subject.brokers[0][:broker_id]).to eq(1)
56
- expect(subject.brokers[0][:broker_name]).to eq("127.0.0.1")
56
+ expect(%w[127.0.0.1 localhost]).to include(subject.brokers[0][:broker_name])
57
57
  expect(subject.brokers[0][:broker_port]).to eq(9092)
58
58
  end
59
59
 
@@ -257,7 +257,7 @@ RSpec.describe Rdkafka::Producer::PartitionsCountCache do
257
257
  cache.get(topic) { partition_count }
258
258
 
259
259
  # Wait just under TTL
260
- sleep(default_ttl - 0.1)
260
+ sleep(default_ttl - 0.2)
261
261
 
262
262
  # Value should still be cached (block should not be called)
263
263
  result = cache.get(topic) { fail "Should not be called when cache is valid" }