fluent-plugin-aws-sqs 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e960c029622511a676c30a88311bc2f322d67cf2672b893f109daa0db6a215d2
4
- data.tar.gz: 39e66e44e7639f72aaaca42d1d85e3ba21c0da3d11b40f314e5ee3a392037033
3
+ metadata.gz: 50685c5260965737557cc07ca01975b2fcb055fbab68d2fc0a805242b1a15fac
4
+ data.tar.gz: 20ce27643d10fe6b80d9f6b48b885c256869e92cc1c8854683b9c3a6ec026a2b
5
5
  SHA512:
6
- metadata.gz: 6f36ab932217826628fa09056bc7fb3d2f0d0578c1fefcdb4129fe6ff024d79d51a37bc34a70a5956efa3f99fd7548676033f2c073a2724ac4daeec3fca21d4e
7
- data.tar.gz: f6333b2e24c65fdda88a5538c605ee149a4165735f08cd69a689c246344bf79e6a3893fc16d1beb30f44b2282682beb6d08c623359972a0e767d59850bcd2c5f
6
+ metadata.gz: a3a1971248f41a9ef47f3582b3ed786e91ec098c37cef776ab4f5508464256f4a297a5839c8fe49921a7e57385d567f77cb4facc64cc2a0bd1d66204f237edf0
7
+ data.tar.gz: f4d5d67dc5fdeb0c46841844bf5bbb4f59d700a7a86961ee2fca5f77a594482e140019a9bf7d5d1dc06aaa8d9fe2915d4672e40569de3f88d90e0eed796877a0
data/.gitignore CHANGED
@@ -5,3 +5,6 @@
5
5
  !.vscode/extensions.json
6
6
  .history/
7
7
  .idea/*
8
+ *.gem
9
+ .bundle/
10
+ vendor/
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-plugin-aws-sqs (1.0.1)
5
+ aws-sdk-sqs (>= 1.22.0)
6
+ fluentd (>= 0.14.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ aws-eventstream (1.0.3)
12
+ aws-partitions (1.215.0)
13
+ aws-sdk-core (3.68.0)
14
+ aws-eventstream (~> 1.0, >= 1.0.2)
15
+ aws-partitions (~> 1.0)
16
+ aws-sigv4 (~> 1.1)
17
+ jmespath (~> 1.0)
18
+ aws-sdk-sqs (1.22.0)
19
+ aws-sdk-core (~> 3, >= 3.61.1)
20
+ aws-sigv4 (~> 1.1)
21
+ aws-sigv4 (1.1.0)
22
+ aws-eventstream (~> 1.0, >= 1.0.2)
23
+ concurrent-ruby (1.1.5)
24
+ cool.io (1.5.4)
25
+ dig_rb (1.0.1)
26
+ fluentd (1.7.1)
27
+ cool.io (>= 1.4.5, < 2.0.0)
28
+ dig_rb (~> 1.0.0)
29
+ http_parser.rb (>= 0.5.1, < 0.7.0)
30
+ msgpack (>= 1.2.0, < 2.0.0)
31
+ serverengine (>= 2.0.4, < 3.0.0)
32
+ sigdump (~> 0.2.2)
33
+ strptime (>= 0.2.2, < 1.0.0)
34
+ tzinfo (~> 2.0)
35
+ tzinfo-data (~> 1.0)
36
+ yajl-ruby (~> 1.0)
37
+ http_parser.rb (0.6.0)
38
+ jmespath (1.4.0)
39
+ msgpack (1.3.1)
40
+ power_assert (1.1.5)
41
+ rake (12.3.3)
42
+ rr (1.2.1)
43
+ serverengine (2.1.1)
44
+ sigdump (~> 0.2.2)
45
+ sigdump (0.2.4)
46
+ strptime (0.2.3)
47
+ test-unit (3.3.3)
48
+ power_assert
49
+ test-unit-rr (1.0.5)
50
+ rr (>= 1.1.1)
51
+ test-unit (>= 2.5.2)
52
+ tzinfo (2.0.0)
53
+ concurrent-ruby (~> 1.0)
54
+ tzinfo-data (1.2019.3)
55
+ tzinfo (>= 1.0.0)
56
+ yajl-ruby (1.4.1)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ bundler
63
+ fluent-plugin-aws-sqs!
64
+ rake (~> 12.0)
65
+ test-unit (>= 3.1.0)
66
+ test-unit-rr
67
+
68
+ BUNDLED WITH
69
+ 1.17.3
data/Rakefile CHANGED
@@ -2,6 +2,6 @@
2
2
  require 'rake/testtask'
3
3
  Rake::TestTask.new(:test) do |test|
4
4
  test.libs << 'lib' << 'test'
5
- test.pattern = 'test/**/test_*.rb'
5
+ test.pattern = 'tests/**/test_*.rb'
6
6
  test.verbose = true
