karafka-testing 2.3.3 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91a12f6c61514bc890bdfd8f6c91e1a834dd1516299f8a6d421c54037d3b55b3
4
- data.tar.gz: 70d467cb5994992d5a3046511bca0676fabc673b2b36c45d366b98d6aeeeae06
3
+ metadata.gz: 6aecdc81babc8c73c80c65934abb2dfcddd59a919228cf0a62afe4fa787c7e68
4
+ data.tar.gz: 1be6197c9e2f9186b8e56e176351254eb54726166cfdf4ebbd2ee48836c08048
5
5
  SHA512:
6
- metadata.gz: ebb18327ff48e4443377a54a09d35611c84f6806bc298ceb0792d1b2862f7f1c35e2c528bdb8b7e611d61998201f851dc8648530d398fdbbd33ec504d7fedae7
7
- data.tar.gz: 9898b5f1bd9264b696361cfd60039226864eb26743722c21a251fad26d2bd9d633b9be0cadcf62dbc7638a5287b69a0aaf720b12ad70595cc03c6bc1c4fe920f
6
+ metadata.gz: 7a2ec5091955cafed3cafcd29407ac8ac38b90c378c2a950fd9ad7690582c9a1b7553ad64bbd0763783ecda5b75d507f821f8f6555fe81c665b4cf78c0b175e3
7
+ data.tar.gz: 406958b6a7c9ee99e446ebe33564a7ebb9e87c50384c89fc7b855ff280c68b51e15b2f3d50f0daa14faefcd58caed8bc0028a0bdb68cb3d26697dc49b2a54aab
checksums.yaml.gz.sig CHANGED
Binary file
@@ -22,7 +22,6 @@ jobs:
22
22
  - '3.2'
23
23
  - '3.1'
24
24
  - '3.0'
25
- - '2.7'
26
25
  include:
27
26
  - ruby: '3.3'
28
27
  coverage: 'true'
@@ -40,24 +39,14 @@ jobs:
40
39
 
41
40
  - name: Install latest bundler
42
41
  run: |
43
- if [[ "$(ruby -v | awk '{print $2}')" == 2.7.8* ]]; then
44
- gem install bundler -v 2.4.22 --no-document
45
- bundle config set version 2.4.22
46
- gem update --system 3.4.22 --no-document
47
- else
48
- gem install bundler --no-document
49
- gem update --system --no-document
50
- fi
42
+ gem install bundler --no-document
43
+ gem update --system --no-document
51
44
 
52
45
  bundle config set without 'tools benchmarks docs'
53
46
 
54
47
  - name: Bundle install
55
48
  run: |
56
- if [[ "$(ruby -v | awk '{print $2}')" == 2.7.8* ]]; then
57
- BUNDLER_VERSION=2.4.22 bundle install --jobs 4 --retry 3
58
- else
59
- bundle install --jobs 4 --retry 3
60
- fi
49
+ bundle install --jobs 4 --retry 3
61
50
 
62
51
  diffend:
63
52
  runs-on: ubuntu-latest
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.3.1
data/CHANGELOG.md CHANGED
@@ -1,7 +1,15 @@
1
1
  # Karafka Test gem changelog
2
2
 
3
- ## 2.3.3 (2024-04-19)
3
+ ## 2.4.2 (2024-06-30)
4
+ - [Fix] Fix FrozenError when accessing key and headers in `Karafka::Messages::Metadata` (tldn0718)
5
+
6
+ ## 2.4.1 (2024-06-29)
7
+ - [Fix] Fix instance variable in minitest helper (tldn0718)
8
+
9
+ ## 2.4.0 (2024-04-26)
10
+ - **[Breaking]** Drop Ruby `2.7` support.
4
11
  - [Refactor] Extract common components for Minitest and RSpec.
12
+ - [Fix] Support again `require: false` on gem loading.
5
13
  - [Fix] Fix a case where multiplexed SG would fail with `TopicInManyConsumerGroupsError`
6
14
 
7
15
  ## 2.3.2 (2024-04-03)
