fluent-plugin-groonga 1.1.8 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,13 +4,14 @@
4
4
 
5
5
  real_host 127.0.0.1
6
6
  real_port 20041
7
-
8
- # command_name_position record
9
7
  </source>
10
8
 
11
- <match groonga.command.**>
9
+ <match groonga.command.*>
12
10
  @type groonga
13
11
  protocol command
14
12
  database /tmp/groonga/db
15
- flush_interval 1
13
+
14
+ <buffer>
15
+ flush_interval 1
16
+ </buffer>
16
17
  </match>
@@ -4,14 +4,15 @@
4
4
 
5
5
  real_host 127.0.0.1
6
6
  real_port 20043
7
-
8
- # command_name_position record
9
7
  </source>
10
8
 
11
- <match groonga.command.**>
9
+ <match groonga.command.*>
12
10
  @type groonga
13
11
  protocol gqtp
14
12
  host 127.0.0.1
15
13
  port 30043
16
- flush_interval 1
14
+
15
+ <buffer>
16
+ flush_interval 1
17
+ </buffer>
17
18
  </match>
@@ -4,14 +4,15 @@
4
4
 
5
5
  real_host 127.0.0.1
6
6
  real_port 20041
7
-
8
- # command_name_position record
9
7
  </source>
10
8
 
11
- <match groonga.command.**>
9
+ <match groonga.command.*>
12
10
  @type groonga
13
11
  protocol http
14
12
  host 127.0.0.1
15
13
  port 30041
16
- flush_interval 1
14
+
15
+ <buffer>
16
+ flush_interval 1
17
+ </buffer>
17
18
  </match>
@@ -42,9 +42,11 @@
42
42
  protocol http
43
43
  host 127.0.0.1
44
44
 
45
- buffer_type file
46
- buffer_path /tmp/buffer
47
- flush_interval 1
45
+ <buffer>
46
+ @type file
47
+ path /tmp/buffer
48
+ flush_interval 1
49
+ <buffer>
48
50
 
49
51
  <table>
50
52
  name Codes
@@ -51,9 +51,11 @@
51
51
  protocol http
52
52
  host 127.0.0.1
53
53
 
54
- buffer_type file
55
- buffer_path /var/spool/td-agent/buffer/groonga
56
- flush_interval 1
54
+ <buffer>
55
+ @type file
56
+ path /var/spool/td-agent/buffer/groonga
57
+ flush_interval 1
58
+ </buffer>
57
59
 
58
60
  <table>
59
61
  name Terms
@@ -9,7 +9,9 @@
9
9
  protocol http
10
10
  host 127.0.0.1
11
11
 
12
- buffer_type file
13
- buffer_path /tmp/buffer
14
- flush_interval 1
12
+ <buffer>
13
+ @type file
14
+ path /tmp/buffer
15
+ flush_interval 1
16
+ <buffer>
15
17
  </match>
@@ -17,7 +17,7 @@ require "fluent/plugin/out_groonga"
17
17
 
18
18
  class OutputTypeTableDefinitionTest < Test::Unit::TestCase
19
19
  def definition(raw={})
20
- Fluent::GroongaOutput::TableDefinition.new(raw)
20
+ Fluent::Plugin::GroongaOutput::TableDefinition.new(raw)
21
21
  end
22
22
 
23
23
  sub_test_case "readers" do
@@ -21,7 +21,7 @@ class OutputTypeTableIndexDefinitionTest < Test::Unit::TestCase
21
21
  :name => "Terms",
22
22
  :default_tokenizer => "TokenBigram",
23
23
  }
24
- Fluent::GroongaOutput::TableDefinition.new(raw)
24
+ Fluent::Plugin::GroongaOutput::TableDefinition.new(raw)
25
25
  end
26
26
 
27
27
  def definition(raw={})
@@ -29,7 +29,7 @@ class OutputTypeTableIndexDefinitionTest < Test::Unit::TestCase
29
29
  :source_columns => "title",
