logstash-mixin-rabbitmq_connection 6.0.0-java → 6.2.0-java

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: bd7fc8e31d1c925fe7f8aa9f2fcd35ecf711060d15f3ec6b3bf1587ce6e3e853
4
- data.tar.gz: 2bd3d32bd653b36eb943667b43b6fe495f3bf6a448aa4b7a21df2beba82f7386
3
+ metadata.gz: facc2c0bbb94d9ffe28e084637a8bffdafd34b6b7ac1585bf44a519d4043253c
4
+ data.tar.gz: d7462fe30d31bd4851210100e0ddf6506a3045f2777dc877a77c06a320f24abd
5
5
  SHA512:
6
- metadata.gz: f0d7510ed02b889bab83f1837f4f4452d18573323f4fec480333fe9652b77db559a4289895fc858cc96794fd1625bd6a163282b35a99847f2eddd4718f942ac1
7
- data.tar.gz: 1b9d536f7e0c4d5a5648696e6cf19d752e482407e765b8c4a2b0a3857ab608b790588ca8e28b27827c5ce5891e6ca17f1341e36fb1bc3fc7d304775e3215505f
6
+ metadata.gz: bf0e3772d6d7ef7b0c1f9c77aab348a1dd8fe2bba5d7afa78abbdc4cacd72f13397406d6a7edc7aef0493ad17f71e74d0ef5be81517bcbf4a3200773d4a0eda0
7
+ data.tar.gz: 5b3790fa5d4dc80eed67701bd05712ede0299d0b2569905385758f54c7a9ab17fd87fe4cca9602128176eb1dacc7210f45c1b49202d98a77e42830a60346e961
@@ -0,0 +1,17 @@
1
+ version: '3'
2
+
3
+ # run tests: cd ci/unit; docker-compose up --build --force-recreate
4
+ # manual: cd ci/unit; docker-compose run logstash bash
5
+ services:
6
+
7
+ logstash:
8
+ build:
9
+ context: ../
10
+ dockerfile: .ci/Dockerfile
11
+ args:
12
+ - ELASTIC_STACK_VERSION=$ELASTIC_STACK_VERSION
13
+ command: .ci/run.sh
14
+ environment:
15
+ LS_JAVA_OPTS: "-Xmx256m -Xms256m"
16
+ LOGSTASH_SOURCE: 1
17
+ tty: true
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is intended to be run inside the docker container as the command of the docker-compose.
4
+ set -ex
5
+
6
+ #bundle exec rspec -fd --pattern spec/**/*_spec.rb,spec/**/*_specs.rb
7
+ bundle exec rspec -fd
@@ -1,19 +1,2 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- matrix:
6
- include:
7
- - rvm: jruby-9.1.13.0
8
- env: LOGSTASH_BRANCH=master
9
- - rvm: jruby-9.1.13.0
10
- env: LOGSTASH_BRANCH=6.x
11
- - rvm: jruby-9.1.13.0
12
- env: LOGSTASH_BRANCH=6.5
13
- - rvm: jruby-1.7.27
14
- env: LOGSTASH_BRANCH=5.6
15
- fast_finish: true
16
- install: true
17
- script: ci/build.sh
18
- jdk: oraclejdk8
19
- before_install: gem install bundler -v '< 2'
1
+ import:
2
+ - logstash-plugins/.ci:travis/travis.yml@1.x
@@ -1,3 +1,13 @@
1
+ ## 6.2.0
2
+ - Remove ruby pipeline dependency. Starting from Logstash 8, Ruby execution engine is not available. All pipelines should use Java pipeline [#64](https://github.com/logstash-plugins/logstash-mixin-rabbitmq_connection/pull/64)
3
+ - Updated ci setting to use the share ci repository
4
+ ## 6.1.1
5
+ - Fixed issue with custom port assignment when multiple hosts are specified. [#54](https://github.com/logstash-plugins/logstash-mixin-rabbitmq_connection/pull/54)
6
+
7
+ ## 6.1.0
8
+ - Updated `march_hare` dependency to `4.x`, which enables consumers to reliably manage a connection blocked/unblocked state machine that survives connection recovery.
9
+ - Removed support for Logstash 5.x since `march_hare` >= 3.x is not compatible.
10
+
1
11
  ## 6.0.0
2
12
  - Removed obsolete options `verify_ssl`, `debug`, `tls_certificate_path` and `tls_certificate_password`
3
13
 
@@ -3,6 +3,7 @@ require "logstash/outputs/base"
3
3
  require "logstash/namespace"
4
4
  require "march_hare"
5
5
  require "java"
6
+ require "stud/interval"
6
7
 
7
8
  # Common functionality for the rabbitmq input/output
8
9
  module LogStash
@@ -95,8 +96,7 @@ module LogStash
95
96
 
96
97
  s = {
97
98
  :vhost => @vhost,
98
- :hosts => @host,
99
- :port => @port,
99
+ :addresses => addresses_from_hosts_and_port(@host, @port),
100
100
  :user => @user,
101
101
  :automatic_recovery => @automatic_recovery,
102
102
  :pass => @password ? @password.value : "guest",
@@ -122,6 +122,42 @@ module LogStash
122
122
  @rabbitmq_settings = s
123
123
  end
124
124
 
125
+
126
+ # Adds port to the value of host if it is not already supplied
127
+ def format_address(host, port)
128
+ case host.count(':')
129
+ when 0
130
+ "#{host}:#{port}"
131
+ when 1
132
+ host
133
+ else
134
+ format_ipv6(host, port)
135
+ end
136
+ end
137
+
138
+ # Formats an IPv6 to include the port, if it is not already given, conforming to the format used for
139
+ # literal IPv6 addresses in URIs,
140
+ # eg [2406:da00:ff00::6b15:edbc]:80
141
+ def format_ipv6(host, port)
142
+ last_bracket = host.rindex(']')
143
+ if last_bracket
144
+ if last_bracket < host.rindex(':')
145
+ host
146
+ else
147
+ "#{host}:#{port}"
148
+ end
149
+ else
150
+ "[#{host}]:#{port}"
151
+ end
152
+ end
153
+
154
+ def addresses_from_hosts_and_port(hosts, port)
155
+ # Expand host to include port, unless port is already present
156
+ # (Allowing hosts with port was a previously undocumented feature)
157
+ hosts.map{|host|format_address(host, port)}
158
+ end
159
+
160
+
125
161
  def connect!
126
162
  @hare_info = connect() unless @hare_info # Don't duplicate the conn!
127
163
  rescue MarchHare::Exception, java.io.IOException => e
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'logstash-mixin-rabbitmq_connection'
4
- s.version = '6.0.0'
4
+ s.version = '6.2.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Common functionality for RabbitMQ plugins"
7
7
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -17,7 +17,12 @@ Gem::Specification.new do |s|
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
18
 
19
19
  s.platform = RUBY_PLATFORM
20
- s.add_runtime_dependency 'march_hare', ['~> 3.0'] #(MIT license)
20
+
21
+ # MarchHare 3.x+ includes ruby syntax from 2.x
22
+ # This effectively requires Logstash >= 6.x
23
+ s.required_ruby_version = '>= 2.0.0'
24
+
25
+ s.add_runtime_dependency 'march_hare', ['~> 4.0'] #(MIT license)
21
26
  s.add_runtime_dependency 'stud', '~> 0.0.22'
22
27
 
23
28
  s.add_development_dependency 'logstash-devutils'
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/devutils/rspec/spec_helper"
3
- require "logstash/pipeline"
4
3
  require "logstash/plugin_mixins/rabbitmq_connection"
5
4
  require "stud/temporary"
6
5
 
@@ -14,12 +13,12 @@ end
14
13
 
15
14
  describe LogStash::PluginMixins::RabbitMQConnection do
16
15
  let(:klass) { TestPlugin }
16
+ let(:default_port) { 5672 }
17
17
  let(:host) { "localhost" }
18
- let(:port) { 5672 }
18
+ let(:port) { default_port }
19
19
  let(:rabbitmq_settings) {
20
20
  {
21
- "host" => host,
22
- "port" => port,
21
+ "host" => host
23
22
  }
24
23
  }
25
24
  let(:instance) {
@@ -27,6 +26,24 @@ describe LogStash::PluginMixins::RabbitMQConnection do
27
26
  }
28
27
  let(:hare_info) { instance.instance_variable_get(:@hare_info) }
29
28
 
29
+
30
+
31
+ shared_examples_for 'it sets the addresses correctly' do
32
+ let(:file) { Stud::Temporary.file }
33
+ let(:path) { file.path }
34
+
35
+ it "should set addresses to the expected value" do
36
+ host.each_with_index do |_, index|
37
+ puts(expected_values[index])
38
+ expect(instance.rabbitmq_settings[:addresses][index]).to eql(expected_values[index])
39
+ end
40
+ end
41
+
42
+ it "should insert the correct number of address entries" do
43
+ expect(instance.rabbitmq_settings[:addresses].length).to eql(host.count)
44
+ end
45
+ end
46
+
30
47
  describe "rabbitmq_settings" do
31
48
  let(:file) { Stud::Temporary.file }
32
49
  let(:path) { file.path }
@@ -59,12 +76,70 @@ describe LogStash::PluginMixins::RabbitMQConnection do
59
76
  expect(instance.rabbitmq_settings[:tls_certificate_password]).to eql(rabbitmq_settings["ssl_certificate_password"])
60
77
  end
61
78
 
62
- it "should set hosts to the expected value " do
63
- expect(instance.rabbitmq_settings[:hosts][0]).to eql(host)
79
+ context 'with host names' do
80
+ let (:host) {%w(localhost rmq.elastic.co rmq.local)}
81
+ let (:expected_values) {%w(localhost:5672 rmq.elastic.co:5672 rmq.local:5672)}
82
+
83
+ it_behaves_like 'it sets the addresses correctly'
84
+ end
85
+
86
+ context 'with host names including ports' do
87
+ let (:host) {%w(localhost:123 rmq.elastic.co:234 rmq.local:345)}
88
+ let (:expected_values) {%w(localhost:123 rmq.elastic.co:234 rmq.local:345)}
89
+
90
+ it_behaves_like 'it sets the addresses correctly'
64
91
  end
65
92
 
66
- it "should only insert a single host entry" do
67
- expect(instance.rabbitmq_settings[:hosts].length).to eql(1)
93
+ context 'with ipv4 ip addresses' do
94
+ let (:host) {%w(127.0.0.1 192.168.1.1 192.168.1.2)}
95
+ let (:expected_values) {%w(127.0.0.1:5672 192.168.1.1:5672 192.168.1.2:5672)}
96
+
97
+ it_behaves_like 'it sets the addresses correctly'
98
+ end
99
+
100
+ context 'with ipv4 ip addresses including ports' do
101
+ let (:host) {%w(127.0.0.1:123 192.168.1.1:234 192.168.1.2:345)}
102
+ let (:expected_values) {host}
103
+
104
+ it_behaves_like 'it sets the addresses correctly'
105
+ end
106
+
107
+ context 'with ipv6 addresses' do
108
+ let (:host) {%w(::1 fe80::1c86:a2e:4bec:4a9f%en0 2406:da00:ff00::36e1:f792 [::1] [fe80::1c86:a2e:4bec:4a9f%en0] [2406:da00:ff00::36e1:f792])}
109
+ let (:expected_values) {%w([::1]:5672 [fe80::1c86:a2e:4bec:4a9f%en0]:5672 [2406:da00:ff00::36e1:f792]:5672 [::1]:5672 [fe80::1c86:a2e:4bec:4a9f%en0]:5672 [2406:da00:ff00::36e1:f792]:5672)}
110
+ it_behaves_like 'it sets the addresses correctly'
111
+ end
112
+
113
+ context 'with ipv6 addresses including ports' do
114
+ let (:host) {%w([::1]:456 [fe80::1c86:a2e:4bec:4a9f%en0]:457 [2406:da00:ff00::36e1:f792]:458)}
115
+ let (:expected_values) {%w([::1]:456 [fe80::1c86:a2e:4bec:4a9f%en0]:457 [2406:da00:ff00::36e1:f792]:458)}
116
+ it_behaves_like 'it sets the addresses correctly'
117
+ end
118
+
119
+ context 'with a custom port' do
120
+ let(:port) { 123 }
121
+ let(:rabbitmq_settings) { super.merge({"port" => port})}
122
+
123
+ context 'with hostnames' do
124
+ let (:host) {%w(localhost rmq.elastic.co rmq.local)}
125
+ let (:expected_values) {%w(localhost:123 rmq.elastic.co:123 rmq.local:123)}
126
+
127
+ it_behaves_like 'it sets the addresses correctly'
128
+ end
129
+
130
+
131
+ context 'with ipv4 ip addresses' do
132
+ let (:host) {%w(127.0.0.1 192.168.1.1 192.168.1.2)}
133
+ let (:expected_values) {%w(127.0.0.1:123 192.168.1.1:123 192.168.1.2:123)}
134
+
135
+ it_behaves_like 'it sets the addresses correctly'
136
+ end
137
+
138
+ context 'with ipv6 addresses' do
139
+ let (:host) {%w(::1 fe80::1c86:a2e:4bec:4a9f%en0 2406:da00:ff00::36e1:f792 [::1] [fe80::1c86:a2e:4bec:4a9f%en0] [2406:da00:ff00::36e1:f792])}
140
+ let (:expected_values) {%w([::1]:123 [fe80::1c86:a2e:4bec:4a9f%en0]:123 [2406:da00:ff00::36e1:f792]:123 [::1]:123 [fe80::1c86:a2e:4bec:4a9f%en0]:123 [2406:da00:ff00::36e1:f792]:123)}
141
+ it_behaves_like 'it sets the addresses correctly'
142
+ end
68
143
  end
69
144
  end
70
145
 
@@ -79,23 +154,6 @@ describe LogStash::PluginMixins::RabbitMQConnection do
79
154
  end
80
155
 
81
156
  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
-
87
- let(:rabbitmq_settings) { super.merge({"host" => ["host01", "host02", "host03"]}) }
88
-
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")
93
- end
94
-
95
- it "should insert 3 host entries" do
96
- expect(instance.rabbitmq_settings[:hosts].length).to eql(3)
97
- end
98
- end
99
157
 
100
158
  context "when connected" do
101
159
  let(:connection) { double("MarchHare Connection") }
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-mixin-rabbitmq_connection
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.2.0
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-11 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '3.0'
18
+ version: '4.0'
19
19
  name: march_hare
20
20
  prerelease: false
21
21
  type: :runtime
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -88,6 +88,8 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
+ - ".ci/docker-compose.yml"
92
+ - ".ci/run.sh"
91
93
  - ".github/CONTRIBUTING.md"
92
94
  - ".github/ISSUE_TEMPLATE.md"
93
95
  - ".github/PULL_REQUEST_TEMPLATE.md"
@@ -97,8 +99,6 @@ files:
97
99
  - Gemfile
98
100
  - README.md
99
101
  - Rakefile
100
- - ci/build.sh
101
- - ci/setup.sh
102
102
  - lib/logstash/plugin_mixins/rabbitmq_connection.rb
103
103
  - logstash-mixin-rabbitmq_connection.gemspec
104
104
  - spec/fixtures/README.md
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 2.0.0
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">="
@@ -1,21 +0,0 @@
1
- #!/bin/bash
2
- # version: 1
3
- ########################################################
4
- #
5
- # AUTOMATICALLY GENERATED! DO NOT EDIT
6
- #
7
- ########################################################
8
- set -e
9
-
10
- echo "Starting build process in: `pwd`"
11
- source ./ci/setup.sh
12
-
13
- if [[ -f "ci/run.sh" ]]; then
14
- echo "Running custom build script in: `pwd`/ci/run.sh"
15
- source ./ci/run.sh
16
- else
17
- echo "Running default build scripts in: `pwd`/ci/build.sh"
18
- bundle install
19
- bundle exec rake vendor
20
- bundle exec rspec spec
21
- fi
@@ -1,26 +0,0 @@
1
- #!/bin/bash
2
- # version: 1
3
- ########################################################
4
- #
5
- # AUTOMATICALLY GENERATED! DO NOT EDIT
6
- #
7
- ########################################################
8
- set -e
9
- if [ "$LOGSTASH_BRANCH" ]; then
10
- echo "Building plugin using Logstash source"
11
- BASE_DIR=`pwd`
12
- echo "Checking out branch: $LOGSTASH_BRANCH"
13
- git clone -b $LOGSTASH_BRANCH https://github.com/elastic/logstash.git ../../logstash --depth 1
14
- printf "Checked out Logstash revision: %s\n" "$(git -C ../../logstash rev-parse HEAD)"
15
- cd ../../logstash
16
- echo "Building plugins with Logstash version:"
17
- cat versions.yml
18
- echo "---"
19
- # We need to build the jars for that specific version
20
- echo "Running gradle assemble in: `pwd`"
21
- ./gradlew assemble
22
- cd $BASE_DIR
23
- export LOGSTASH_SOURCE=1
24
- else
25
- echo "Building plugin using released gems on rubygems"
26
- fi