fluent-plugin-couch 0.7.0 → 0.8.0
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 +4 -4
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/lib/fluent/plugin/out_couch.rb +4 -2
- data/test/test_out_couch.rb +158 -0
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d073471a0ed7c484d199419351e9113b23776b30
|
4
|
+
data.tar.gz: 3b1128f4df0679566c9ab1fb2a2616cebacf7fce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e71cce5a1c21275f20e25fe2e9adfe8d58e50ed6ac3fc9a385806074553c6fc1678a4c8e6b4689fbdded036452716afde4c195e622670e09ebf7f44f80584bb
|
7
|
+
data.tar.gz: 43b3235f4d99417db0601479c547b5c58a639cb12ff22d957e14e6c5b44cc57f2e39434313ae51357f54fa15f98ccc45b8f0845413bb0be58efe3a3e35df66a1
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Fluent
|
2
2
|
class CouchOutput < BufferedOutput
|
3
|
+
attr_reader :db # for tests
|
4
|
+
|
3
5
|
include SetTagKeyMixin
|
4
6
|
config_set_default :include_tag_key, false
|
5
7
|
|
@@ -35,12 +37,12 @@ module Fluent
|
|
35
37
|
|
36
38
|
def configure(conf)
|
37
39
|
super
|
40
|
+
account = "#{@user}:#{@password}@" if @user && @password
|
41
|
+
@db = CouchRest.database!("#{@protocol}://#{account}#{@host}:#{@port}/#{@database}")
|
38
42
|
end
|
39
43
|
|
40
44
|
def start
|
41
45
|
super
|
42
|
-
account = "#{@user}:#{@password}@" if @user && @password
|
43
|
-
@db = CouchRest.database!("#{@protocol}://#{account}#{@host}:#{@port}/#{@database}")
|
44
46
|
@views = []
|
45
47
|
if @refresh_view_index
|
46
48
|
begin
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require "fluent/test"
|
2
|
+
require "fluent/plugin/out_couch"
|
3
|
+
|
4
|
+
class CouchOutputTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
DATABASE_NAME = "fluent_test"
|
10
|
+
COUCHHOST = ENV['COUCHHOST'] || "http://127.0.0.1:5984"
|
11
|
+
|
12
|
+
CONFIG = %[
|
13
|
+
database #{DATABASE_NAME}
|
14
|
+
]
|
15
|
+
|
16
|
+
CONFIG_UPDATE_DOC = %[
|
17
|
+
database #{DATABASE_NAME}
|
18
|
+
doc_key_field key
|
19
|
+
update_docs true
|
20
|
+
]
|
21
|
+
|
22
|
+
CONFIG_JSONPATH = %[
|
23
|
+
database #{DATABASE_NAME}
|
24
|
+
doc_key_field key
|
25
|
+
doc_key_jsonpath $.nested.key
|
26
|
+
]
|
27
|
+
|
28
|
+
CONFIG_DESIGN = %[
|
29
|
+
database #{DATABASE_NAME}
|
30
|
+
doc_key_field key
|
31
|
+
refresh_view_index d01
|
32
|
+
]
|
33
|
+
|
34
|
+
def prepare_db
|
35
|
+
@cr = CouchRest.new(COUCHHOST)
|
36
|
+
@db = @cr.database(DATABASE_NAME)
|
37
|
+
@db.delete! rescue nil
|
38
|
+
@cr.create_db(DATABASE_NAME)
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_driver(config = CONFIG)
|
42
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::CouchOutput).configure(config)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_configure
|
46
|
+
d = create_driver
|
47
|
+
assert_equal(DATABASE_NAME, d.instance.database)
|
48
|
+
assert_equal('localhost', d.instance.host)
|
49
|
+
assert_equal('5984', d.instance.port)
|
50
|
+
assert_equal('http', d.instance.protocol)
|
51
|
+
assert_nil(d.instance.refresh_view_index)
|
52
|
+
assert_nil(d.instance.user)
|
53
|
+
assert_nil(d.instance.password)
|
54
|
+
assert_false(d.instance.instance_variable_get(:@update_docs))
|
55
|
+
assert_nil(d.instance.doc_key_field)
|
56
|
+
assert_nil(d.instance.doc_key_jsonpath)
|
57
|
+
end
|
58
|
+
|
59
|
+
class WriteTest < self
|
60
|
+
def setup
|
61
|
+
@d = create_driver
|
62
|
+
prepare_db
|
63
|
+
end
|
64
|
+
|
65
|
+
def teardown
|
66
|
+
@db.delete!
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_write
|
70
|
+
previous_rows = @d.instance.db.all_docs["total_rows"]
|
71
|
+
time = Time.now.to_i
|
72
|
+
@d.emit({"message" => "record"}, time)
|
73
|
+
@d.run
|
74
|
+
rows = @d.instance.db.all_docs["total_rows"]
|
75
|
+
assert_equal(rows, previous_rows + 1)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class WriteWithUpdateDocTest < self
|
80
|
+
def setup
|
81
|
+
@d = create_driver(CONFIG_UPDATE_DOC)
|
82
|
+
prepare_db
|
83
|
+
end
|
84
|
+
|
85
|
+
def teardown
|
86
|
+
@db.delete!
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_write
|
90
|
+
time = Time.now.to_i
|
91
|
+
@d.emit({"key" => "record-1", "message" => "record"}, time)
|
92
|
+
@d.run
|
93
|
+
previous_rows = @d.instance.db.all_docs["total_rows"]
|
94
|
+
@d.emit({"key" => "record-1", "message" => "record-mod"}, time)
|
95
|
+
@d.run
|
96
|
+
rows = @d.instance.db.all_docs["total_rows"]
|
97
|
+
record = @d.instance.db.get("record-1")
|
98
|
+
assert_equal(rows, previous_rows)
|
99
|
+
assert_equal("record-mod", record["message"])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class WriteWithJsonpathTest < self
|
104
|
+
def setup
|
105
|
+
@d = create_driver(CONFIG_JSONPATH)
|
106
|
+
prepare_db
|
107
|
+
end
|
108
|
+
|
109
|
+
def teardown
|
110
|
+
@db.delete!
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_write
|
114
|
+
time = Time.now.to_i
|
115
|
+
@d.emit({"nested" => {"key" => "record-nested", "message" => "record"}}, time)
|
116
|
+
@d.run
|
117
|
+
record = @d.instance.db.get("record-nested")
|
118
|
+
assert_equal({"key" => "record-nested", "message" => "record"}, record["nested"])
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
class WriteWithDesignTest < self
|
123
|
+
def setup
|
124
|
+
@d = create_driver(CONFIG_DESIGN)
|
125
|
+
prepare_db
|
126
|
+
setup_design
|
127
|
+
end
|
128
|
+
|
129
|
+
def setup_design
|
130
|
+
message_by_key = {
|
131
|
+
:map => 'function(doc) {
|
132
|
+
if (doc._id == "record-design") {
|
133
|
+
emit(doc._id, doc.message);
|
134
|
+
}
|
135
|
+
}',
|
136
|
+
}
|
137
|
+
@db.delete_doc db.get("_design/d01") rescue nil
|
138
|
+
@db.save_doc({
|
139
|
+
"_id" => "_design/d01",
|
140
|
+
:views => {
|
141
|
+
:messages => message_by_key
|
142
|
+
}
|
143
|
+
})
|
144
|
+
end
|
145
|
+
|
146
|
+
def teardown
|
147
|
+
@db.delete!
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_write
|
151
|
+
time = Time.now.to_i
|
152
|
+
@d.emit({"key" => "record-design", "message" => "record"}, time)
|
153
|
+
@d.run
|
154
|
+
record = @d.instance.db.get("record-design")
|
155
|
+
assert_equal("record", record["message"])
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-couch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuri Odagiri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.10.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: couchrest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.1.2
|
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
40
|
version: 1.1.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jsonpath
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.4.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.4.2
|
55
55
|
description:
|
@@ -60,10 +60,11 @@ extra_rdoc_files:
|
|
60
60
|
- README.rdoc
|
61
61
|
files:
|
62
62
|
- AUTHORS
|
63
|
+
- README.rdoc
|
63
64
|
- Rakefile
|
64
65
|
- VERSION
|
65
66
|
- lib/fluent/plugin/out_couch.rb
|
66
|
-
-
|
67
|
+
- test/test_out_couch.rb
|
67
68
|
homepage: http://github.com/ixixi/fluent-plugin-couch
|
68
69
|
licenses: []
|
69
70
|
metadata: {}
|
@@ -73,18 +74,19 @@ require_paths:
|
|
73
74
|
- lib
|
74
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
76
|
requirements:
|
76
|
-
- -
|
77
|
+
- - ">="
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
|
-
- -
|
82
|
+
- - ">="
|
82
83
|
- !ruby/object:Gem::Version
|
83
84
|
version: '0'
|
84
85
|
requirements: []
|
85
86
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.5.2
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: CouchDB output plugin for Fluentd event collector
|
90
|
-
test_files:
|
91
|
+
test_files:
|
92
|
+
- test/test_out_couch.rb
|