fluent-plugin-s3 0.5.11 → 0.6.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/README.rdoc +3 -0
- data/VERSION +2 -1
- data/fluent-plugin-s3.gemspec +2 -2
- data/lib/fluent/plugin/out_s3.rb +70 -22
- data/test/test_out_s3.rb +123 -129
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd565fde9785110e7b4a202ec2b013c79381cbbf
|
4
|
+
data.tar.gz: 14fc7296e5f8d4dea3605f2affecc4b224da8af8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 496c9a8350a9ffedc103cea38eeaea77a6bb7dcb7c4fc36c38d1cf927ea95ffd4d4b44d417873b325fbb3816dc958d36e98302efcbdad7b8fdf9d5616c5b6c37
|
7
|
+
data.tar.gz: 845cd5d1f2c79fc890c174cea1f855aa92b1fb4f944712ac1c3a253c886c3d48f072330044788e27144dc0a1bc86c062be04c73f9b30b9e50488db51be64bc7b
|
data/ChangeLog
CHANGED
data/README.rdoc
CHANGED
@@ -93,6 +93,9 @@ The {fluent-mixin-config-placeholders}[https://github.com/tagomoris/fluent-mixin
|
|
93
93
|
- json
|
94
94
|
- text
|
95
95
|
- lzo (Need lzop command)
|
96
|
+
- lzma2 (Need xz command)
|
97
|
+
- gzip_command (Need gzip command)
|
98
|
+
- This compressor uses an external gzip command, hence would result in utilizing CPU cores well compared with `gzip`
|
96
99
|
|
97
100
|
See 'Use your compression algorithm' section for adding another format.
|
98
101
|
|
data/VERSION
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0.pre1
|
2
|
+
|
data/fluent-plugin-s3.gemspec
CHANGED
@@ -18,10 +18,10 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
20
|
gem.add_dependency "fluentd", [">= 0.10.49", "< 2"]
|
21
|
-
gem.add_dependency "aws-sdk
|
21
|
+
gem.add_dependency "aws-sdk", "~> 2"
|
22
22
|
gem.add_dependency "yajl-ruby", "~> 1.0"
|
23
23
|
gem.add_dependency "fluent-mixin-config-placeholders", ">= 0.3.0"
|
24
24
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
25
|
-
gem.add_development_dependency "flexmock", ">= 1.2.0"
|
26
25
|
gem.add_development_dependency "test-unit", ">= 3.0.8"
|
26
|
+
gem.add_development_dependency "test-unit-rr", ">= 1.0.3"
|
27
27
|
end
|
data/lib/fluent/plugin/out_s3.rb
CHANGED
@@ -6,7 +6,7 @@ module Fluent
|
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
super
|
9
|
-
require 'aws-sdk-
|
9
|
+
require 'aws-sdk-resources'
|
10
10
|
require 'zlib'
|
11
11
|
require 'time'
|
12
12
|
require 'tempfile'
|
@@ -15,13 +15,32 @@ module Fluent
|
|
15
15
|
end
|
16
16
|
|
17
17
|
config_param :path, :string, :default => ""
|
18
|
-
config_param :use_ssl, :bool, :default => true
|
19
18
|
config_param :use_server_side_encryption, :string, :default => nil
|
20
19
|
config_param :aws_key_id, :string, :default => nil, :secret => true
|
21
20
|
config_param :aws_sec_key, :string, :default => nil, :secret => true
|
21
|
+
config_section :assume_role_credentials, :multi => false do
|
22
|
+
config_param :role_arn, :string
|
23
|
+
config_param :role_session_name, :string
|
24
|
+
config_param :policy, :string, :default => nil
|
25
|
+
config_param :duration_seconds, :integer, :default => nil
|
26
|
+
config_param :external_id, :string, :default => nil
|
27
|
+
end
|
28
|
+
config_section :instance_profile_credentials, :multi => false do
|
29
|
+
config_param :retries, :integer, :default => nil
|
30
|
+
config_param :ip_address, :string, :default => nil
|
31
|
+
config_param :port, :integer, :default => nil
|
32
|
+
config_param :http_open_timeout, :float, :default => nil
|
33
|
+
config_param :http_read_timeout, :float, :default => nil
|
34
|
+
# config_param :delay, :integer or :proc, :default => nil
|
35
|
+
# config_param :http_degub_output, :io, :default => nil
|
36
|
+
end
|
37
|
+
config_section :shared_credentials, :multi => false do
|
38
|
+
config_param :path, :string, :default => nil
|
39
|
+
config_param :profile_name, :string, :default => nil
|
40
|
+
end
|
22
41
|
config_param :aws_iam_retries, :integer, :default => 5
|
23
42
|
config_param :s3_bucket, :string
|
24
|
-
config_param :s3_region, :string, :default =>
|
43
|
+
config_param :s3_region, :string, :default => ENV["AWS_REGION"] || "us-east-1"
|
25
44
|
config_param :s3_endpoint, :string, :default => nil
|
26
45
|
config_param :s3_object_key_format, :string, :default => "%{path}%{time_slice}_%{index}.%{file_extension}"
|
27
46
|
config_param :store_as, :string, :default => "gzip"
|
@@ -29,6 +48,7 @@ module Fluent
|
|
29
48
|
config_param :check_apikey_on_start, :bool, :default => true
|
30
49
|
config_param :proxy_uri, :string, :default => nil
|
31
50
|
config_param :reduced_redundancy, :bool, :default => false
|
51
|
+
config_param :storage_class, :string, :default => "STANDARD"
|
32
52
|
config_param :format, :string, :default => 'out_file'
|
33
53
|
config_param :acl, :string, :default => :private
|
34
54
|
|
@@ -68,27 +88,55 @@ module Fluent
|
|
68
88
|
Time.now.utc.strftime(path)
|
69
89
|
}
|
70
90
|
end
|
91
|
+
|
92
|
+
@storage_class = "REDUCED_REDUNDANCY" if @reduced_redundancy
|
71
93
|
end
|
72
94
|
|
73
95
|
def start
|
74
96
|
super
|
75
97
|
options = {}
|
76
|
-
|
98
|
+
credentials_options = {}
|
99
|
+
case
|
100
|
+
when @aws_key_id && @aws_sec_key
|
77
101
|
options[:access_key_id] = @aws_key_id
|
78
102
|
options[:secret_access_key] = @aws_sec_key
|
79
|
-
|
80
|
-
|
103
|
+
when @assume_role_credentials
|
104
|
+
c = @assume_role_credentials
|
105
|
+
credentials_options[:role_arn] = c.role_arn
|
106
|
+
credentials_options[:role_session_name] = c.role_session_name
|
107
|
+
credentials_options[:policy] = c.policy if c.policy
|
108
|
+
credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds
|
109
|
+
credentials_options[:external_id] = c.external_id if c.external_id
|
110
|
+
options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options)
|
111
|
+
when @instance_profile_credentials
|
112
|
+
c = @instance_profile_credentials
|
113
|
+
credentials_options[:retries] = c.retries if c.retries
|
114
|
+
credentials_options[:ip_address] = c.ip_address if c.ip_address
|
115
|
+
credentials_options[:port] = c.port if c.port
|
116
|
+
credentials_options[:http_open_timeout] = c.http_open_timeout if c.http_open_timeout
|
117
|
+
credentials_options[:http_read_timeout] = c.http_read_timeout if c.http_read_timeout
|
118
|
+
options[:credentials] = Aws::InstanceProfileCredentials.new(credentials_options)
|
119
|
+
when @shared_credentials
|
120
|
+
c = @shared_credentials
|
121
|
+
credentials_options[:path] = c.path if c.path
|
122
|
+
credentials_options[:profile_name] = c.profile_name if c.profile_name
|
123
|
+
options[:credentials] = Aws::SharedCredentials.new(credentials_options)
|
124
|
+
when @aws_iam_retries
|
125
|
+
$log.warn("'aws_iam_retries' parameter is deprecated. Use 'instance_profile_credentials' instead")
|
126
|
+
credentials_options[:retries] = @aws_iam_retries
|
127
|
+
options[:credentials] = Aws::InstanceProfileCredentials.new(credentials_options)
|
81
128
|
else
|
82
|
-
|
129
|
+
# Use default credentials
|
130
|
+
# See http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html
|
83
131
|
end
|
84
132
|
options[:region] = @s3_region if @s3_region
|
85
|
-
options[:
|
86
|
-
options[:
|
87
|
-
options[:use_ssl] = @use_ssl
|
133
|
+
options[:endpoint] = @s3_endpoint if @s3_endpoint
|
134
|
+
options[:http_proxy] = @proxy_uri if @proxy_uri
|
88
135
|
options[:s3_server_side_encryption] = @use_server_side_encryption.to_sym if @use_server_side_encryption
|
89
136
|
|
90
|
-
|
91
|
-
@
|
137
|
+
s3_client = Aws::S3::Client.new(options)
|
138
|
+
@s3 = Aws::S3::Resource.new(:client => s3_client)
|
139
|
+
@bucket = @s3.bucket(@s3_bucket)
|
92
140
|
|
93
141
|
check_apikeys if @check_apikey_on_start
|
94
142
|
ensure_bucket
|
@@ -120,14 +168,15 @@ module Fluent
|
|
120
168
|
|
121
169
|
i += 1
|
122
170
|
previous_path = s3path
|
123
|
-
end while @bucket.
|
171
|
+
end while @bucket.object(s3path).exists?
|
124
172
|
|
125
173
|
tmp = Tempfile.new("s3-")
|
126
174
|
begin
|
127
175
|
@compressor.compress(chunk, tmp)
|
128
|
-
|
129
|
-
|
130
|
-
|
176
|
+
tmp.rewind
|
177
|
+
@bucket.object(s3path).put(:body => tmp,
|
178
|
+
:content_type => @compressor.content_type,
|
179
|
+
:storage_class => @storage_class)
|
131
180
|
ensure
|
132
181
|
tmp.close(true) rescue nil
|
133
182
|
end
|
@@ -139,7 +188,7 @@ module Fluent
|
|
139
188
|
if !@bucket.exists?
|
140
189
|
if @auto_create_bucket
|
141
190
|
log.info "Creating bucket #{@s3_bucket} on #{@s3_endpoint}"
|
142
|
-
@s3.
|
191
|
+
@s3.create_bucket(:bucket => @s3_bucket)
|
143
192
|
else
|
144
193
|
raise "The specified bucket does not exist: bucket = #{@s3_bucket}"
|
145
194
|
end
|
@@ -147,8 +196,8 @@ module Fluent
|
|
147
196
|
end
|
148
197
|
|
149
198
|
def check_apikeys
|
150
|
-
@bucket.
|
151
|
-
rescue
|
199
|
+
@bucket.objects.first
|
200
|
+
rescue Aws::S3::Errors::NoSuchBucket
|
152
201
|
# ignore NoSuchBucket Error because ensure_bucket checks it.
|
153
202
|
rescue => e
|
154
203
|
raise "can't call S3 API. Please check your aws_key_id / aws_sec_key or s3_region configuration. error = #{e.inspect}"
|
@@ -204,9 +253,9 @@ module Fluent
|
|
204
253
|
def compress(chunk, tmp)
|
205
254
|
w = Zlib::GzipWriter.new(tmp)
|
206
255
|
chunk.write_to(w)
|
207
|
-
w.
|
256
|
+
w.finish
|
208
257
|
ensure
|
209
|
-
w.
|
258
|
+
w.finish rescue nil
|
210
259
|
end
|
211
260
|
end
|
212
261
|
|
@@ -221,7 +270,6 @@ module Fluent
|
|
221
270
|
|
222
271
|
def compress(chunk, tmp)
|
223
272
|
chunk.write_to(tmp)
|
224
|
-
tmp.close
|
225
273
|
end
|
226
274
|
end
|
227
275
|
|
data/test/test_out_s3.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'fluent/test'
|
2
2
|
require 'fluent/plugin/out_s3'
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'test/unit/rr'
|
5
5
|
require 'zlib'
|
6
|
+
require 'fileutils'
|
6
7
|
|
7
8
|
class S3OutputTest < Test::Unit::TestCase
|
8
9
|
def setup
|
9
|
-
require 'aws-sdk-
|
10
|
+
require 'aws-sdk-resources'
|
10
11
|
Fluent::Test.setup
|
11
12
|
end
|
12
13
|
|
@@ -41,7 +42,6 @@ class S3OutputTest < Test::Unit::TestCase
|
|
41
42
|
assert_equal 'test_sec_key', d.instance.aws_sec_key
|
42
43
|
assert_equal 'test_bucket', d.instance.s3_bucket
|
43
44
|
assert_equal 'log', d.instance.path
|
44
|
-
assert d.instance.instance_variable_get(:@use_ssl)
|
45
45
|
assert_equal 'gz', d.instance.instance_variable_get(:@compressor).ext
|
46
46
|
assert_equal 'application/x-gzip', d.instance.instance_variable_get(:@compressor).content_type
|
47
47
|
end
|
@@ -242,39 +242,21 @@ class S3OutputTest < Test::Unit::TestCase
|
|
242
242
|
end
|
243
243
|
|
244
244
|
def test_write_with_custom_s3_object_key_format
|
245
|
-
# Assert content of event logs which are being sent to S3
|
246
|
-
s3obj = flexmock(AWS::S3::S3Object)
|
247
|
-
s3obj.should_receive(:exists?).with_any_args.and_return { false }
|
248
|
-
s3obj.should_receive(:write).with(
|
249
|
-
on { |pathname|
|
250
|
-
data = nil
|
251
|
-
# Event logs are compressed in GZip
|
252
|
-
pathname.open { |f|
|
253
|
-
gz = Zlib::GzipReader.new(f)
|
254
|
-
data = gz.read
|
255
|
-
gz.close
|
256
|
-
}
|
257
|
-
assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] +
|
258
|
-
%[2011-01-02T13:14:15Z\ttest\t{"a":2}\n],
|
259
|
-
data
|
260
|
-
|
261
|
-
pathname.to_s.match(%r|s3-|)
|
262
|
-
},
|
263
|
-
{:content_type => "application/x-gzip", :reduced_redundancy => false, :acl => :private})
|
264
|
-
|
265
|
-
# Assert the key of S3Object, which event logs are stored in
|
266
|
-
s3obj_col = flexmock(AWS::S3::ObjectCollection)
|
267
|
-
s3obj_col.should_receive(:[]).with(
|
268
|
-
on { |key|
|
269
|
-
key == "log/events/ts=20110102-13/events_0-testing.node.local.gz"
|
270
|
-
}).
|
271
|
-
and_return {
|
272
|
-
s3obj
|
273
|
-
}
|
274
|
-
|
275
245
|
# Partial mock the S3Bucket, not to make an actual connection to Amazon S3
|
276
|
-
|
277
|
-
|
246
|
+
setup_mocks(true)
|
247
|
+
|
248
|
+
# Assert content of event logs which are being sent to S3
|
249
|
+
s3obj = stub(Aws::S3::Object.new(:bucket_name => "test_bucket",
|
250
|
+
:key => "test",
|
251
|
+
:client => @s3_client))
|
252
|
+
s3obj.exists? { false }
|
253
|
+
s3_test_file_path = "/tmp/s3-test.txt"
|
254
|
+
tempfile = File.new(s3_test_file_path, "w")
|
255
|
+
mock(Tempfile).new("s3-") { tempfile }
|
256
|
+
s3obj.put(:body => tempfile,
|
257
|
+
:content_type => "application/x-gzip",
|
258
|
+
:storage_class => "STANDARD")
|
259
|
+
@s3_bucket.object("log/events/ts=20110102-13/events_0-testing.node.local.gz") { s3obj }
|
278
260
|
|
279
261
|
# We must use TimeSlicedOutputTestDriver instead of BufferedOutputTestDriver,
|
280
262
|
# to make assertions on chunks' keys
|
@@ -286,46 +268,38 @@ class S3OutputTest < Test::Unit::TestCase
|
|
286
268
|
|
287
269
|
# Finally, the instance of S3Output is initialized and then invoked
|
288
270
|
d.run
|
271
|
+
Zlib::GzipReader.open(s3_test_file_path) do |gz|
|
272
|
+
data = gz.read
|
273
|
+
assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] +
|
274
|
+
%[2011-01-02T13:14:15Z\ttest\t{"a":2}\n],
|
275
|
+
data
|
276
|
+
end
|
277
|
+
FileUtils.rm_f(s3_test_file_path)
|
289
278
|
end
|
290
279
|
|
291
280
|
def test_write_with_custom_s3_object_key_format_containing_uuid_flush_placeholder
|
292
|
-
# Assert content of event logs which are being sent to S3
|
293
|
-
s3obj = flexmock(AWS::S3::S3Object)
|
294
|
-
s3obj.should_receive(:exists?).with_any_args.and_return { false }
|
295
|
-
s3obj.should_receive(:write).with(
|
296
|
-
on { |pathname|
|
297
|
-
data = nil
|
298
|
-
# Event logs are compressed in GZip
|
299
|
-
pathname.open { |f|
|
300
|
-
gz = Zlib::GzipReader.new(f)
|
301
|
-
data = gz.read
|
302
|
-
gz.close
|
303
|
-
}
|
304
|
-
assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] +
|
305
|
-
%[2011-01-02T13:14:15Z\ttest\t{"a":2}\n],
|
306
|
-
data
|
307
|
-
|
308
|
-
pathname.to_s.match(%r|s3-|)
|
309
|
-
},
|
310
|
-
{:content_type => "application/x-gzip", :reduced_redundancy => false, :acl => :private})
|
311
|
-
|
312
|
-
# Assert the key of S3Object, which event logs are stored in
|
313
|
-
s3obj_col = flexmock(AWS::S3::ObjectCollection)
|
314
|
-
s3obj_col.should_receive(:[]).with(
|
315
|
-
on { |key|
|
316
|
-
key =~ /.*.[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}.*/
|
317
|
-
}).
|
318
|
-
and_return {
|
319
|
-
s3obj
|
320
|
-
}
|
321
|
-
|
322
281
|
# Partial mock the S3Bucket, not to make an actual connection to Amazon S3
|
323
|
-
|
324
|
-
|
282
|
+
setup_mocks(true)
|
283
|
+
|
284
|
+
uuid = "5755e23f-9b54-42d8-8818-2ea38c6f279e"
|
285
|
+
stub(UUIDTools::UUID).random_create{ uuid }
|
286
|
+
|
287
|
+
# Assert content of event logs which are being sent to S3
|
288
|
+
s3obj = stub(Aws::S3::Object.new(:bucket_name => "test_bucket",
|
289
|
+
:key => "test",
|
290
|
+
:client => @s3_client))
|
291
|
+
s3obj.exists? { false }
|
292
|
+
s3_test_file_path = "/tmp/s3-test.txt"
|
293
|
+
tempfile = File.new(s3_test_file_path, "w")
|
294
|
+
mock(Tempfile).new("s3-") { tempfile }
|
295
|
+
s3obj.put(:body => tempfile,
|
296
|
+
:content_type => "application/x-gzip",
|
297
|
+
:storage_class => "STANDARD")
|
298
|
+
@s3_bucket.object("log/events/ts=20110102-13/events_0-#{uuid}.gz") { s3obj }
|
325
299
|
|
326
300
|
# We must use TimeSlicedOutputTestDriver instead of BufferedOutputTestDriver,
|
327
301
|
# to make assertions on chunks' keys
|
328
|
-
config = CONFIG_TIME_SLICE.
|
302
|
+
config = CONFIG_TIME_SLICE.gsub(/%{hostname}/,"%{uuid_flush}")
|
329
303
|
d = create_time_sliced_driver(config)
|
330
304
|
|
331
305
|
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
@@ -334,22 +308,32 @@ class S3OutputTest < Test::Unit::TestCase
|
|
334
308
|
|
335
309
|
# Finally, the instance of S3Output is initialized and then invoked
|
336
310
|
d.run
|
311
|
+
Zlib::GzipReader.open(s3_test_file_path) do |gz|
|
312
|
+
data = gz.read
|
313
|
+
assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] +
|
314
|
+
%[2011-01-02T13:14:15Z\ttest\t{"a":2}\n],
|
315
|
+
data
|
316
|
+
end
|
317
|
+
FileUtils.rm_f(s3_test_file_path)
|
337
318
|
end
|
338
319
|
|
339
320
|
def setup_mocks(exists_return = false)
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
321
|
+
@s3_client = stub(Aws::S3::Client.new(:stub_responses => true))
|
322
|
+
mock(Aws::S3::Client).new(anything).at_least(0) { @s3_client }
|
323
|
+
@s3_resource = mock(Aws::S3::Resource.new(:client => @s3_client))
|
324
|
+
mock(Aws::S3::Resource).new(:client => @s3_client) { @s3_resource }
|
325
|
+
@s3_bucket = mock(Aws::S3::Bucket.new(:name => "test",
|
326
|
+
:client => @s3_client))
|
327
|
+
@s3_bucket.exists? { exists_return }
|
328
|
+
@s3_object = mock(Aws::S3::Object.new(:bucket_name => "test_bucket",
|
329
|
+
:key => "test",
|
330
|
+
:client => @s3_client))
|
331
|
+
@s3_bucket.object(anything).at_least(0) { @s3_object }
|
332
|
+
@s3_resource.bucket(anything) { @s3_bucket }
|
349
333
|
end
|
350
334
|
|
351
335
|
def test_auto_create_bucket_false_with_non_existence_bucket
|
352
|
-
|
336
|
+
setup_mocks
|
353
337
|
|
354
338
|
config = CONFIG_TIME_SLICE + 'auto_create_bucket false'
|
355
339
|
d = create_time_sliced_driver(config)
|
@@ -359,73 +343,83 @@ class S3OutputTest < Test::Unit::TestCase
|
|
359
343
|
end
|
360
344
|
|
361
345
|
def test_auto_create_bucket_true_with_non_existence_bucket
|
362
|
-
|
363
|
-
|
346
|
+
setup_mocks
|
347
|
+
@s3_resource.create_bucket(:bucket => "test_bucket")
|
364
348
|
|
365
349
|
config = CONFIG_TIME_SLICE + 'auto_create_bucket true'
|
366
350
|
d = create_time_sliced_driver(config)
|
367
351
|
assert_nothing_raised { d.run }
|
368
352
|
end
|
369
353
|
|
370
|
-
def
|
371
|
-
s3bucket, s3bucket_col = setup_mocks
|
372
|
-
s3bucket_col.should_receive(:create).with_any_args.and_return { true }
|
373
|
-
|
354
|
+
def test_credentials
|
374
355
|
d = create_time_sliced_driver
|
375
|
-
assert_nothing_raised
|
376
|
-
|
356
|
+
assert_nothing_raised{ d.run }
|
357
|
+
client = d.instance.instance_variable_get(:@s3).client
|
358
|
+
credentials = client.config.credentials
|
359
|
+
assert_instance_of(Aws::Credentials, credentials)
|
377
360
|
end
|
378
361
|
|
379
|
-
def
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
config = CONFIG_TIME_SLICE.
|
362
|
+
def test_assume_role_credentials
|
363
|
+
expected_credentials = Aws::Credentials.new("test_key", "test_secret")
|
364
|
+
mock(Aws::AssumeRoleCredentials).new(:role_arn => "test_arn",
|
365
|
+
:role_session_name => "test_session"){
|
366
|
+
expected_credentials
|
367
|
+
}
|
368
|
+
config = CONFIG_TIME_SLICE.split("\n").reject{|x| x =~ /.+aws_.+/}.join("\n")
|
369
|
+
config += %[
|
370
|
+
<assume_role_credentials>
|
371
|
+
role_arn test_arn
|
372
|
+
role_session_name test_session
|
373
|
+
</assume_role_credentials>
|
374
|
+
]
|
386
375
|
d = create_time_sliced_driver(config)
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
assert_equal
|
391
|
-
assert_equal nil, d.instance.aws_sec_key
|
392
|
-
assert_equal "AWS::Core::CredentialProviders::ENVProvider", d.instance.instance_variable_get(:@s3).config.credential_provider.class.to_s
|
393
|
-
|
394
|
-
ENV.replace({'AWS_ACCESS_KEY_ID' => key}) unless key.nil?
|
376
|
+
assert_nothing_raised{ d.run }
|
377
|
+
client = d.instance.instance_variable_get(:@s3).client
|
378
|
+
credentials = client.config.credentials
|
379
|
+
assert_equal(expected_credentials, credentials)
|
395
380
|
end
|
396
381
|
|
397
|
-
def
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
382
|
+
def test_instance_profile_credentials
|
383
|
+
expected_credentials = Aws::Credentials.new("test_key", "test_secret")
|
384
|
+
mock(Aws::InstanceProfileCredentials).new({}).returns(expected_credentials)
|
385
|
+
config = CONFIG_TIME_SLICE.split("\n").reject{|x| x =~ /.+aws_.+/}.join("\n")
|
386
|
+
config += %[
|
387
|
+
<instance_profile_credentials>
|
388
|
+
</instance_profile_credentials>
|
389
|
+
]
|
404
390
|
d = create_time_sliced_driver(config)
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
assert_equal
|
409
|
-
assert_equal nil, d.instance.aws_sec_key
|
410
|
-
assert_equal "AWS::Core::CredentialProviders::EC2Provider", d.instance.instance_variable_get(:@s3).config.credential_provider.class.to_s
|
411
|
-
assert_equal 5, d.instance.instance_variable_get(:@s3).config.credential_provider.retries
|
412
|
-
|
413
|
-
ENV.replace({'AWS_ACCESS_KEY_ID' => key}) unless key.nil?
|
391
|
+
assert_nothing_raised{ d.run }
|
392
|
+
client = d.instance.instance_variable_get(:@s3).client
|
393
|
+
credentials = client.config.credentials
|
394
|
+
assert_equal(expected_credentials, credentials)
|
414
395
|
end
|
415
396
|
|
416
|
-
def
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
397
|
+
def test_instance_profile_credentials_aws_iam_retries
|
398
|
+
expected_credentials = Aws::Credentials.new("test_key", "test_secret")
|
399
|
+
mock(Aws::InstanceProfileCredentials).new({}).returns(expected_credentials)
|
400
|
+
config = CONFIG_TIME_SLICE.split("\n").reject{|x| x =~ /.+aws_.+/}.join("\n")
|
401
|
+
config += %[
|
402
|
+
aws_iam_retries 10
|
403
|
+
]
|
423
404
|
d = create_time_sliced_driver(config)
|
405
|
+
assert_nothing_raised{ d.run }
|
406
|
+
client = d.instance.instance_variable_get(:@s3).client
|
407
|
+
credentials = client.config.credentials
|
408
|
+
assert_equal(expected_credentials, credentials)
|
409
|
+
end
|
424
410
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
411
|
+
def test_shared_credentials
|
412
|
+
expected_credentials = Aws::Credentials.new("test_key", "test_secret")
|
413
|
+
mock(Aws::SharedCredentials).new({}).returns(expected_credentials)
|
414
|
+
config = CONFIG_TIME_SLICE.split("\n").reject{|x| x =~ /.+aws_.+/}.join("\n")
|
415
|
+
config += %[
|
416
|
+
<shared_credentials>
|
417
|
+
</shared_credentials>
|
418
|
+
]
|
419
|
+
d = create_time_sliced_driver(config)
|
420
|
+
assert_nothing_raised{ d.run }
|
421
|
+
client = d.instance.instance_variable_get(:@s3).client
|
422
|
+
credentials = client.config.credentials
|
423
|
+
assert_equal(expected_credentials, credentials)
|
430
424
|
end
|
431
425
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -32,19 +32,19 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name: aws-sdk
|
35
|
+
name: aws-sdk
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2'
|
41
41
|
type: :runtime
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: yajl-ruby
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,33 +88,33 @@ dependencies:
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.9.2
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
|
-
name:
|
91
|
+
name: test-unit
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 3.0.8
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 3.0.8
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
|
-
name: test-unit
|
105
|
+
name: test-unit-rr
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 1.0.3
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.0.3
|
118
118
|
description: Amazon S3 output plugin for Fluentd event collector
|
119
119
|
email: frsyuki@gmail.com
|
120
120
|
executables: []
|
@@ -150,9 +150,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
|
-
- - "
|
153
|
+
- - ">"
|
154
154
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
155
|
+
version: 1.3.1
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
158
|
rubygems_version: 2.2.3
|