deimos-ruby 1.10.2 → 1.11.0

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: 4ef9a6d6960e0d8cf17946b13ba838646bc7bdbbad657131ebd36c7d41cacaf3
4
- data.tar.gz: d37cdef98e76e9136b745c70ba2d4b8e4d72de2032299911b3f7e86e99bd45b7
3
+ metadata.gz: ac454bfdafdeec22f07c9b00386dfcdd687ed1320288384f53f4541eb6037589
4
+ data.tar.gz: a012d3b33de492bf84d17c74da545dbd0180377fde07b0e52f8002806e3cc489
5
5
  SHA512:
6
- metadata.gz: 1f794bd76a0f227a3ddeee6cb2957549076f805b3c68a586c2907af7829f5dded8764d8a35faf9ef214beff310743850ad1d3ca8963a03bcee6707f63791eaeb
7
- data.tar.gz: aa129ceecf20171eb48de1fd24a06f4d5fa26470e80a05a51b0f541316969f5a724d7bf95c3f747043dc25e29d72ad119da94a63ba3dee74320ce6c621fde35e
6
+ metadata.gz: 6bad789e44e21108e652119640e641f4efa217398d8db89b1b734373f5bdc23cbdd60605828e4f6df9e366bac948512c9ff041222db8fd858605fb5a82e7fea9
7
+ data.tar.gz: 218fb6e258b3a7859644ece11feff5e27738cbe85c20830f704128c5e9fa3d50e764b4d178fc58ca31b35de90839cb1411d1cf98bcfe73c601162c8cb5017d83
data/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## UNRELEASED
9
+
10
+ ## 1.11.0 - 2021-08-27
11
+
12
+ - ### Fixes :wrench:
13
+ - Fixed issue where ActiveRecord batch consumption could fail when decoding keys.
14
+
15
+ - ### Roadmap :car:
16
+ - TestHelper does not automatically reset Deimos config before each test. [#120](https://github.com/flipp-oss/deimos/pull/120).
17
+ **Please note that this is a breaking change**
18
+
19
+
8
20
  ## 1.10.2 - 2021-07-20
9
21
 
10
22
  - ### Fixes :wrench:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deimos-ruby (1.10.1)
4
+ deimos-ruby (1.10.2)
5
5
  avro_turf (~> 0.11)
6
6
  fig_tree (~> 0.0.2)
7
7
  phobos (>= 1.9, < 3.0)
data/README.md CHANGED
@@ -29,6 +29,7 @@ Built on Phobos and hence Ruby-Kafka.
29
29
  * [Running Consumers](#running-consumers)
30
30
  * [Metrics](#metrics)
31
31
  * [Testing](#testing)
32
+ * [Test Helpers](#test-helpers)
32
33
  * [Integration Test Helpers](#integration-test-helpers)
33
34
  * [Utilities](#utilities)
34
35
  * [Contributing](#contributing)
@@ -946,6 +947,56 @@ require 'deimos/test_helpers'
946
947
  # Can pass a file path, a string or a hash into this:
947
948
  Deimos::TestHelpers.schemas_compatible?(schema1, schema2)
948
949
  ```
950
+ ### Test Helpers
951
+
952
+ There are helper methods available to configure Deimos for different types of testing scenarios.
953
+ Currently there are helpers defined for unit tests and for testing Kafka related code. You can use it as follows:
954
+
955
+ ```ruby
956
+ # The following can be added to a rpsec file so that each unit
957
+ # test can have the same settings every time it is run
958
+ around(:each) do |example|
959
+ Deimos::TestHelpers.unit_test!
960
+ example.run
961
+ Deimos.config.reset!
962
+ end
963
+
964
+ # Similarly you can use the Kafka test helper
965
+ around(:each) do |example|
966
+ Deimos::TestHelpers.kafka_test!
967
+ example.run
968
+ Deimos.config.reset!
969
+ end
970
+
971
+ # Kakfa test helper using schema registry
972
+ around(:each) do |example|
973
+ Deimos::TestHelpers.full_integration_test!
974
+ example.run
975
+ Deimos.config.reset!
976
+ end
977
+ ```
978
+
979
+ With the help of these helper methods, rspec examples can be written without having to tinker with Deimos settings.
980
+ This also prevents Deimos setting changes from leaking in to other examples.
981
+
982
+ This does not take away the ability to configure Deimos manually in individual examples. Deimos can still be configured like so:
983
+ ```ruby
984
+ it 'should not fail this random test' do
985
+
986
+ Deimos.configure do |config|
987
+ config.consumers.fatal_error = proc { true }
988
+ config.consumers.reraise_errors = false
989
+ end
990
+ ...
991
+ expect(some_object).to be_truthy
992
+ ...
993
+ Deimos.config.reset!
994
+ end
995
+ ```
996
+ If you are using one of the test helpers in an `around(:each)` block and want to override few settings for one example,
997
+ you can do it like in the example shown above. These settings would only apply to that specific example and the Deimos conifg should
998
+ reset once the example has finished running.
999
+
949
1000
 
950
1001
  ### Integration Test Helpers
951
1002
 
@@ -10,7 +10,7 @@ module Deimos
10
10
  class AvroSchemaRegistry < AvroBase
11
11
  # @override
12
12
  def decode_payload(payload, schema:)
13
- avro_turf_messaging.decode(payload, schema_name: schema)
13
+ avro_turf_messaging.decode(payload.to_s, schema_name: schema)
14
14
  end
15
15
 
16
16
  # @override
@@ -18,22 +18,39 @@ module Deimos
18
18
  def sent_messages
19
19
  Deimos::Backends::Test.sent_messages
20
20
  end
21
+
22
+ # Set the config to the right settings for a unit test
23
+ def unit_test!
24
+ Deimos.configure do |deimos_config|
25
+ deimos_config.logger = Logger.new(STDOUT)
26
+ deimos_config.consumers.reraise_errors = true
27
+ deimos_config.kafka.seed_brokers ||= ['test_broker']
28
+ deimos_config.schema.backend = Deimos.schema_backend_class.mock_backend
29
+ deimos_config.producers.backend = :test
30
+ end
31
+ end
32
+
33
+ # Kafka test config with avro schema registry
34
+ def full_integration_test!
35
+ Deimos.configure do |deimos_config|
36
+ deimos_config.producers.backend = :kafka
37
+ deimos_config.schema.backend = :avro_schema_registry
38
+ end
39
+ end
40
+
41
+ # Set the config to the right settings for a kafka test
42
+ def kafka_test!
43
+ Deimos.configure do |deimos_config|
44
+ deimos_config.producers.backend = :kafka
45
+ deimos_config.schema.backend = :avro_validation
46
+ end
47
+ end
21
48
  end
22
49
 
23
50
  included do
24
51
 
25
52
  RSpec.configure do |config|
26
53
 
27
- config.before(:suite) do
28
- Deimos.configure do |d_config|
29
- d_config.logger = Logger.new(STDOUT)
30
- d_config.consumers.reraise_errors = true
31
- d_config.kafka.seed_brokers ||= ['test_broker']
32
- d_config.schema.backend = Deimos.schema_backend_class.mock_backend
33
- d_config.producers.backend = :test
34
- end
35
- end
36
-
37
54
  config.prepend_before(:each) do
38
55
  client = double('client').as_null_object
39
56
  allow(client).to receive(:time) do |*_args, &block|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.10.2'
4
+ VERSION = '1.11.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.2
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-20 00:00:00.000000000 Z
11
+ date: 2021-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf