karafka-testing 2.4.0.rc1 → 2.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 587bb151db13812b7c26215c9357264f21a3357448fffe542363042db19c7744
4
- data.tar.gz: 2c624b601afc5384ae7ce43bf6b0ac19f27a8ec8b00aacd796c33da5e19fdd40
3
+ metadata.gz: f0075ae4b6753ffed88f26fe1e9a65ebd9927ee0aa22dd5b5a720597d89f8921
4
+ data.tar.gz: f2bdfa9155f2d614ce9946e6387676fff10424a2d8a5a3f391c57795c3a4556b
5
5
  SHA512:
6
- metadata.gz: c70be00aeb884026f00025dc207219761ba5374e91980d89fffff2b4a76eef26098896cf60860d8f9dc088e8606569ab23c3b6ad6b75e31225ca6ad51f7296c4
7
- data.tar.gz: 344b7a3176b89a1882656eb730a458093b580e25a4e6363472b3dd95f200999697c5216814fbecb4c214a50f231e6e32f46cca1af6c90a6274ce4b6b09f19e4d
6
+ metadata.gz: ff791c4d3d10d92a05130857fd31e0b562ebdb310ccf6773376f927724d4c7625a799f75c6014e45e376636d776a99a67fed0963da1348fb9b94cfcce0eab0eb
7
+ data.tar.gz: 18d8ea8673e867c7df81142a884d34bde31f467470f9d077960dfd8c53727f951328948a278697f42968935d3fa63604cfbaaf596eca4cc935a4ddfe75e7f1a6
checksums.yaml.gz.sig CHANGED
Binary file
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.3.1
data/CHANGELOG.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Karafka Test gem changelog
2
2
 
3
- ## 2.4.0 (Unreleased)
3
+ ## 2.4.0 (2024-04-26)
4
4
  - **[Breaking]** Drop Ruby `2.7` support.
5
+ - [Refactor] Extract common components for Minitest and RSpec.
5
6
  - [Fix] Support again `require: false` on gem loading.
7
+ - [Fix] Fix a case where multiplexed SG would fail with `TopicInManyConsumerGroupsError`
6
8
 
7
9
  ## 2.3.2 (2024-04-03)
8
10
  - [Enhancement] Support `Minitest::Spec`.
