deimos-ruby 1.10.2 → 1.11.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
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +51 -0
- data/lib/deimos/schema_backends/avro_schema_registry.rb +1 -1
- data/lib/deimos/test_helpers.rb +27 -10
- data/lib/deimos/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac454bfdafdeec22f07c9b00386dfcdd687ed1320288384f53f4541eb6037589
|
4
|
+
data.tar.gz: a012d3b33de492bf84d17c74da545dbd0180377fde07b0e52f8002806e3cc489
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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
|
|
data/lib/deimos/test_helpers.rb
CHANGED
@@ -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|
|
data/lib/deimos/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro_turf
|