30
30
  }
31
31
  raw = default_raw.merge(raw)
32
- Fluent::GroongaOutput::TableDefinition::IndexDefinition.new(table_definition,
32
+ Fluent::Plugin::GroongaOutput::TableDefinition::IndexDefinition.new(table_definition,
33
33
  raw)
34
34
  end
35
35
 
@@ -18,7 +18,7 @@ require "fluent/plugin/out_groonga"
18
18
  class OutputTypeGuesserTest < Test::Unit::TestCase
19
19
  sub_test_case "#guess" do
20
20
  def guess(sample_values)
21
- guesser = Fluent::GroongaOutput::Schema::TypeGuesser.new(sample_values)
21
+ guesser = Fluent::Plugin::GroongaOutput::Schema::TypeGuesser.new(sample_values)
22
22
  guesser.guess
23
23
  end
24
24
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,9 @@ Test::Unit::Priority.enable
31
31
  $LOAD_PATH.unshift(lib_dir)
32
32
 
33
33
  require "fluent/test"
34
+ require "fluent/test/helpers"
35
+
36
+ include Fluent::Test::Helpers
34
37
 
35
38
  ENV["TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"] ||= "5000"
36
39
 
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2018 Yasuhiro Horimoto <horimoto@clear-code.com>
4
1
  # Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
5
2
  #
6
3
  # This library is free software; you can redistribute it and/or
@@ -22,22 +19,21 @@ require "net/http"
22
19
  require "webrick/config"
23
20
  require "webrick/httpresponse"
24
21
 
25
- require "fluent/test"
26
- require "fluent/plugin/in_groonga"
22
+ require "fluent/test/driver/input"
27
23
 
28
- require "http_parser"
24
+ require "fluent/plugin/in_groonga"
29
25
 
30
26
  class GroongaInputTest < Test::Unit::TestCase
31
27
  setup :before => :append
32
28
  def setup_fluent
33
29
  Fluent::Test.setup
34
- @now = Time.parse("2012-10-26T08:45:42Z").to_i
30
+ @now = event_time("2012-10-26T08:45:42Z")
35
31
  Fluent::Engine.now = @now
36
32
  end
37
33
 
38
34
  private
39
35
  def create_driver
40
- driver = Fluent::Test::InputTestDriver.new(Fluent::GroongaInput)
36
+ driver = Fluent::Test::Driver::Input.new(Fluent::Plugin::GroongaInput)
41
37
  driver.configure(configuration)
42
38
  driver
43
39
  end
@@ -104,16 +100,21 @@ EOC
104
100
  def test_target_command
105
101
  @real_response["Content-Type"] = "application/json"
106
102
  @real_response.body = JSON.generate([[0, 0.0, 0.0], true])
107
- @driver.expect_emit("groonga.command.table_create",
108
- @now,
109
- {
110
- "name" => "Users",
111
- "flags" => "TABLE_NO_KEY",
112
- })
113
103
  @driver.run do
114
104
  get("/d/table_create", "name" => "Users", "flags" => "TABLE_NO_KEY")
115
105
  assert_equal("200", @last_response.code)
116
106
  end
107
+ assert_equal([
108
+ [
109
+ "groonga.command.table_create",
110
+ @now,
111
+ {
112
+ "name" => "Users",
113
+ "flags" => "TABLE_NO_KEY",
114
+ },
115
+ ]
116
+ ],
117
+ @driver.events)
117
118
  end
118
119
 
119
120
  def test_not_target_command
@@ -121,7 +122,7 @@ EOC
121
122
  get("/d/status")
122
123
  assert_equal("200", @last_response.code)
123
124
  end
124
- assert_empty(@driver.emits)
125
+ assert_empty(@driver.events)
125
126
  end
126
127
 
127
128
  def test_load
@@ -133,17 +134,21 @@ EOC
133
134
  {"name": "Bob"}
134
135
  ]
135
136
  EOJ