data/Gemfile.lock CHANGED
@@ -1,28 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-testing (2.4.0.rc1)
5
- karafka (>= 2.4.0.beta1, < 2.5.0)
6
- waterdrop (>= 2.7.0.rc1)
4
+ karafka-testing (2.4.0)
5
+ karafka (>= 2.4.0, < 2.5.0)
6
+ waterdrop (>= 2.7.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ffi (1.16.3)
12
- karafka (2.4.0.beta1)
13
- karafka-core (>= 2.4.0.rc1, < 2.5.0)
14
- waterdrop (>= 2.7.0.rc1, < 3.0.0)
12
+ karafka (2.4.0)
13
+ karafka-core (>= 2.4.0, < 2.5.0)
14
+ waterdrop (>= 2.7.0, < 3.0.0)
15
15
  zeitwerk (~> 2.3)
16
- karafka-core (2.4.0.rc1)
17
- karafka-rdkafka (>= 0.15.0.rc1, < 0.16.0)
18
- karafka-rdkafka (0.15.0.rc1)
16
+ karafka-core (2.4.0)
17
+ karafka-rdkafka (>= 0.15.0, < 0.16.0)
18
+ karafka-rdkafka (0.15.0)
19
19
  ffi (~> 1.15)
20
20
  mini_portile2 (~> 2.6)
21
21
  rake (> 12)
22
22
  mini_portile2 (2.8.5)
23
23
  rake (13.2.1)
24
- waterdrop (2.7.0.rc1)
25
- karafka-core (>= 2.4.0.rc1, < 3.0.0)
24
+ waterdrop (2.7.0)
25
+ karafka-core (>= 2.4.0, < 3.0.0)
26
26
  zeitwerk (~> 2.3)
27
27
  zeitwerk (2.6.13)
28
28
 
@@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
25
25
  end
26
26
 
27
- spec.add_dependency 'karafka', '>= 2.4.0.beta1', '< 2.5.0'
28
- spec.add_dependency 'waterdrop', '>= 2.7.0.rc1'
27
+ spec.add_dependency 'karafka', '>= 2.4.0', '< 2.5.0'
28
+ spec.add_dependency 'waterdrop', '>= 2.7.0'
29
29
 
30
30
  spec.required_ruby_version = '>= 3.0.0'
31
31
 
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module Testing
5
+ # Common helper methods that are shared in between RSpec and Minitest
6
+ module Helpers
7
+ class << self
8
+ # Finds all the routing topics matching requested topic within all topics or within
9
+ # provided consumer group based on name
10
+ #
11
+ # @param requested_topic [String] requested topic name
12
+ # @param requested_consumer_group [String] requested consumer group or nil to look in all
13
+ # @return [Array<Karafka::Routing::Topic>] all matching topics
14
+ #
15
+ # @note Since we run the lookup on subscription groups, the search will automatically
16
+ # expand with matching patterns
17
+ def karafka_consumer_find_candidate_topics(requested_topic, requested_consumer_group)
18
+ karafka_consumer_find_subscription_groups(requested_consumer_group)
19
+ # multiplexed subscriptions of the same origin share name, thus we can reduced
20
+ # multiplexing to the first one as during testing, there is no multiplexing parallel
21
+ # execution anyhow
22
+ .uniq(&:name)
23
+ .map(&:topics)
24
+ .filter_map do |topics|
25
+ topics.find(requested_topic.to_s)
26
+ rescue Karafka::Errors::TopicNotFoundError
27
+ nil
28
+ end
29
+ end
30
+
31
+ # Finds subscription groups from the requested consumer group or selects all if no
32
+ # consumer group specified
33
+ # @param requested_consumer_group [String] requested consumer group or nil to look in all
34
+ # @return [Array<Karafka::Routing::SubscriptionGroup>] requested subscription groups
35
+ def karafka_consumer_find_subscription_groups(requested_consumer_group)
36
+ if requested_consumer_group && !requested_consumer_group.empty?
37
+ ::Karafka::App
38
+ .subscription_groups
39
+ # Find matching consumer group
40
+ .find { |cg, _sgs| cg.name == requested_consumer_group.to_s }
41
+ # Raise error if not found
42
+ .tap { |cg| cg || raise(Errors::ConsumerGroupNotFound, requested_consumer_group) }
43
+ # Since lookup was on a hash, get the value, that is subscription groups
44
+ .last
45
+ else
46
+ ::Karafka::App
47
+ .subscription_groups
48
+ .values
49
+ .flatten
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'karafka/testing'
4
4
  require 'karafka/testing/errors'
5
+ require 'karafka/testing/helpers'
5
6
  require 'karafka/testing/spec_consumer_client'
6
7
  require 'karafka/testing/spec_producer_client'
7
8
  require 'karafka/testing/minitest/proxy'
@@ -56,7 +57,7 @@ module Karafka
56
57
  # @example Creates a consumer instance with settings for `my_requested_topic`
57
58
  # consumer = @karafka.consumer_for(:my_requested_topic)
58
59
  def _karafka_consumer_for(requested_topic, requested_consumer_group = nil)
59
- selected_topics = _karafka_consumer_find_candidate_topics(
60
+ selected_topics = Testing::Helpers.karafka_consumer_find_candidate_topics(
60
61
  requested_topic.to_s,
61
62
  requested_consumer_group.to_s
62
63
  )
@@ -169,48 +170,6 @@ module Karafka
169
170
  @consumer.instance_variable_set('@used', true)
170
171
  @consumer
171
172
  end
172
-
173
- # Finds all the routing topics matching requested topic within all topics or within
174
- # provided consumer group based on name
175
- #
176
- # @param requested_topic [String] requested topic name
177
- # @param requested_consumer_group [String] requested consumer group or nil to look in all
178
- # @return [Array<Karafka::Routing::Topic>] all matching topics
179
- #
180
- # @note Since we run the lookup on subscription groups, the search will automatically
181
- # expand with matching patterns
182
- def _karafka_consumer_find_candidate_topics(requested_topic, requested_consumer_group)
183
- _karafka_consumer_find_subscription_groups(requested_consumer_group)
184
- .map(&:topics)
185
- .filter_map do |topics|
186
- topics.find(requested_topic.to_s)
187
- rescue Karafka::Errors::TopicNotFoundError
188
- nil
189
- end
190
- .uniq(&:consumer_group)
191
- end
192
-
193
- # Finds subscription groups from the requested consumer group or selects all if no
194
- # consumer group specified
195
- # @param requested_consumer_group [String] requested consumer group or nil to look in all
196
- # @return [Array<Karafka::Routing::SubscriptionGroup>] requested subscription groups
197
- def _karafka_consumer_find_subscription_groups(requested_consumer_group)
198
- if requested_consumer_group && !requested_consumer_group.empty?
199
- ::Karafka::App
200
- .subscription_groups
201
- # Find matching consumer group
202
- .find { |cg, _sgs| cg.name == requested_consumer_group.to_s }
203
- # Raise error if not found
204
- .tap { |cg| cg || raise(Errors::ConsumerGroupNotFound, requested_consumer_group) }
205
- # Since lookup was on a hash, get the value, that is subscription groups
206
- .last
207
- else
208
- ::Karafka::App
209
- .subscription_groups
210
- .values
211
- .flatten
212
- end
213
- end
214
173
  end
215
174
  end
216
175
  end
@@ -3,6 +3,7 @@
3
3
  require 'waterdrop'
4
4
  require 'karafka/testing'
5
5
  require 'karafka/testing/errors'
6
+ require 'karafka/testing/helpers'
6
7
  require 'karafka/testing/spec_consumer_client'
7
8
  require 'karafka/testing/spec_producer_client'
8
9
  require 'karafka/testing/rspec/proxy'
@@ -60,7 +61,7 @@ module Karafka
60
61
  # subject(:consumer) { karafka.consumer_for(:my_requested_topic) }
61
62
  # end
62
63
  def _karafka_consumer_for(requested_topic, requested_consumer_group = nil)
63
- selected_topics = _karafka_consumer_find_candidate_topics(
64
+ selected_topics = Testing::Helpers.karafka_consumer_find_candidate_topics(
64
65
  requested_topic.to_s,
65
66
  requested_consumer_group.to_s
66
67
  )
@@ -179,48 +180,6 @@ module Karafka
179
180
  consumer.instance_variable_set('@used', true)
180
181
  consumer
181
182
  end
182
-
183
- # Finds all the routing topics matching requested topic within all topics or within
184
- # provided consumer group based on name
185
- #
186
- # @param requested_topic [String] requested topic name
187
- # @param requested_consumer_group [String] requested consumer group or nil to look in all
188
- # @return [Array<Karafka::Routing::Topic>] all matching topics
189
- #
190
- # @note Since we run the lookup on subscription groups, the search will automatically
191
- # expand with matching patterns
192
- def _karafka_consumer_find_candidate_topics(requested_topic, requested_consumer_group)
193
- _karafka_consumer_find_subscription_groups(requested_consumer_group)
194
- .map(&:topics)
195
- .filter_map do |topics|
196
- topics.find(requested_topic.to_s)
197
- rescue Karafka::Errors::TopicNotFoundError
198
- nil
199
- end
200
- .uniq(&:consumer_group)
201
- end
202
-
203
- # Finds subscription groups from the requested consumer group or selects all if no
204
- # consumer group specified
205
- # @param requested_consumer_group [String] requested consumer group or nil to look in all
206
- # @return [Array<Karafka::Routing::SubscriptionGroup>] requested subscription groups
207
- def _karafka_consumer_find_subscription_groups(requested_consumer_group)
208
- if requested_consumer_group && !requested_consumer_group.empty?
209
- ::Karafka::App
210
- .subscription_groups
211
- # Find matching consumer group
212
- .find { |cg, _sgs| cg.name == requested_consumer_group.to_s }
213
- # Raise error if not found
214
- .tap { |cg| cg || raise(Errors::ConsumerGroupNotFound, requested_consumer_group) }
215
- # Since lookup was on a hash, get the value, that is subscription groups
216
- .last
217
- else
218
- ::Karafka::App
219
- .subscription_groups
220
- .values
221
- .flatten
222
- end
223
- end
224
183
  end
225
184
  end
226
185
  end
@@ -4,6 +4,6 @@
4
4
  module Karafka
5
5
  module Testing
6
6
  # Current version of gem. It should match Karafka framework version
7
- VERSION = '2.4.0.rc1'
7
+ VERSION = '2.4.0'
8
8
  end
9
9
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0.rc1
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
36
36
  msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
37
37
  -----END CERTIFICATE-----
38
- date: 2024-04-10 00:00:00.000000000 Z
38
+ date: 2024-04-26 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka
@@ -43,7 +43,7 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.4.0.beta1
46
+ version: 2.4.0
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
49
  version: 2.5.0
@@ -53,7 +53,7 @@ dependencies:
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 2.4.0.beta1
56
+ version: 2.4.0
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
59
  version: 2.5.0
@@ -63,14 +63,14 @@ dependencies:
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 2.7.0.rc1
66
+ version: 2.7.0
67
67
  type: :runtime
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 2.7.0.rc1
73
+ version: 2.7.0
74
74
  description: Library which provides helpers for easier Karafka consumers tests
75
75
  email:
76
76
  - contact@karafka.io
@@ -97,6 +97,7 @@ files:
97
97
  - lib/karafka-testing.rb
98
98
  - lib/karafka/testing.rb
99
99
  - lib/karafka/testing/errors.rb
100
+ - lib/karafka/testing/helpers.rb
100
101
  - lib/karafka/testing/minitest/helpers.rb
101
102
  - lib/karafka/testing/minitest/proxy.rb
102
103
  - lib/karafka/testing/rspec/helpers.rb
@@ -131,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  - !ruby/object:Gem::Version
132
133
  version: '0'
133
134
  requirements: []
134
- rubygems_version: 3.5.3
135
+ rubygems_version: 3.5.9
135
136
  signing_key:
136
137
  specification_version: 4
137
138
  summary: Library which provides helpers for easier Karafka consumers tests
metadata.gz.sig CHANGED
Binary file