data/Gemfile.lock CHANGED
@@ -1,28 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-testing (2.3.3)
5
- karafka (>= 2.3.0, < 2.4.0)
6
- waterdrop (>= 2.6.12)
4
+ karafka-testing (2.4.2)
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.3.3)
13
- karafka-core (>= 2.3.0, < 2.4.0)
14
- waterdrop (>= 2.6.12, < 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.3.0)
17
- karafka-rdkafka (>= 0.14.8, < 0.15.0)
18
- karafka-rdkafka (0.14.10)
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
- rake (13.1.0)
24
- waterdrop (2.6.14)
25
- karafka-core (>= 2.2.3, < 3.0.0)
23
+ rake (13.2.1)
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
 
@@ -34,4 +34,4 @@ DEPENDENCIES
34
34
  karafka-testing!
35
35
 
36
36
  BUNDLED WITH
37
- 2.5.6
37
+ 2.5.7
@@ -24,8 +24,10 @@ 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.3.0', '< 2.4.0'
28
- spec.add_dependency 'waterdrop', '>= 2.6.12'
27
+ spec.add_dependency 'karafka', '>= 2.4.0', '< 2.5.0'
28
+ spec.add_dependency 'waterdrop', '>= 2.7.0'
29
+
30
+ spec.required_ruby_version = '>= 3.0.0'
29
31
 