136
- @driver.expect_emit("groonga.command.load",
137
- @now,
138
- {
139
- "table" => "Users",
140
- "values" => json,
141
- })
142
-
143
137
  @driver.run do
144
138
  post("/d/load", json, "table" => "Users")
145
139
  assert_equal("200", @last_response.code)
146
140
  end
141
+ assert_equal([
142
+ [
143
+ "groonga.command.load",
144
+ @now,
145
+ {
146
+ "table" => "Users",
147
+ "values" => json,
148
+ },
149
+ ],
150
+ ],
151
+ @driver.events)
147
152
  end
148
153
 
149
154
  def test_not_command
@@ -154,59 +159,6 @@ EOJ
154
159
  end
155
160
  end
156
161
 
157
- sub_test_case("command_name_position") do
158
- sub_test_case("record") do
159
- def configuration
160
- <<-CONFIGURATION
161
- #{super}
162
- command_name_position record
163
- CONFIGURATION
164
- end
165
-
166
- def test_not_load
167
- @real_response["Content-Type"] = "application/json"
168
- @real_response.body = JSON.generate([[0, 0.0, 0.0], true])
169
- @driver.expect_emit("groonga.command",
170
- @now,
171
- {
172
- "name" => "table_create",
173
- "arguments" => {
174
- "name" => "Users",
175
- "flags" => "TABLE_NO_KEY",
176
- }
177
- })
178
- @driver.run do
179
- get("/d/table_create", "name" => "Users", "flags" => "TABLE_NO_KEY")
180
- assert_equal("200", @last_response.code)
181
- end
182
- end
183
-
184
- def test_load
185
- @real_response["Content-Type"] = "application/json"
186
- @real_response.body = JSON.generate([[0, 0.0, 0.0], true])
187
- json = <<-JSON
188
- [
189
- {"name": "Alice"},
190
- {"name": "Bob"}
191
- ]
192
- JSON
193
- @driver.expect_emit("groonga.command",
194
- @now,
195
- {
196
- "name" => "load",
197
- "arguments" => {
198
- "table" => "Users",
199
- "values" => json,
200
- }
201
- })
202
- @driver.run do
203
- post("/d/load", json, "table" => "Users")
204
- assert_equal("200", @last_response.code)
205
- end
206
- end
207
- end
208
- end
209
-
210
162
  private
211
163
  def get(path, parameters={})
212
164
  http = Net::HTTP.new(@host, @port)
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2018 Yasuhiro Horimoto <horimoto@clear-code.com>
4
1
  # Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
5
2
  #
6
3
  # This library is free software; you can redistribute it and/or
@@ -22,10 +19,9 @@ require "net/http"
22
19
  require "webrick/config"
23
20
  require "webrick/httpresponse"
24
21
 
25
- require "fluent/test"
26
- require "fluent/plugin/out_groonga"
22
+ require "fluent/test/driver/output"
27
23
 
28
- require "http_parser"
24
+ require "fluent/plugin/out_groonga"
29
25
 
30
26
  class GroongaOutputTest < Test::Unit::TestCase
31
27
  setup :before => :append
@@ -34,9 +30,8 @@ class GroongaOutputTest < Test::Unit::TestCase
34
30
  end
35
31
 
36
32
  private
37
- def create_driver(tag)
38
- driver = Fluent::Test::BufferedOutputTestDriver.new(Fluent::GroongaOutput,
39
- tag)
33
+ def create_driver
34
+ driver = Fluent::Test::Driver::Output.new(Fluent::Plugin::GroongaOutput)
40
35
  driver.configure(configuration)
41
36
  driver
42
37
  end
@@ -97,27 +92,13 @@ EOC
97
92
  end
98
93
 
99
94
  class CommandTest < self
100
- def test_command_name_position_tag
95
+ def test_basic_command
101
96
  @response_body = JSON.generate([[0, 0.0, 0.0], true])
