fluent-plugin-elb-access-log 0.3.7.pre.beta1 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -6
- data/fluent-plugin-elb-access-log.gemspec +3 -1
- data/lib/fluent/plugin/in_elb_access_log.rb +179 -52
- data/lib/fluent_plugin_elb_access_log/version.rb +1 -1
- data/spec/in_elb_access_log_alb_spec.rb +763 -0
- data/spec/{in_elb_access_log_spec.rb → in_elb_access_log_clb_spec.rb} +21 -10
- data/spec/in_elb_access_log_config_spec.rb +24 -0
- data/spec/spec_helper.rb +12 -1
- metadata +40 -10
@@ -32,13 +32,14 @@ describe Fluent::ElbAccessLogInput do
|
|
32
32
|
allow_any_instance_of(Fluent::ElbAccessLogInput).to receive(:load_history) { [] }
|
33
33
|
allow_any_instance_of(Fluent::ElbAccessLogInput).to receive(:parse_tsfile) { nil }
|
34
34
|
allow(FileUtils).to receive(:touch)
|
35
|
-
|
35
|
+
expect(driver.instance.log).to_not receive(:error)
|
36
|
+
end
|
36
37
|
|
37
38
|
after do
|
38
39
|
Timecop.return
|
39
40
|
end
|
40
41
|
|
41
|
-
subject {
|
42
|
+
subject { driver.emits }
|
42
43
|
|
43
44
|
context 'when access log does not exist' do
|
44
45
|
before do
|
@@ -47,6 +48,7 @@ describe Fluent::ElbAccessLogInput do
|
|
47
48
|
expect(client).to receive(:list_objects).with(bucket: s3_bucket, prefix: tomorrow_prefix) { [] }
|
48
49
|
expect(driver.instance).to_not receive(:save_timestamp).with(today)
|
49
50
|
expect(driver.instance).to receive(:save_history)
|
51
|
+
expect(driver.instance.log).to_not receive(:warn)
|
50
52
|
|
51
53
|
driver.run
|
52
54
|
end
|
@@ -92,6 +94,7 @@ describe Fluent::ElbAccessLogInput do
|
|
92
94
|
|
93
95
|
expect(driver.instance).to receive(:save_timestamp).with(tomorrow)
|
94
96
|
expect(driver.instance).to receive(:save_history)
|
97
|
+
expect(driver.instance.log).to_not receive(:warn)
|
95
98
|
|
96
99
|
driver.run
|
97
100
|
end
|
@@ -223,7 +226,7 @@ describe Fluent::ElbAccessLogInput do
|
|
223
226
|
"request.uri.fragment"=>nil}]]
|
224
227
|
end
|
225
228
|
|
226
|
-
it { is_expected.to
|
229
|
+
it { is_expected.to match_table expected_emits }
|
227
230
|
|
228
231
|
context 'when sampling' do
|
229
232
|
let(:fluentd_conf) do
|
@@ -239,7 +242,7 @@ describe Fluent::ElbAccessLogInput do
|
|
239
242
|
it do
|
240
243
|
expected_emits.delete_at(3)
|
241
244
|
expected_emits.delete_at(1)
|
242
|
-
is_expected.to
|
245
|
+
is_expected.to match_table expected_emits
|
243
246
|
end
|
244
247
|
end
|
245
248
|
end
|
@@ -267,6 +270,7 @@ describe Fluent::ElbAccessLogInput do
|
|
267
270
|
expect(driver.instance).to receive(:save_history)
|
268
271
|
|
269
272
|
allow(Addressable::URI).to receive(:parse).and_raise('parse error')
|
273
|
+
expect(driver.instance.log).to receive(:warn).with('parse error: http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/')
|
270
274
|
|
271
275
|
driver.run
|
272
276
|
end
|
@@ -298,7 +302,7 @@ describe Fluent::ElbAccessLogInput do
|
|
298
302
|
"request.http_version"=>"HTTP/1.1"}]]
|
299
303
|
end
|
300
304
|
|
301
|
-
it { is_expected.to
|
305
|
+
it { is_expected.to match_table expected_emits }
|
302
306
|
end
|
303
307
|
|
304
308
|
context 'when access log exists (with tag option)' do
|
@@ -332,6 +336,7 @@ describe Fluent::ElbAccessLogInput do
|
|
332
336
|
|
333
337
|
expect(driver.instance).to receive(:save_timestamp).with(today)
|
334
338
|
expect(driver.instance).to receive(:save_history)
|
339
|
+
expect(driver.instance.log).to_not receive(:warn)
|
335
340
|
|
336
341
|
driver.run
|
337
342
|
end
|
@@ -370,7 +375,7 @@ describe Fluent::ElbAccessLogInput do
|
|
370
375
|
"request.uri.fragment"=>nil}]]
|
371
376
|
end
|
372
377
|
|
373
|
-
it { is_expected.to
|
378
|
+
it { is_expected.to match_table expected_emits }
|
374
379
|
end
|
375
380
|
|
376
381
|
context 'when access old log exists' do
|
@@ -396,6 +401,7 @@ describe Fluent::ElbAccessLogInput do
|
|
396
401
|
|
397
402
|
expect(driver.instance).to_not receive(:save_timestamp)
|
398
403
|
expect(driver.instance).to receive(:save_history)
|
404
|
+
expect(driver.instance.log).to_not receive(:warn)
|
399
405
|
|
400
406
|
driver.run
|
401
407
|
end
|
@@ -434,7 +440,7 @@ describe Fluent::ElbAccessLogInput do
|
|
434
440
|
"request.uri.fragment"=>nil}]]
|
435
441
|
end
|
436
442
|
|
437
|
-
it { is_expected.to
|
443
|
+
it { is_expected.to match_table expected_emits }
|
438
444
|
end
|
439
445
|
|
440
446
|
context 'when parse error' do
|
@@ -460,6 +466,7 @@ describe Fluent::ElbAccessLogInput do
|
|
460
466
|
expect(driver.instance).to receive(:save_history)
|
461
467
|
|
462
468
|
expect(CSV).to receive(:parse_line).and_raise('parse error')
|
469
|
+
expect(driver.instance.log).to_not receive(:warn)
|
463
470
|
|
464
471
|
driver.run
|
465
472
|
end
|
@@ -498,7 +505,7 @@ describe Fluent::ElbAccessLogInput do
|
|
498
505
|
"request.uri.fragment"=>nil}]]
|
499
506
|
end
|
500
507
|
|
501
|
-
it { is_expected.to
|
508
|
+
it { is_expected.to match_table expected_emits }
|
502
509
|
|
503
510
|
context 'when no user_agent' do
|
504
511
|
let(:today_access_log) do
|
@@ -513,7 +520,7 @@ describe Fluent::ElbAccessLogInput do
|
|
513
520
|
expected_emits[0][2]['ssl_protocol'] = nil
|
514
521
|
end
|
515
522
|
|
516
|
-
it { is_expected.to
|
523
|
+
it { is_expected.to match_table expected_emits }
|
517
524
|
end
|
518
525
|
end
|
519
526
|
|
@@ -537,6 +544,7 @@ describe Fluent::ElbAccessLogInput do
|
|
537
544
|
expect(client).to_not receive(:get_object)
|
538
545
|
expect(driver.instance).to_not receive(:save_timestamp)
|
539
546
|
expect(driver.instance).to receive(:save_history)
|
547
|
+
expect(driver.instance.log).to_not receive(:warn)
|
540
548
|
|
541
549
|
driver.run
|
542
550
|
end
|
@@ -565,6 +573,7 @@ describe Fluent::ElbAccessLogInput do
|
|
565
573
|
history << today_object_key
|
566
574
|
expect(driver.instance).to_not receive(:save_timestamp)
|
567
575
|
expect(driver.instance).to receive(:save_history)
|
576
|
+
expect(driver.instance.log).to_not receive(:warn)
|
568
577
|
|
569
578
|
driver.run
|
570
579
|
end
|
@@ -595,6 +604,7 @@ describe Fluent::ElbAccessLogInput do
|
|
595
604
|
|
596
605
|
expect(driver.instance).to receive(:save_timestamp).with(today)
|
597
606
|
expect(driver.instance).to receive(:save_history)
|
607
|
+
expect(driver.instance.log).to_not receive(:warn)
|
598
608
|
end
|
599
609
|
|
600
610
|
subject { history.length }
|
@@ -638,6 +648,7 @@ describe Fluent::ElbAccessLogInput do
|
|
638
648
|
|
639
649
|
expect(driver.instance).to receive(:save_timestamp).with(today)
|
640
650
|
expect(driver.instance).to receive(:save_history)
|
651
|
+
expect(driver.instance.log).to_not receive(:warn)
|
641
652
|
|
642
653
|
driver.run
|
643
654
|
end
|
@@ -676,6 +687,6 @@ describe Fluent::ElbAccessLogInput do
|
|
676
687
|
"request.uri.fragment"=>nil}]]
|
677
688
|
end
|
678
689
|
|
679
|
-
it { is_expected.to
|
690
|
+
it { is_expected.to match_table expected_emits }
|
680
691
|
end
|
681
692
|
end
|
@@ -43,6 +43,7 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
43
43
|
expect(driver.instance.history_length).to eq 100
|
44
44
|
expect(driver.instance.sampling_interval).to eq 1
|
45
45
|
expect(driver.instance.debug).to be_falsey
|
46
|
+
expect(driver.instance.elb_type).to eq 'clb'
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -61,6 +62,7 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
61
62
|
let(:buffer_sec) { 1200 }
|
62
63
|
let(:history_length) { 200 }
|
63
64
|
let(:sampling_interval) { 100 }
|
65
|
+
let(:elb_type) { 'alb' }
|
64
66
|
|
65
67
|
let(:fluentd_conf) do
|
66
68
|
{
|
@@ -82,6 +84,7 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
82
84
|
history_length: history_length,
|
83
85
|
sampling_interval: sampling_interval,
|
84
86
|
debug: true,
|
87
|
+
elb_type: elb_type,
|
85
88
|
}
|
86
89
|
end
|
87
90
|
|
@@ -103,6 +106,7 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
103
106
|
expect(driver.instance.history_length).to eq history_length
|
104
107
|
expect(driver.instance.sampling_interval).to eq sampling_interval
|
105
108
|
expect(driver.instance.debug).to be_truthy
|
109
|
+
expect(driver.instance.elb_type).to eq elb_type
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
@@ -166,4 +170,24 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
166
170
|
expect(driver.instance.start_datetime).to eq Time.parse(tsfile_datetime)
|
167
171
|
end
|
168
172
|
end
|
173
|
+
|
174
|
+
context 'when an invalid ELB type' do
|
175
|
+
let(:start_datetime) { '2015-01-01 01:02:03 UTC' }
|
176
|
+
|
177
|
+
let(:fluentd_conf) do
|
178
|
+
{
|
179
|
+
account_id: account_id,
|
180
|
+
s3_bucket: s3_bucket,
|
181
|
+
region: region,
|
182
|
+
start_datetime: start_datetime,
|
183
|
+
elb_type: 'invalid',
|
184
|
+
}
|
185
|
+
end
|
186
|
+
|
187
|
+
it do
|
188
|
+
expect {
|
189
|
+
subject
|
190
|
+
}.to raise_error 'Invalid ELB type: invalid'
|
191
|
+
end
|
192
|
+
end
|
169
193
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
require 'fluent/test'
|
2
2
|
require 'fluent/plugin/in_elb_access_log'
|
3
3
|
|
4
|
-
require 'aws-sdk'
|
4
|
+
require 'aws-sdk-s3'
|
5
5
|
require 'time'
|
6
6
|
require 'timecop'
|
7
|
+
require 'rspec/match_table'
|
8
|
+
|
9
|
+
if ENV['TRAVIS']
|
10
|
+
require 'simplecov'
|
11
|
+
require 'coveralls'
|
12
|
+
|
13
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
14
|
+
SimpleCov.start do
|
15
|
+
add_filter "spec/"
|
16
|
+
end
|
17
|
+
end
|
7
18
|
|
8
19
|
# Disable Test::Unit
|
9
20
|
module Test::Unit::RunCount; def run(*); end; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-elb-access-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.7
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: aws-sdk
|
28
|
+
name: aws-sdk-s3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '1.8'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '1.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: addressable
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +122,34 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 3.1.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-match_table
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.1.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.1.1
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: coveralls
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
125
153
|
description: Fluentd input plugin for AWS ELB Access Logs.
|
126
154
|
email:
|
127
155
|
- sugawara@cookpad.com
|
@@ -139,8 +167,9 @@ files:
|
|
139
167
|
- fluent-plugin-elb-access-log.gemspec
|
140
168
|
- lib/fluent/plugin/in_elb_access_log.rb
|
141
169
|
- lib/fluent_plugin_elb_access_log/version.rb
|
170
|
+
- spec/in_elb_access_log_alb_spec.rb
|
171
|
+
- spec/in_elb_access_log_clb_spec.rb
|
142
172
|
- spec/in_elb_access_log_config_spec.rb
|
143
|
-
- spec/in_elb_access_log_spec.rb
|
144
173
|
- spec/spec_helper.rb
|
145
174
|
homepage: https://github.com/winebarrel/fluent-plugin-elb-access-log
|
146
175
|
licenses:
|
@@ -157,16 +186,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
186
|
version: '0'
|
158
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
188
|
requirements:
|
160
|
-
- - "
|
189
|
+
- - ">="
|
161
190
|
- !ruby/object:Gem::Version
|
162
|
-
version:
|
191
|
+
version: '0'
|
163
192
|
requirements: []
|
164
193
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.6.
|
194
|
+
rubygems_version: 2.6.13
|
166
195
|
signing_key:
|
167
196
|
specification_version: 4
|
168
197
|
summary: Fluentd input plugin for AWS ELB Access Logs.
|
169
198
|
test_files:
|
199
|
+
- spec/in_elb_access_log_alb_spec.rb
|
200
|
+
- spec/in_elb_access_log_clb_spec.rb
|
170
201
|
- spec/in_elb_access_log_config_spec.rb
|
171
|
-
- spec/in_elb_access_log_spec.rb
|
172
202
|
- spec/spec_helper.rb
|