7
7
  end
@@ -10,10 +10,10 @@ module Fluent::Plugin
10
10
  config_param :aws_key_id, :string, default: nil, secret: true
11
11
  config_param :aws_sec_key, :string, default: nil, secret: true
12
12
  config_param :tag, :string
13
- config_param :region, :string, default: 'ap-northeast-1'
13
+ config_param :region, :string, default: 'eu-central-1'
14
14
  config_param :sqs_url, :string, default: nil
15
15
  config_param :receive_interval, :time, default: 0.1
16
- config_param :max_number_of_messages, :integer, default: 10
16
+ config_param :max_number_of_messages, :integer, default: 100
17
17
  config_param :wait_time_seconds, :integer, default: 10
18
18
  config_param :visibility_timeout, :integer, default: nil
19
19
  config_param :delete_message, :bool, default: false
@@ -22,6 +22,23 @@ module Fluent::Plugin
22
22
  def configure(conf)
23
23
  super
24
24
 
25
+ # configured "port" is referred by `@port` or instance method #port
26
+ if @aws_key_id == nil
27
+ raise Fluent::ConfigError, "aws_key_id configuration key is mandatory"
28
+ end
29
+
30
+ if @aws_sec_key == nil
31
+ raise Fluent::ConfigError, "aws_sec_key configuration key is mandatory"
32
+ end
33
+
34
+ if @tag == nil
35
+ raise Fluent::ConfigError, "tag configuration key is mandatory"
36
+ end
37
+
38
+ if @sqs_url == nil
39
+ raise Fluent::ConfigError, "sqs_url configuration key is mandatory"
40
+ end
41
+
25
42
  Aws.config = {
26
43
  access_key_id: @aws_key_id,
27
44
  secret_access_key: @aws_sec_key,
@@ -64,8 +81,6 @@ module Fluent::Plugin
64
81
  log.warn_backtrace ex.backtrace
65
82
  end
66
83
 
67
- private
68
-
69
84
  def parse_message(message)
70
85
  {
71
86
  'body' => message.body.to_s,
@@ -1,3 +1,3 @@
1
1
  module SQS
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -0,0 +1,80 @@
1
+ require "test-unit"
2
+ require "fluent/test"
3
+ require "fluent/test/driver/input"
4
+ require "fluent/test/helpers"
5
+ require "./lib/fluent/plugin/in-sqs.rb"
6
+
7
+ class InSqsTest < Test::Unit::TestCase
8
+ include Fluent::Test::Helpers
9
+
10
+ # default configuration for tests
11
+ DEFAULT_VALID_CONFIG = %[
12
+ aws_key_id test_aws_key_id
13
+ aws_sec_key test_aws_sec_key
14
+ tag test_tag
15
+ sqs_url http://sqs-url.com
16
+ ]
17
+
18
+ setup do
19
+ Fluent::Test.setup # this is required to setup router and others
20
+ end
21
+
22
+ def create_driver(conf = DEFAULT_VALID_CONFIG)
23
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::SQSInput).configure(conf)
24
+ end
25
+
26
+ sub_test_case 'configured with invalid configurations' do
27
+ test 'should reject because aws_key_id is missing' do
28
+ assert_raise Fluent::ConfigError do
29
+ create_driver(%[
30
+ aws_sec_key test_aws_sec_key
31
+ tag tag
32
+ sqs_url http://sqs-url.com
33
+ ])
34
+ end
35
+ end
36
+
37
+ test 'should reject because aws_sec_key is missing' do
38
+ assert_raise Fluent::ConfigError do
39
+ create_driver(%[
40
+ aws_key_id test_aws_key_id
41
+ tag tag
42
+ sqs_url http://sqs-url.com
43
+ ])
44
+ end
45
+ end
46
+
47
+ test 'should reject because tag is missing' do
48
+ assert_raise Fluent::ConfigError do
49
+ create_driver(%[
50
+ aws_sec_key test_aws_sec_key
51
+ aws_key_id test_aws_key_id
52
+ sqs_url http://sqs-url.com
53
+ ])
54
+ end
55
+ end
56
+
57
+ test 'should reject because sqs_url is missing' do
58
+ assert_raise Fluent::ConfigError do
59
+ create_driver(%[
60
+ aws_sec_key test_aws_sec_key
61
+ aws_key_id test_aws_key_id
62
+ tag test_tag
63
+ ])
64
+ end
65
+ end
66
+
67
+ test 'params are set correctly' do
68
+ d = create_driver
69
+ assert_equal "test_tag", d.instance.tag
70
+ assert_equal "test_aws_sec_key", d.instance.aws_sec_key
71
+ assert_equal "test_aws_key_id", d.instance.aws_key_id
72
+ assert_equal "eu-central-1", d.instance.region
73
+ assert_equal "http://sqs-url.com", d.instance.sqs_url
74
+ assert_equal 0.1, d.instance.receive_interval
75
+ assert_equal 100, d.instance.max_number_of_messages
76
+ assert_equal 10, d.instance.wait_time_seconds
77
+ end
78
+ end # end of configured with invalid configurations sub_test_case
79
+
80
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-aws-sqs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shai Moria
@@ -108,14 +108,14 @@ files:
108
108
  - ".gitignore"
109
109
  - ".gitlab-ci.yml"
110
110
  - Gemfile
111
+ - Gemfile.lock
111
112
  - README.md
112
113
  - Rakefile
113
114
  - VERSION
114
115
  - fluent-plugin-aws-sqs.gemspec
115
- - lib/fluent/plugin/in_sqs.rb
116
+ - lib/fluent/plugin/in-sqs.rb
116
117
  - lib/fluent/plugin/version.rb
117
- - spec/lib/fluent/plugin/in_sqs_spec.rb
118
- - spec/spec_helper.rb
118
+ - tests/test_in-sqs.rb
119
119
  homepage: https://github.com/zooz/fluent-plugin-aws-sqs
120
120
  licenses:
121
121
  - Apache-2.0
@@ -1,120 +0,0 @@
1
- require 'spec_helper'
2
- require 'fluent/plugin/in_sqs'
3
-
4
- describe Fluent::Plugin::SQSInput do
5
- let(:driver) do
6
- Fluent::Test.setup
7
- Fluent::Test::Driver::Input.new(Fluent::Plugin::SQSInput).configure(config)
8
- end
9
- subject { driver.instance }
10
-
11
- describe '#configure' do
12
- let(:config) do
13
- %(
14
- aws_key_id AWS_KEY_ID
15
- aws_sec_key AWS_SEC_KEY
16
- tag TAG
17
- region REGION
18
- sqs_url http://SQS_URL
19
- receive_interval 1
20
- max_number_of_messages 10
21
- wait_time_seconds 10
22
- visibility_timeout 1
23
- delete_message true
24
- stub_responses true
25
- )
26
- end
27
-
28
- context 'fluentd input configuration settings' do
29
- it { expect(subject.aws_key_id).to eq('AWS_KEY_ID') }
30
- it { expect(subject.aws_sec_key).to eq('AWS_SEC_KEY') }
31
- it { expect(subject.tag).to eq('TAG') }
32
- it { expect(subject.region).to eq('REGION') }
33
- it { expect(subject.sqs_url).to eq('http://SQS_URL') }
34
- it { expect(subject.receive_interval).to eq(1) }
35
- it { expect(subject.max_number_of_messages).to eq(10) }
36
- it { expect(subject.wait_time_seconds).to eq(10) }
37
- it { expect(subject.visibility_timeout).to eq(1) }
38
- it { expect(subject.delete_message).to eq(true) }
39
- it { expect(subject.stub_responses).to eq(true) }
40
- end
41
-
42
- context 'AWS configuration settings' do
43
- subject { Aws.config }
44
-
45
- before { driver.instance }
46
-
47
- it { expect(subject[:access_key_id]).to eq('AWS_KEY_ID') }
48
- it { expect(subject[:secret_access_key]).to eq('AWS_SEC_KEY') }
49
- it { expect(subject[:region]).to eq('REGION') }
50
- end
51
- end
52
-
53
- describe '#run' do
54
- let(:message_attributes) do
55
- {
56
- body: 'body',
57
- receipt_handle: 'receipt_handle',
58
- message_id: 'message_id',
59
- md5_of_body: 'md5_of_body',
60
- queue_url: 'queue_url',
61
- attributes: { 'SenderId' => 'sender_id' }
62
- }
63
- end
64
- let(:queue) { double(:queue, receive_messages: true) }
65
- let(:message) { double(:message, **message_attributes.merge(delete: nil)) }
66
- let(:messages) { [message] }
67
-
68
- context 'with no delete messages param' do
69
- let(:config) do
70
- %(
71
- tag TAG
72
- max_number_of_messages 10
73
- wait_time_seconds 10
74
- visibility_timeout 1
75
- delete_message false
76
- )
77
- end
78
-
79
- before do
80
- allow(subject).to receive(:queue) { queue }
81
- end
82
-
83
- it 'parse through messages and emit it' do
84
- expect(queue).to receive(:receive_messages)
85
- .with(max_number_of_messages: 10, wait_time_seconds: 10, visibility_timeout: 1) { messages }
86
- expect(subject).to receive(:parse_message).with(message) { message_attributes }
87
- expect(message).not_to receive(:delete)
88
- expect(subject.router).to receive(:emit).with('TAG', kind_of(Fluent::EventTime), message_attributes)
89
-
90
- subject.run
91
- end
92
- end
93
-
94
- context 'with no delete messages param' do
95
- let(:config) do
96
- %(
97
- tag TAG
98
- max_number_of_messages 10
99
- wait_time_seconds 10
100
- visibility_timeout 1
101
- delete_message true
102
- )
103
- end
104
-
105
- before do
106
- allow(subject).to receive(:queue) { queue }
107
- end
108
-
109
- it 'parse through messages and emit it' do
110
- expect(queue).to receive(:receive_messages)
111
- .with(max_number_of_messages: 10, wait_time_seconds: 10, visibility_timeout: 1) { messages }
112
- expect(subject).to receive(:parse_message).with(message) { message_attributes }
113
- expect(message).to receive(:delete)
114
- expect(subject.router).to receive(:emit).with('TAG', kind_of(Fluent::EventTime), message_attributes)
115
-
116
- subject.run
117
- end
118
- end
119
- end
120
- end
@@ -1,28 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
- RSpec.configure do |config|
8
- config.run_all_when_everything_filtered = true
9
- config.filter_run :focus
10
-
11
- # Run specs in random order to surface order dependencies. If you find an
12
- # order dependency and want to debug it, you can fix the order by providing
13
- # the seed, which is printed after each run.
14
- # --seed 1234
15
- config.order = 'random'
16
-
17
- require 'fluent/load'
18
- require 'fluent/test'
19
- require 'fluent/test/helpers'
20
- require 'fluent/test/driver/output'
21
- require 'fluent/test/driver/input'
22
-
23
- require 'ostruct'
24
- require 'pry'
25
- require 'rr'
26
- # prevent Test::Unit's AutoRunner from executing during RSpec's rake task
27
- Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
28
- end