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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +3 -1
- data/Gemfile.lock +11 -11
- data/karafka-testing.gemspec +2 -2
- 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 +8 -7
- 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: f0075ae4b6753ffed88f26fe1e9a65ebd9927ee0aa22dd5b5a720597d89f8921
|
4
|
+
data.tar.gz: f2bdfa9155f2d614ce9946e6387676fff10424a2d8a5a3f391c57795c3a4556b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
1
|
+
3.3.1
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# Karafka Test gem changelog
|
2
2
|
|
3
|
-
## 2.4.0 (
|
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
|
5
|
-
karafka (>= 2.4.0
|
6
|
-
waterdrop (>= 2.7.0
|
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
|
13
|
-
karafka-core (>= 2.4.0
|
14
|
-
waterdrop (>= 2.7.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
|
17
|
-
karafka-rdkafka (>= 0.15.0
|
18
|
-
karafka-rdkafka (0.15.0
|
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
|
25
|
-
karafka-core (>= 2.4.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
|
|
data/karafka-testing.gemspec
CHANGED
@@ -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
|
28
|
-
spec.add_dependency 'waterdrop', '>= 2.7.0
|
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 =
|
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
|
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-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
|
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
|
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
|
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
|
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.
|
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
|