30
32
  spec.metadata = {
31
33
  'funding_uri' => 'https://karafka.io/#become-pro',
@@ -15,7 +15,17 @@ module Karafka
15
15
  TopicInManyConsumerGroupsError = Class.new(BaseError)
16
16
 
17
17
  # Raised when you requested a topic from a consumer group that does not exist
18
- ConsumerGroupNotFound = Class.new(BaseError)
18
+ ConsumerGroupNotFoundError = Class.new(BaseError)
19
+
20
+ # Raised when trying to use testing without Karafka app being visible
21
+ # If you are seeing this error, then you tried to use testing helpers without Karafka being
22
+ # loaded prior to this happening.
23
+ KarafkaNotLoadedError = Class.new(BaseError)
24
+
25
+ # Raised when there is an attempt to use the testing primitives without Karafka app being
26
+ # configured. Prior to initialization process, most of config values are nils, etc and
27
+ # mocks will not work.
28
+ KarafkaNotInitializedError = Class.new(BaseError)
19
29
  end
20
30
  end
21
31
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'karafka/testing'
3
4
  require 'karafka/testing/errors'
4
5
  require 'karafka/testing/helpers'
5
6
  require 'karafka/testing/spec_consumer_client'
@@ -18,6 +19,8 @@ module Karafka
18
19
  # @param base [Class] Minitest example group we want to extend
19
20
  def included(base)
20
21
  eval_flow = lambda do
22
+ Karafka::Testing.ensure_karafka_initialized!
23
+
21
24
  @karafka = Karafka::Testing::Minitest::Proxy.new(self)
22
25
  @_karafka_consumer_messages = []
23
26
  @_karafka_consumer_client = Karafka::Testing::SpecConsumerClient.new
@@ -97,7 +100,7 @@ module Karafka
97
100
  # Add this message to previously produced messages
98
101
  @_karafka_consumer_messages << Karafka::Messages::Message.new(
99
102
  message[:payload],
100
- Karafka::Messages::Metadata.new(metadata).freeze
103
+ Karafka::Messages::Metadata.new(metadata)
101
104
  )
102
105
  # Update batch metadata
103
106
  batch_metadata = Karafka::Messages::Builders::BatchMetadata.call(
@@ -136,10 +139,10 @@ module Karafka
136
139
  # @return [Hash] message default options
137
140
  def _karafka_message_metadata_defaults
138
141
  {
139
- deserializer: @consumer.topic.deserializer,
142
+ deserializers: @consumer.topic.deserializers,
140
143
  timestamp: Time.now,
141
- headers: {},
142
- key: nil,
144
+ raw_headers: {},
145
+ raw_key: nil,
143
146
  offset: @_karafka_consumer_messages.size,
144
147
  partition: 0,
145
148
  received_at: Time.now,
@@ -160,7 +163,7 @@ module Karafka
160
163
  # Inject appropriate strategy so needed options and components are available
161
164
  strategy = Karafka::App.config.internal.processing.strategy_selector.find(topic)
162
165
  @consumer.singleton_class.include(strategy)
163
- @consumer.client = @karafka_consumer_client
166
+ @consumer.client = @_karafka_consumer_client
164
167
  @consumer.coordinator = coordinators.find_or_create(topic.name, 0)
165
168
  @consumer.coordinator.seek_offset = 0
166
169
  # Indicate usage as for tests no direct enqueuing happens
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'waterdrop'
4
+ require 'karafka/testing'
4
5
  require 'karafka/testing/errors'
5
6
  require 'karafka/testing/helpers'
6
7
  require 'karafka/testing/spec_consumer_client'
@@ -31,6 +32,8 @@ module Karafka
31
32
  base.let(:_karafka_producer_client) { Karafka::Testing::SpecProducerClient.new(self) }
32
33
 
33
34
  base.prepend_before do
35
+ Karafka::Testing.ensure_karafka_initialized!
36
+
34
37
  _karafka_consumer_messages.clear
35
38
  _karafka_producer_client.reset
36
39
 
@@ -105,7 +108,7 @@ module Karafka
105
108
  # Add this message to previously produced messages
106
109
  _karafka_consumer_messages << Karafka::Messages::Message.new(
107
110
  message[:payload],
108
- Karafka::Messages::Metadata.new(metadata).freeze
111
+ Karafka::Messages::Metadata.new(metadata)
109
112
  )
110
113
 
111
114
  # Update batch metadata
@@ -145,10 +148,10 @@ module Karafka
145
148
  # @return [Hash] message default options
146
149
  def _karafka_message_metadata_defaults
147
150
  {
148
- deserializer: consumer.topic.deserializer,
151
+ deserializers: consumer.topic.deserializers,
149
152
  timestamp: Time.now,
150
- headers: {},
151
- key: nil,
153
+ raw_headers: {},
154
+ raw_key: nil,
152
155
  offset: _karafka_consumer_messages.size,
153
156
  partition: 0,
154
157
  received_at: Time.now,
@@ -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.3.3'
7
+ VERSION = '2.4.2'
8
8
  end
9
9
  end
@@ -4,5 +4,32 @@
4
4
  module Karafka
5
5
  # Testing lib module
6
6
  module Testing
7
+ class << self
8
+ # Makes sure, that we do not use the testing stubs, etc when Karafka app is not loaded
9
+ #
10
+ # You should never use karafka-testing primitives when framework is not loaded because
11
+ # testing lib stubs certain pieces of Karafka that need to be initialized.
12
+ def ensure_karafka_loaded!
13
+ return if ::Karafka.const_defined?('App', false)
14
+
15
+ raise(
16
+ Karafka::Testing::Errors::KarafkaNotLoadedError,
17
+ 'Make sure to load Karafka framework prior to usage of the testing components.'
18
+ )
19
+ end
20
+
21
+ # If you do not initialize Karafka always within your specs, do not include/use this lib
22
+ # in places where Karafka would not be loaded.
23
+ def ensure_karafka_initialized!
24
+ ensure_karafka_loaded!
25
+
26
+ return unless Karafka::App.initializing?
27
+
28
+ raise(
29
+ Karafka::Testing::Errors::KarafkaNotInitializedError,
30
+ 'Make sure to initialize Karafka framework prior to usage of the testing components.'
31
+ )
32
+ end
33
+ end
7
34
  end
8
35
  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.3.3
4
+ version: 2.4.2
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-22 00:00:00.000000000 Z
38
+ date: 2024-04-30 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka
@@ -43,34 +43,34 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.3.0
46
+ version: 2.4.0
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
- version: 2.4.0
49
+ version: 2.5.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 2.3.0
56
+ version: 2.4.0
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
- version: 2.4.0
59
+ version: 2.5.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: waterdrop
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 2.6.12
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.6.12
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
@@ -125,14 +125,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
- version: '0'
128
+ version: 3.0.0
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.5.3
135
+ rubygems_version: 3.5.9
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: Library which provides helpers for easier Karafka consumers tests
metadata.gz.sig CHANGED
Binary file