102
- driver = create_driver("groonga.command.table_create")
103
- time = Time.parse("2012-10-26T08:45:42Z").to_i
104
- driver.emit({"name" => "Users"}, time)
105
- driver.run
106
- assert_equal("/d/table_create?name=Users",
107
- @request_parser.request_url)
108
- end
109
-
110
- def test_command_name_position_record
111
- @response_body = JSON.generate([[0, 0.0, 0.0], true])
112
- driver = create_driver("groonga.command")
113
- time = Time.parse("2012-10-26T08:45:42Z").to_i
114
- driver.emit({
115
- "name" => "table_create",
116
- "arguments" => {
117
- "name" => "Users"
118
- }
119
- }, time)
120
- driver.run
97
+ driver = create_driver
98
+ time = event_time("2012-10-26T08:45:42Z")
99
+ driver.run(default_tag: "groonga.command.table_create") do
100
+ driver.feed(time, {"name" => "Users"})
101
+ end
121
102
  assert_equal("/d/table_create?name=Users",
122
103
  @request_parser.request_url)
123
104
  end
@@ -133,10 +114,11 @@ EOC
133
114
 
134
115
  def test_one_message
135
116
  @response_body = JSON.generate([[0, 0.0, 0.0], [1]])
136
- driver = create_driver("log")
137
- time = Time.parse("2012-10-26T08:45:42Z").to_i
138
- driver.emit({"message" => "1st message"}, time)
139
- driver.run
117
+ driver = create_driver
118
+ time = event_time("2012-10-26T08:45:42Z")
119
+ driver.run(default_tag: "log") do
120
+ driver.feed(time, {"message" => "1st message"})
121
+ end
140
122
  assert_equal("/d/load?table=Logs",
141
123
  @request_parser.request_url)
142
124
  assert_equal([{"message" => "1st message"}],
@@ -145,11 +127,12 @@ EOC
145
127
 
146
128
  def test_multiple_messages
147
129
  @response_body = JSON.generate([[0, 0.0, 0.0], [2]])
148
- driver = create_driver("log")
149
- time = Time.parse("2012-10-26T08:45:42Z").to_i
150
- driver.emit({"message" => "1st message"}, time)
151
- driver.emit({"message" => "2nd message"}, time + 1)
152
- driver.run
130
+ driver = create_driver
131
+ time = event_time("2012-10-26T08:45:42Z")
132
+ driver.run(default_tag: "log") do
133
+ driver.feed(time, {"message" => "1st message"})
134
+ driver.feed(time + 1, {"message" => "2nd message"})
135
+ end
153
136
  assert_equal("/d/load?table=Logs",
154
137
  @request_parser.request_url)
155
138
  assert_equal([
@@ -244,33 +227,12 @@ EOC
244
227
  end
245
228
 
246
229
  class CommandTest < self
247
- def test_command_name_position_tag
248
- driver = create_driver("groonga.command.table_create")
249
- time = Time.parse("2012-10-26T08:45:42Z").to_i
250
- driver.emit({"name" => "Users"}, time)
251
- driver.run
252
- assert_equal([
253
- [
254
- "--input-fd", actual_input_fd,
255
- "--output-fd", actual_output_fd,
256
- "-n", @database_path,
257
- ],
258
- "/d/table_create?name=Users\n",
259
- ],
260
- [
261
- actual_command_line,
262
- actual_input,
263
- ])
264
- end
265
-
266
- def test_command_name_position_record
267
- driver = create_driver("groonga.command")
268
- time = Time.parse("2012-10-26T08:45:42Z").to_i
269
- driver.emit({
270
- "name" => "table_create",
271
- "arguments" => {"name" => "Users"}
272
- }, time)
273
- driver.run
230
+ def test_basic_command
231
+ driver = create_driver
232
+ time = event_time("2012-10-26T08:45:42Z")
233
+ driver.run(default_tag: "groonga.command.table_create") do
234
+ driver.feed(time, {"name" => "Users"})
235
+ end
274
236
  assert_equal([
275
237
  [
276
238
  "--input-fd", actual_input_fd,