fluent-plugin-s3 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ Release 0.2.0 - 2011/10/16
3
+
4
+ * Updated to fluentd-0.10.0
5
+
6
+
2
7
  Release 0.1.1 - 2011/09/27
3
8
 
4
9
  * First release
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  gemspec.homepage = "http://fluent.github.com/"
13
13
  gemspec.has_rdoc = false
14
14
  gemspec.require_paths = ["lib"]
15
- gemspec.add_dependency "fluent", "~> 0.9.14"
15
+ gemspec.add_dependency "fluentd", "~> 0.10.0"
16
16
  gemspec.add_dependency "aws-sdk", "~> 1.1.3"
17
17
  gemspec.test_files = Dir["test/**/*.rb"]
18
18
  gemspec.files = Dir["bin/**/*", "lib/**/*", "test/**/*.rb"] +
@@ -49,3 +49,12 @@ end
49
49
 
50
50
  task :default => [:build]
51
51
 
52
+ Rake::TestTask.new(:test) do |t|
53
+ t.libs << "test"
54
+ t.test_files = Dir["test/*.rb"].sort
55
+ t.verbose = true
56
+ #t.warning = true
57
+ end
58
+
59
+ task :default => [:build, :gemspec]
60
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
@@ -11,6 +11,8 @@ class S3Output < Fluent::TimeSlicedOutput
11
11
  require 'time'
12
12
  end
13
13
 
14
+ attr_accessor :aws_key_id, :aws_sec_key, :s3_bucket, :path
15
+
14
16
  def configure(conf)
15
17
  super
16
18
 
@@ -18,37 +20,37 @@ class S3Output < Fluent::TimeSlicedOutput
18
20
  @aws_key_id = aws_key_id
19
21
  end
20
22
  unless @aws_key_id
21
- raise ConfigError, "'aws_key_id' parameter is required on file output"
23
+ raise ConfigError, "'aws_key_id' parameter is required on s3 output"
22
24
  end
23
25
 
24
26
  if aws_sec_key = conf['aws_sec_key']
25
27
  @aws_sec_key = aws_sec_key
26
28
  end
27
29
  unless @aws_sec_key
28
- raise ConfigError, "'aws_sec_key' parameter is required on file output"
30
+ raise ConfigError, "'aws_sec_key' parameter is required on s3 output"
29
31
  end
30
32
 
31
33
  if s3_bucket = conf['s3_bucket']
32
34
  @s3_bucket = s3_bucket
33
35
  end
34
36
  unless @s3_bucket
35
- raise ConfigError, "'s3_bucket' parameter is required on file output"
37
+ raise ConfigError, "'s3_bucket' parameter is required on s3 output"
36
38
  end
37
39
 
38
40
  if path = conf['path']
39
41
  @path = path
40
42
  end
41
43
  unless @path
42
- raise ConfigError, "'path' parameter is required on file output"
44
+ @path = ''
43
45
  end
44
46
 
45
47
  if @localtime
46
- @formatter = Proc.new {|tag,event|
47
- "#{Time.at(event.time).iso8601}\t#{tag}\t#{event.record.to_json}\n"
48
+ @formatter = Proc.new {|tag,time,record|
49
+ "#{Time.at(time).iso8601}\t#{tag}\t#{record.to_json}\n"
48
50
  }
49
51
  else
50
- @formatter = Proc.new {|tag,event|
51
- "#{Time.at(event.time).utc.iso8601}\t#{tag}\t#{event.record.to_json}\n"
52
+ @formatter = Proc.new {|tag,time,record|
53
+ "#{Time.at(time).utc.iso8601}\t#{tag}\t#{record.to_json}\n"
52
54
  }
53
55
  end
54
56
  end
@@ -61,8 +63,8 @@ class S3Output < Fluent::TimeSlicedOutput
61
63
  @bucket = @s3.buckets[@s3_bucket]
62
64
  end
63
65
 
64
- def format(tag, event)
65
- @formatter.call(tag, event)
66
+ def format(tag, time, record)
67
+ @formatter.call(tag, time, record)
66
68
  end
67
69
 
68
70
  def write(chunk)
data/test/out_s3.rb ADDED
@@ -0,0 +1,63 @@
1
+ require 'fluent/test'
2
+ require 'fluent/plugin/out_s3'
3
+
4
+ class S3OutputTest < Test::Unit::TestCase
5
+ def setup
6
+ Fluent::Test.setup
7
+ end
8
+
9
+ CONFIG = %[
10
+ aws_key_id test_key_id
11
+ aws_sec_key test_sec_key
12
+ s3_bucket test_bucket
13
+ path log
14
+ utc
15
+ buffer_type memory
16
+ ]
17
+
18
+ def create_driver(conf = CONFIG)
19
+ Fluent::Test::BufferedOutputTestDriver.new(Fluent::S3Output) do
20
+ def write(chunk)
21
+ chunk.read
22
+ end
23
+ end.configure(conf)
24
+ end
25
+
26
+ def test_configure
27
+ d = create_driver
28
+ assert_equal 'test_key_id', d.instance.aws_key_id
29
+ assert_equal 'test_sec_key', d.instance.aws_sec_key
30
+ assert_equal 'test_bucket', d.instance.s3_bucket
31
+ assert_equal 'log', d.instance.path
32
+ end
33
+
34
+ def test_format
35
+ d = create_driver
36
+
37
+ time = Time.parse("2011-01-02 13:14:15 UTC").to_i
38
+ d.emit({"a"=>1}, time)
39
+ d.emit({"a"=>2}, time)
40
+
41
+ d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n]
42
+ d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
43
+
44
+ d.run
45
+ end
46
+
47
+ def test_write
48
+ d = create_driver
49
+
50
+ time = Time.parse("2011-01-02 13:14:15 UTC").to_i
51
+ d.emit({"a"=>1}, time)
52
+ d.emit({"a"=>2}, time)
53
+
54
+ # S3OutputTest#write returns chunk.read
55
+ data = d.run
56
+
57
+ assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] +
58
+ %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n],
59
+ data
60
+ end
61
+
62
+ end
63
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-s3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sadayuki Furuhashi
@@ -15,23 +15,23 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-06 00:00:00 +09:00
18
+ date: 2011-10-16 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: fluent
22
+ name: fluentd
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 39
29
+ hash: 55
30
30
  segments:
31
31
  - 0
32
- - 9
33
- - 14
34
- version: 0.9.14
32
+ - 10
33
+ - 0
34
+ version: 0.10.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -64,6 +64,7 @@ files:
64
64
  - Rakefile
65
65
  - VERSION
66
66
  - lib/fluent/plugin/out_s3.rb
67
+ - test/out_s3.rb
67
68
  - ChangeLog
68
69
  - README.rdoc
69
70
  has_rdoc: true
@@ -100,5 +101,5 @@ rubygems_version: 1.3.7
100
101
  signing_key:
101
102
  specification_version: 3
102
103
  summary: Amazon S3 output plugin for Fluent event collector
103
- test_files: []
104
-
104
+ test_files:
105
+ - test/out_s3.rb