karafka-testing 2.4.0.rc1 → 2.4.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile.lock +1 -1
- data/lib/karafka/testing/helpers.rb +55 -0
- data/lib/karafka/testing/minitest/helpers.rb +2 -43
- data/lib/karafka/testing/rspec/helpers.rb +2 -43
- data/lib/karafka/testing/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91dfd9d61d189ef4382255dd90805291525c7ce596002f5932eddbf60d0ed4d4
|
4
|
+
data.tar.gz: c288612346f823379c454a2de964c6600a4705a99704c2261b78e8f685f33068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49458d3a51b4d8ba2a6b073c67dd43a85d1987aa9a300a1047a5268d6f61ae85d4c60a587fe9e8078bec0c61a900b129a8272a931a81fef3f017d548d04ce83b
|
7
|
+
data.tar.gz: 27e88641a3c2b0795731bebddf56bb5a81159730152c8fb3859543af5dcdb8bca9f762e4edaaafee931ef8cfc6d18f62c44a2993c321d44b104160826922d974
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
## 2.4.0 (Unreleased)
|
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
@@ -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 =
|
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 =
|
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
|
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.
|
4
|
+
version: 2.4.0.rc2
|
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-
|
38
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: karafka
|
@@ -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
|
metadata.gz.sig
CHANGED
Binary file
|