logstash-integration-rabbitmq 7.0.0-java → 7.1.1-java

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.
@@ -2,7 +2,6 @@
2
2
  require "logstash/devutils/rspec/spec_helper"
3
3
  require "logstash/pipeline"
4
4
  require "logstash/outputs/rabbitmq"
5
- java_import java.util.concurrent.TimeoutException
6
5
 
7
6
  describe LogStash::Outputs::RabbitMQ do
8
7
  let(:klass) { LogStash::Outputs::RabbitMQ }
@@ -60,7 +59,7 @@ describe LogStash::Outputs::RabbitMQ do
60
59
  allow(connection).to receive(:on_blocked)
61
60
  allow(connection).to receive(:on_unblocked)
62
61
  allow(connection).to receive(:on_shutdown)
63
- allow(connection).to receive(:on_recovery_started)
62
+ allow(connection).to receive(:on_recovery_start)
64
63
  allow(connection).to receive(:on_recovery)
65
64
  allow(channel).to receive(:exchange).and_return(exchange)
66
65
 
@@ -84,18 +83,67 @@ describe LogStash::Outputs::RabbitMQ do
84
83
  before do
85
84
  allow(exchange).to receive(:publish).with(any_args)
86
85
  allow(event).to receive(:sprintf).with(key).and_return(sprinted_key)
87
- instance.send(:publish, event, encoded_event)
88
86
  end
89
87
 
90
88
  it "should send the correct message" do
89
+ instance.send(:publish, event, encoded_event)
91
90
  expect(exchange).to have_received(:publish).with(encoded_event, anything)
92
91
  end
93
92
 
94
93
  it "should send the correct metadata" do
95
94
  expected_metadata = {:routing_key => sprinted_key, :properties => {:persistent => persistent }}
96
95
 
96
+ instance.send(:publish, event, encoded_event)
97
+
97
98
  expect(exchange).to have_received(:publish).with(anything, expected_metadata)
98
99
  end
100
+
101
+ context 'with message_properties' do
102
+ let(:rabbitmq_settings) { super().merge("message_properties" => message_properties) }
103
+ let(:message_properties) { Hash.new }
104
+ context 'priority' do
105
+ let(:message_properties) { super().merge("priority" => priority) }
106
+ context 'as literal Integer value' do
107
+ let(:priority) { 3 }
108
+ it 'publishes with the constant-value priority' do
109
+ instance.send(:publish, event, encoded_event)
110
+ expect(exchange).to have_received(:publish).with(anything, hash_including(:properties => hash_including(:priority => 3)))
111
+ end
112
+ end
113
+
114
+ context 'as literal String value' do
115
+ let(:priority) { "7" }
116
+ it 'publishes with the constant-value priority' do
117
+ instance.send(:publish, event, encoded_event)
118
+ expect(exchange).to have_received(:publish).with(anything, hash_including(:properties => hash_including(:priority => 7)))
119
+ end
120
+ end
121
+
122
+ context 'as template value' do
123
+ let(:priority) { "%{[@metadata][priority]}" }
124
+ context 'when event expands template value' do
125
+ before do
126
+ expect(event).to receive(:sprintf).with(priority).and_return("31")
127
+ end
128
+
129
+ it 'publishes with the priority extracted from the event' do
130
+ instance.send(:publish, event, encoded_event)
131
+ expect(exchange).to have_received(:publish).with(anything, hash_including(:properties => hash_including(:priority => 31)))
132
+ end
133
+ end
134
+ context 'when event cannot expand template value' do
135
+ before do
136
+ expect(event).to receive(:sprintf).with(priority).and_return(priority)
137
+ end
138
+
139
+ it 'publishes with the priority of zero (`0`)' do
140
+ instance.send(:publish, event, encoded_event)
141
+ expect(exchange).to have_received(:publish).with(anything, hash_including(:properties => hash_including(:priority => 0)))
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
99
147
  end
100
148
 
101
149
  context 'when an exception is encountered' do
@@ -124,7 +172,7 @@ describe LogStash::Outputs::RabbitMQ do
124
172
  end
125
173
 
126
174
  context 'when it is a TimeoutException' do
127
- let(:exception) { TimeoutException.new }
175
+ let(:exception) { java.util.concurrent.TimeoutException.new }
128
176
  it_behaves_like 'recovers from exception gracefully'
129
177
  end
130
178
  end
@@ -133,14 +181,15 @@ describe LogStash::Outputs::RabbitMQ do
133
181
  end
134
182
 
135
183
 
136
- describe "with a live server", :integration => true do
184
+ describe "LogStash::Outputs::RabbitMQ with a live server", :integration => true do
185
+ let(:rabbitmq_host) { ENV["RABBITMQ_HOST"] || "127.0.0.1" }
137
186
  let(:klass) { LogStash::Outputs::RabbitMQ }
138
187
  let(:exchange) { "myexchange" }
139
188
  let(:exchange_type) { "topic" }
140
189
  let(:priority) { 34 }
141
190
  let(:default_plugin_config) {
142
191
  {
143
- "host" => "127.0.0.1",
192
+ "host" => rabbitmq_host,
144
193
  "exchange" => exchange,
145
194
  "exchange_type" => exchange_type,
146
195
  "key" => "foo",
@@ -14,12 +14,12 @@ end
14
14
 
15
15
  describe LogStash::PluginMixins::RabbitMQConnection do
16
16
  let(:klass) { TestPlugin }
17
+ let(:default_port) { 5672 }
17
18
  let(:host) { "localhost" }
18
- let(:port) { 5672 }
19
+ let(:port) { default_port }
19
20
  let(:rabbitmq_settings) {
20
21
  {
21
- "host" => host,
22
- "port" => port,
22
+ "host" => host
23
23
  }
24
24
  }
25
25
  let(:instance) {
@@ -27,6 +27,22 @@ describe LogStash::PluginMixins::RabbitMQConnection do
27
27
  }
28
28
  let(:hare_info) { instance.instance_variable_get(:@hare_info) }
29
29
 
30
+ shared_examples_for 'it sets the addresses correctly' do
31
+ let(:file) { Stud::Temporary.file }
32
+ let(:path) { file.path }
33
+ let(:host) {%w(host01 host02 host03)}
34
+
35
+ it "should set addresses to the expected value" do
36
+ host.each_with_index do |each_host, index|
37
+ expect(instance.rabbitmq_settings[:addresses][index]).to eql("#{each_host}:#{port}")
38
+ end
39
+ end
40
+
41
+ it "should insert the correct number of address entries" do
42
+ expect(instance.rabbitmq_settings[:addresses].length).to eql(host.count)
43
+ end
44
+ end
45
+
30
46
  describe "rabbitmq_settings" do
31
47
  let(:file) { Stud::Temporary.file }
32
48
  let(:path) { file.path }
@@ -59,12 +75,13 @@ describe LogStash::PluginMixins::RabbitMQConnection do
59
75
  expect(instance.rabbitmq_settings[:tls_certificate_password]).to eql(rabbitmq_settings["ssl_certificate_password"])
60
76
  end
61
77
 
62
- it "should set hosts to the expected value " do
63
- expect(instance.rabbitmq_settings[:hosts][0]).to eql(host)
64
- end
78
+ it_behaves_like 'it sets the addresses correctly'
79
+
80
+ context 'with a custom port' do
81
+ let(:port) { 123 }
82
+ let(:rabbitmq_settings) { super.merge({"port" => port})}
65
83
 
66
- it "should only insert a single host entry" do
67
- expect(instance.rabbitmq_settings[:hosts].length).to eql(1)
84
+ it_behaves_like 'it sets the addresses correctly'
68
85
  end
69
86
  end
70
87
 
@@ -79,21 +96,25 @@ describe LogStash::PluginMixins::RabbitMQConnection do
79
96
  end
80
97
 
81
98
  end
82
- describe "rabbitmq_settings multiple hosts" do
83
- let(:file) { Stud::Temporary.file }
84
- let(:path) { file.path }
85
- after { File.unlink(path)}
86
99
 
87
- let(:rabbitmq_settings) { super.merge({"host" => ["host01", "host02", "host03"]}) }
100
+ describe "rabbitmq_settings with multiple hosts" do
101
+ it_behaves_like 'it sets the addresses correctly'
102
+
103
+ context 'with a custom port' do
104
+ let(:port) { 999 }
105
+ let(:rabbitmq_settings) { super.merge({"port" => port})}
88
106
 
89
- it "should set hosts to the expected value" do
90
- expect(instance.rabbitmq_settings[:hosts][0]).to eql("host01")
91
- expect(instance.rabbitmq_settings[:hosts][1]).to eql("host02")
92
- expect(instance.rabbitmq_settings[:hosts][2]).to eql("host03")
107
+ it_behaves_like 'it sets the addresses correctly'
93
108
  end
94
109
 
95
- it "should insert 3 host entries" do
96
- expect(instance.rabbitmq_settings[:hosts].length).to eql(3)
110
+ context 'when ports are set in the host definition' do
111
+ let(:host) { %w(host01:4444 host02:4445 host03:4446)}
112
+
113
+ it "should set the address correctly" do
114
+ expect(instance.rabbitmq_settings[:addresses][0]).to eql("host01:4444")
115
+ expect(instance.rabbitmq_settings[:addresses][1]).to eql("host02:4445")
116
+ expect(instance.rabbitmq_settings[:addresses][2]).to eql("host03:4446")
117
+ end
97
118
  end
98
119
  end
99
120
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-integration-rabbitmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.1.1
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-15 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -103,17 +103,17 @@ dependencies:
103
103
  - !ruby/object:Gem::Dependency
104
104
  requirement: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ">="
106
+ - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '0'
108
+ version: '2.0'
109
109
  name: logstash-devutils
110
110
  prerelease: false
111
111
  type: :development
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - ">="
114
+ - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '0'
116
+ version: '2.0'
117
117
  - !ruby/object:Gem::Dependency
118
118
  requirement: !ruby/object:Gem::Requirement
119
119
  requirements:
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  version: '0'
219
219
  requirements: []
220
220
  rubyforge_project:
221
- rubygems_version: 2.7.9
221
+ rubygems_version: 2.6.13
222
222
  signing_key:
223
223
  specification_version: 4
224
224
  summary: Integration with RabbitMQ - input and output plugins