fluent-plugin-droonga 0.9.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dir-locals.el +3 -0
- data/.travis.yml +6 -2
- data/README.md +6 -7
- data/Rakefile +23 -6
- data/fluent-plugin-droonga.gemspec +2 -2
- data/lib/droonga/adapter.rb +12 -3
- data/lib/droonga/adapter_runner.rb +28 -23
- data/lib/droonga/catalog/base.rb +7 -111
- data/lib/droonga/catalog/dataset.rb +13 -25
- data/lib/droonga/catalog/errors.rb +94 -0
- data/lib/droonga/catalog/schema.rb +277 -0
- data/lib/droonga/catalog/version1.rb +404 -0
- data/lib/droonga/catalog/version2.rb +160 -0
- data/lib/droonga/catalog_loader.rb +27 -4
- data/lib/droonga/catalog_observer.rb +44 -6
- data/lib/droonga/collector.rb +12 -10
- data/lib/droonga/{handler_plugin.rb → collector_message.rb} +47 -20
- data/lib/droonga/collector_runner.rb +64 -0
- data/lib/droonga/collectors.rb +18 -0
- data/lib/droonga/{catalog.rb → collectors/add.rb} +9 -7
- data/lib/droonga/{command_repository.rb → collectors/and.rb} +7 -14
- data/lib/droonga/collectors/sum.rb +26 -0
- data/lib/droonga/dispatcher.rb +74 -41
- data/lib/droonga/distributed_command_planner.rb +2 -2
- data/lib/droonga/engine.rb +13 -5
- data/lib/droonga/{message_processing_error.rb → error.rb} +33 -12
- data/lib/droonga/{plugin/planner/search.rb → error_messages.rb} +12 -10
- data/lib/droonga/farm.rb +15 -14
- data/lib/droonga/fluent_message_sender.rb +15 -11
- data/lib/droonga/forwarder.rb +22 -18
- data/lib/droonga/handler.rb +8 -2
- data/lib/droonga/handler_runner.rb +47 -26
- data/lib/droonga/input_message.rb +6 -6
- data/lib/droonga/{command.rb → loggable.rb} +7 -14
- data/lib/droonga/logger.rb +56 -15
- data/lib/droonga/message_matcher.rb +12 -7
- data/lib/droonga/message_pusher.rb +8 -4
- data/lib/droonga/message_receiver.rb +11 -9
- data/lib/droonga/output_message.rb +2 -0
- data/lib/droonga/planner.rb +21 -10
- data/lib/droonga/plugin.rb +15 -0
- data/lib/droonga/plugin/metadata/{adapter_message.rb → adapter_input_message.rb} +6 -14
- data/lib/droonga/plugin/metadata/adapter_output_message.rb +39 -0
- data/lib/droonga/plugin/metadata/collector_message.rb +39 -0
- data/lib/droonga/plugin/metadata/input_message.rb +15 -0
- data/lib/droonga/plugin_loader.rb +33 -25
- data/lib/droonga/plugin_registry.rb +9 -1
- data/lib/droonga/plugins/basic.rb +54 -0
- data/lib/droonga/plugins/crud.rb +36 -15
- data/lib/droonga/plugins/error.rb +5 -4
- data/lib/droonga/plugins/groonga.rb +9 -6
- data/lib/droonga/plugins/groonga/column_create.rb +10 -5
- data/lib/droonga/plugins/groonga/generic_command.rb +2 -8
- data/lib/droonga/plugins/groonga/generic_response.rb +2 -2
- data/lib/droonga/plugins/groonga/select.rb +2 -2
- data/lib/droonga/plugins/groonga/table_create.rb +9 -4
- data/lib/droonga/plugins/groonga/table_remove.rb +10 -5
- data/lib/droonga/plugins/search.rb +106 -5
- data/lib/droonga/plugins/search/distributed_search_planner.rb +398 -0
- data/lib/droonga/plugins/watch.rb +41 -20
- data/lib/droonga/processor.rb +12 -9
- data/lib/droonga/{plugin/collector/basic.rb → reducer.rb} +36 -50
- data/lib/droonga/replier.rb +7 -4
- data/lib/droonga/searcher.rb +40 -37
- data/lib/droonga/server.rb +8 -6
- data/lib/droonga/session.rb +17 -7
- data/lib/droonga/single_step.rb +53 -0
- data/lib/droonga/{plugin/planner/watch.rb → single_step_definition.rb} +27 -26
- data/lib/droonga/{partition.rb → slice.rb} +23 -12
- data/lib/droonga/status_code.rb +25 -0
- data/lib/droonga/step_runner.rb +63 -0
- data/lib/droonga/watch_schema.rb +7 -3
- data/lib/droonga/watcher.rb +4 -4
- data/lib/droonga/worker.rb +6 -6
- data/lib/fluent/plugin/out_droonga.rb +27 -2
- data/sample/cluster/catalog.json +33 -32
- data/test/command/config/default/catalog.json +72 -45
- data/test/command/config/version1/catalog.json +68 -0
- data/test/command/config/version1/fluentd.conf +11 -0
- data/test/command/suite/message/error/missing-dataset.expected +1 -1
- data/test/command/suite/message/error/unknown-dataset.expected +1 -1
- data/test/command/suite/message/error/unknown-type.expected +13 -0
- data/test/command/suite/message/error/{unknown-command.test → unknown-type.test} +1 -1
- data/test/command/suite/search/error/missing-source-parameter.expected +1 -1
- data/test/command/suite/search/error/unknown-source.expected +15 -3
- data/test/command/suite/watch/subscribe.expected +1 -3
- data/test/command/suite/watch/unsubscribe.expected +1 -3
- data/test/performance/watch/catalog.json +1 -0
- data/test/unit/catalog/test_dataset.rb +16 -358
- data/test/unit/catalog/test_schema.rb +285 -0
- data/test/unit/catalog/test_version1.rb +222 -28
- data/test/unit/catalog/test_version2.rb +155 -0
- data/test/unit/fixtures/catalog/version2.json +62 -0
- data/test/unit/helper/distributed_search_planner_helper.rb +2 -2
- data/test/unit/plugins/crud/test_add.rb +13 -13
- data/test/unit/plugins/groonga/test_column_create.rb +14 -11
- data/test/unit/plugins/groonga/test_table_create.rb +4 -9
- data/test/unit/plugins/groonga/test_table_remove.rb +4 -9
- data/test/unit/{plugin/planner/search_planner → plugins/search/planner}/test_basic.rb +0 -0
- data/test/unit/{plugin/planner/search_planner → plugins/search/planner}/test_group_by.rb +0 -0
- data/test/unit/{plugin/planner/search_planner → plugins/search/planner}/test_output.rb +0 -0
- data/test/unit/{plugin/planner/search_planner → plugins/search/planner}/test_sort_by.rb +0 -0
- data/test/unit/{plugin/collector/test_search.rb → plugins/search/test_collector.rb} +40 -39
- data/test/unit/plugins/{test_search.rb → search/test_handler.rb} +6 -5
- data/test/unit/{plugin/planner/test_search.rb → plugins/search/test_planner.rb} +3 -3
- data/test/unit/{plugin/collector → plugins}/test_basic.rb +68 -50
- data/test/unit/plugins/test_groonga.rb +2 -15
- data/test/unit/plugins/test_watch.rb +25 -22
- data/test/unit/test_message_matcher.rb +29 -6
- data/test/unit/test_output.rb +4 -0
- metadata +58 -50
- data/lib/droonga/collector_plugin.rb +0 -50
- data/lib/droonga/legacy_pluggable.rb +0 -66
- data/lib/droonga/legacy_plugin.rb +0 -57
- data/lib/droonga/legacy_plugin_repository.rb +0 -54
- data/lib/droonga/planner_plugin.rb +0 -54
- data/lib/droonga/plugin/collector/search.rb +0 -98
- data/lib/droonga/plugin/planner/crud.rb +0 -49
- data/lib/droonga/plugin/planner/distributed_search_planner.rb +0 -393
- data/lib/droonga/plugin/planner/groonga.rb +0 -54
- data/lib/droonga/plugin_registerable.rb +0 -75
- data/test/command/suite/message/error/unknown-command.expected +0 -13
- data/test/unit/test_command_repository.rb +0 -39
- data/test/unit/test_legacy_plugin.rb +0 -50
- data/test/unit/test_legacy_plugin_repository.rb +0 -89
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -29,8 +29,10 @@ class SearchHandlerTest < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
def setup_plugin
|
31
31
|
@handler = Droonga::Test::StubHandler.new
|
32
|
-
@plugin = Droonga::Plugins::Search::Handler.new("droonga", @handler.context)
|
33
32
|
@messenger = Droonga::Test::StubHandlerMessenger.new
|
33
|
+
@plugin = Droonga::Plugins::Search::Handler.new("droonga",
|
34
|
+
@handler.context,
|
35
|
+
@messenger)
|
34
36
|
end
|
35
37
|
|
36
38
|
def teardown_plugin
|
@@ -41,8 +43,7 @@ class SearchHandlerTest < Test::Unit::TestCase
|
|
41
43
|
private
|
42
44
|
def search(request, headers={})
|
43
45
|
message = Droonga::Test::StubHandlerMessage.new(request, headers)
|
44
|
-
@plugin.handle(message
|
45
|
-
results_to_result_set(@messenger.values.first)
|
46
|
+
results_to_result_set(@plugin.handle(message))
|
46
47
|
end
|
47
48
|
|
48
49
|
def results_to_result_set(results)
|
@@ -51,7 +52,7 @@ class SearchHandlerTest < Test::Unit::TestCase
|
|
51
52
|
result_set[name] = normalize_result(result)
|
52
53
|
end
|
53
54
|
result_set
|
54
|
-
|
55
|
+
end
|
55
56
|
|
56
57
|
def normalize_result(result)
|
57
58
|
result["startTime"] = start_time if result["startTime"]
|
@@ -13,13 +13,13 @@
|
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
14
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
15
|
|
16
|
-
require "droonga/
|
16
|
+
require "droonga/plugins/search"
|
17
17
|
|
18
18
|
class SearchPlannerTest < Test::Unit::TestCase
|
19
19
|
def setup
|
20
20
|
setup_database
|
21
21
|
@planner = Droonga::Test::StubPlanner.new
|
22
|
-
@plugin = Droonga::
|
22
|
+
@plugin = Droonga::Plugins::Search::Planner.new
|
23
23
|
end
|
24
24
|
|
25
25
|
def teardown
|
@@ -56,7 +56,7 @@ class SearchPlannerTest < Test::Unit::TestCase
|
|
56
56
|
},
|
57
57
|
}
|
58
58
|
|
59
|
-
@planner.distribute(@plugin.
|
59
|
+
@planner.distribute(@plugin.plan(envelope))
|
60
60
|
|
61
61
|
message = []
|
62
62
|
|
@@ -13,16 +13,11 @@
|
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
14
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
15
|
|
16
|
-
require "droonga/
|
16
|
+
require "droonga/plugins/basic"
|
17
17
|
|
18
18
|
class BasicCollectorTest < Test::Unit::TestCase
|
19
19
|
def setup
|
20
20
|
setup_database
|
21
|
-
@plugin = Droonga::BasicCollector.new
|
22
|
-
@outputs = []
|
23
|
-
stub(@plugin).emit do |name, value|
|
24
|
-
@outputs << [name, value]
|
25
|
-
end
|
26
21
|
end
|
27
22
|
|
28
23
|
def teardown
|
@@ -34,6 +29,22 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
34
29
|
columns
|
35
30
|
end
|
36
31
|
|
32
|
+
def run_collector(collector, message)
|
33
|
+
collector_message = Droonga::CollectorMessage.new(message)
|
34
|
+
collector.collect(collector_message)
|
35
|
+
collector_message.values
|
36
|
+
end
|
37
|
+
|
38
|
+
def gather(message)
|
39
|
+
collector = Droonga::Plugins::Basic::GatherCollector.new
|
40
|
+
run_collector(collector, message)
|
41
|
+
end
|
42
|
+
|
43
|
+
def reduce(message)
|
44
|
+
collector = Droonga::Plugins::Basic::ReduceCollector.new
|
45
|
+
run_collector(collector, message)
|
46
|
+
end
|
47
|
+
|
37
48
|
class << self
|
38
49
|
def create_record(*columns)
|
39
50
|
columns
|
@@ -43,12 +54,12 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
43
54
|
class IOTest < self
|
44
55
|
data(
|
45
56
|
:simple_mapping => {
|
46
|
-
:expected =>
|
57
|
+
:expected => { "output_name" => "result" },
|
47
58
|
:source => "result",
|
48
59
|
:mapping => "output_name",
|
49
60
|
},
|
50
61
|
:complex_mapping => {
|
51
|
-
:expected =>
|
62
|
+
:expected => { "output_name" => "result" },
|
52
63
|
:source => "result",
|
53
64
|
:mapping => {
|
54
65
|
"output" => "output_name",
|
@@ -58,7 +69,7 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
58
69
|
def test_gather(data)
|
59
70
|
request = {
|
60
71
|
"task" => {
|
61
|
-
"values" =>
|
72
|
+
"values" => {},
|
62
73
|
"step" => {
|
63
74
|
"body" => nil,
|
64
75
|
"outputs" => nil,
|
@@ -69,8 +80,7 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
69
80
|
"name" => data[:mapping],
|
70
81
|
"descendants" => nil,
|
71
82
|
}
|
72
|
-
|
73
|
-
assert_equal(data[:expected], @outputs.last)
|
83
|
+
assert_equal(data[:expected], gather(request))
|
74
84
|
end
|
75
85
|
|
76
86
|
def test_reduce
|
@@ -98,16 +108,18 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
98
108
|
"name" => input_name,
|
99
109
|
"descendants" => nil,
|
100
110
|
}
|
101
|
-
|
102
|
-
|
103
|
-
output_name,
|
104
|
-
[0, 1, 2, 3, 4, 5],
|
105
|
-
],
|
106
|
-
@outputs.last)
|
111
|
+
assert_equal({ output_name => [0, 1, 2, 3, 4, 5] },
|
112
|
+
reduce(request))
|
107
113
|
end
|
108
114
|
end
|
109
115
|
|
110
|
-
|
116
|
+
# TODO: Split file
|
117
|
+
class ReducerTest < self
|
118
|
+
def reduce_value(deal, left_value, right_value)
|
119
|
+
reducer = Droonga::Reducer.new(deal)
|
120
|
+
reducer.reduce(left_value, right_value)
|
121
|
+
end
|
122
|
+
|
111
123
|
data(
|
112
124
|
:int => {
|
113
125
|
:expected => 1.5,
|
@@ -121,9 +133,9 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
121
133
|
},
|
122
134
|
)
|
123
135
|
def test_average(data)
|
124
|
-
reduced =
|
125
|
-
|
126
|
-
|
136
|
+
reduced = reduce_value({ "type" => "average" },
|
137
|
+
data[:left],
|
138
|
+
data[:right])
|
127
139
|
assert_equal(data[:expected], reduced)
|
128
140
|
end
|
129
141
|
|
@@ -150,9 +162,9 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
150
162
|
},
|
151
163
|
)
|
152
164
|
def test_and(data)
|
153
|
-
reduced =
|
154
|
-
|
155
|
-
|
165
|
+
reduced = reduce_value({ "type" => "and" },
|
166
|
+
data[:left],
|
167
|
+
data[:right])
|
156
168
|
assert_equal(data[:expected], reduced)
|
157
169
|
end
|
158
170
|
|
@@ -179,9 +191,9 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
179
191
|
},
|
180
192
|
)
|
181
193
|
def test_or(data)
|
182
|
-
reduced =
|
183
|
-
|
184
|
-
|
194
|
+
reduced = reduce_value({ "type" => "or" },
|
195
|
+
data[:left],
|
196
|
+
data[:right])
|
185
197
|
assert_equal(data[:expected], reduced)
|
186
198
|
end
|
187
199
|
|
@@ -273,10 +285,10 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
273
285
|
},
|
274
286
|
)
|
275
287
|
def test_sum(data)
|
276
|
-
reduced =
|
277
|
-
|
278
|
-
|
279
|
-
|
288
|
+
reduced = reduce_value({ "type" => "sum",
|
289
|
+
"limit" => data[:limit] || -1 },
|
290
|
+
data[:left],
|
291
|
+
data[:right])
|
280
292
|
assert_equal(data[:expected], reduced)
|
281
293
|
end
|
282
294
|
|
@@ -357,20 +369,26 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
357
369
|
},
|
358
370
|
)
|
359
371
|
def test_sort(data)
|
360
|
-
reduced =
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
372
|
+
reduced = reduce_value({
|
373
|
+
"type" => "sort",
|
374
|
+
"operators" => [
|
375
|
+
{ "column" => 0, "operator" => "<" },
|
376
|
+
],
|
377
|
+
"limit" => data[:limit] || -1,
|
378
|
+
},
|
379
|
+
data[:left],
|
380
|
+
data[:right])
|
369
381
|
assert_equal(data[:expected], reduced)
|
370
382
|
end
|
371
383
|
end
|
372
384
|
|
385
|
+
# TODO: Split file
|
373
386
|
class MergeTest < self
|
387
|
+
def reduce_value(deal, left_value, right_value)
|
388
|
+
reducer = Droonga::Reducer.new(deal)
|
389
|
+
reducer.reduce(left_value, right_value)
|
390
|
+
end
|
391
|
+
|
374
392
|
def test_grouped
|
375
393
|
expected = [
|
376
394
|
[
|
@@ -476,16 +494,16 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
476
494
|
],
|
477
495
|
]
|
478
496
|
|
479
|
-
reduced =
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
497
|
+
reduced = reduce_value({
|
498
|
+
"type" => "sort",
|
499
|
+
"operators" => [
|
500
|
+
{ "column" => 1, "operator" => "<" },
|
501
|
+
],
|
502
|
+
"key_column" => 0,
|
503
|
+
"limit" => -1,
|
504
|
+
},
|
505
|
+
left,
|
506
|
+
right)
|
489
507
|
assert_equal(expected, reduced)
|
490
508
|
end
|
491
509
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -45,7 +45,7 @@ class GroongaHandlerTest < Test::Unit::TestCase
|
|
45
45
|
def process(command, request)
|
46
46
|
message = Droonga::Test::StubHandlerMessage.new(request)
|
47
47
|
handler = create_handler
|
48
|
-
handler.handle(message
|
48
|
+
handler.handle(message)
|
49
49
|
end
|
50
50
|
|
51
51
|
NORMALIZED_START_TIME = Time.parse("2013-07-11T16:04:28+0900").to_i
|
@@ -66,17 +66,4 @@ class GroongaHandlerTest < Test::Unit::TestCase
|
|
66
66
|
NORMALIZED_START_TIME,
|
67
67
|
NORMALIZED_ELAPSED_TIME,
|
68
68
|
]
|
69
|
-
|
70
|
-
def assert_valid_output(output)
|
71
|
-
expected = {
|
72
|
-
"result" => [],
|
73
|
-
}
|
74
|
-
normalized_output = Marshal.load(Marshal.dump(output))
|
75
|
-
normalized_output.each do |key, value|
|
76
|
-
if value.is_a?(Array)
|
77
|
-
normalized_output[key] = []
|
78
|
-
end
|
79
|
-
end
|
80
|
-
assert_equal(expected, normalized_output)
|
81
|
-
end
|
82
69
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013 Droonga Project
|
3
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -20,7 +20,7 @@ require "droonga/plugins/watch"
|
|
20
20
|
class WatchHandlerTest < Test::Unit::TestCase
|
21
21
|
include WatchHelper
|
22
22
|
|
23
|
-
SUCCESS_RESULT =
|
23
|
+
SUCCESS_RESULT = true
|
24
24
|
|
25
25
|
def setup
|
26
26
|
setup_database
|
@@ -45,13 +45,15 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
45
45
|
|
46
46
|
def process(command, request, headers={})
|
47
47
|
message = Droonga::Test::StubHandlerMessage.new(request, headers)
|
48
|
-
create_plugin.handle(message
|
48
|
+
create_plugin.handle(message)
|
49
49
|
end
|
50
50
|
|
51
51
|
public
|
52
52
|
class SubscribeTest < self
|
53
53
|
def create_plugin
|
54
|
-
Droonga::Plugins::Watch::SubscribeHandler.new("droonga",
|
54
|
+
Droonga::Plugins::Watch::SubscribeHandler.new("droonga",
|
55
|
+
@handler.context,
|
56
|
+
@messenger)
|
55
57
|
end
|
56
58
|
|
57
59
|
def test_subscribe
|
@@ -60,8 +62,8 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
60
62
|
"condition" => "たいやき",
|
61
63
|
"subscriber" => "localhost"
|
62
64
|
}
|
63
|
-
process(:subscribe, request)
|
64
|
-
assert_equal(
|
65
|
+
response = process(:subscribe, request)
|
66
|
+
assert_equal(SUCCESS_RESULT, response)
|
65
67
|
|
66
68
|
assert_equal(
|
67
69
|
["localhost:23003/output"],
|
@@ -74,8 +76,8 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
74
76
|
"condition" => "たいやき",
|
75
77
|
"subscriber" => "localhost"
|
76
78
|
}
|
77
|
-
process(:subscribe, request, "from" => "localhost:23004/output")
|
78
|
-
assert_equal(
|
79
|
+
response = process(:subscribe, request, "from" => "localhost:23004/output")
|
80
|
+
assert_equal(SUCCESS_RESULT, response)
|
79
81
|
|
80
82
|
assert_equal(
|
81
83
|
["localhost:23004/output"],
|
@@ -89,8 +91,8 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
89
91
|
"subscriber" => "localhost",
|
90
92
|
"route" => "localhost:23003/output"
|
91
93
|
}
|
92
|
-
process(:subscribe, request, "from" => "localhost:23004/output")
|
93
|
-
assert_equal(
|
94
|
+
response = process(:subscribe, request, "from" => "localhost:23004/output")
|
95
|
+
assert_equal(SUCCESS_RESULT, response)
|
94
96
|
|
95
97
|
assert_equal(
|
96
98
|
["localhost:23003/output"],
|
@@ -116,7 +118,8 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
116
118
|
|
117
119
|
def create_plugin
|
118
120
|
Droonga::Plugins::Watch::UnsubscribeHandler.new("droonga",
|
119
|
-
@handler.context
|
121
|
+
@handler.context,
|
122
|
+
@messenger)
|
120
123
|
end
|
121
124
|
|
122
125
|
def test_unsubscribe
|
@@ -125,8 +128,8 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
125
128
|
"condition" => "たいやき",
|
126
129
|
"subscriber" => "localhost"
|
127
130
|
}
|
128
|
-
process(:unsubscribe, request)
|
129
|
-
assert_equal(
|
131
|
+
response = process(:unsubscribe, request)
|
132
|
+
assert_equal(SUCCESS_RESULT, response)
|
130
133
|
end
|
131
134
|
|
132
135
|
private
|
@@ -136,9 +139,8 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
136
139
|
"condition" => "たいやき",
|
137
140
|
"subscriber" => "localhost"
|
138
141
|
}
|
139
|
-
process(:subscribe, request)
|
140
|
-
assert_equal(
|
141
|
-
@messenger.values.clear
|
142
|
+
response = process(:subscribe, request)
|
143
|
+
assert_equal(SUCCESS_RESULT, response)
|
142
144
|
end
|
143
145
|
end
|
144
146
|
|
@@ -150,7 +152,8 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
150
152
|
|
151
153
|
def create_plugin
|
152
154
|
Droonga::Plugins::Watch::FeedHandler.new("droonga",
|
153
|
-
@handler.context
|
155
|
+
@handler.context,
|
156
|
+
@messenger)
|
154
157
|
end
|
155
158
|
|
156
159
|
def test_feed_match
|
@@ -181,8 +184,7 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
181
184
|
"text" => "たこやきおいしいです"
|
182
185
|
}
|
183
186
|
}
|
184
|
-
process(:feed, request)
|
185
|
-
assert_equal([], @messenger.messages)
|
187
|
+
assert_nil(process(:feed, request))
|
186
188
|
end
|
187
189
|
|
188
190
|
private
|
@@ -195,9 +197,10 @@ class WatchHandlerTest < Test::Unit::TestCase
|
|
195
197
|
message = Droonga::Test::StubHandlerMessage.new(request, {})
|
196
198
|
subscribe_handler =
|
197
199
|
Droonga::Plugins::Watch::SubscribeHandler.new("droonga",
|
198
|
-
@handler.context
|
199
|
-
|
200
|
-
|
200
|
+
@handler.context,
|
201
|
+
@messenger)
|
202
|
+
response = subscribe_handler.handle(message)
|
203
|
+
assert_equal(SUCCESS_RESULT, response)
|
201
204
|
end
|
202
205
|
end
|
203
206
|
end
|
@@ -90,26 +90,26 @@ class MessageMatcherTest < Test::Unit::TestCase
|
|
90
90
|
|
91
91
|
class IncludeTest < self
|
92
92
|
def test_exist
|
93
|
-
assert_true(match?(["originalTypes", :include
|
93
|
+
assert_true(match?(["originalTypes", :include, "select"],
|
94
94
|
{
|
95
95
|
"originalTypes" => ["search", "select"],
|
96
96
|
}))
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_not_exist
|
100
|
-
assert_false(match?(["originalTypes", :include
|
100
|
+
assert_false(match?(["originalTypes", :include, "select"],
|
101
101
|
{
|
102
102
|
"originalTypes" => ["load"],
|
103
103
|
}))
|
104
104
|
end
|
105
105
|
|
106
106
|
def test_no_key
|
107
|
-
assert_false(match?(["originalTypes", :include
|
107
|
+
assert_false(match?(["originalTypes", :include, "select"],
|
108
108
|
{}))
|
109
109
|
end
|
110
110
|
|
111
111
|
def test_not_enumerable
|
112
|
-
assert_false(match?(["originalTypes", :include
|
112
|
+
assert_false(match?(["originalTypes", :include, "select"],
|
113
113
|
{
|
114
114
|
"originalTypes" => 29,
|
115
115
|
}))
|
@@ -118,7 +118,7 @@ class MessageMatcherTest < Test::Unit::TestCase
|
|
118
118
|
|
119
119
|
class ExistTest < self
|
120
120
|
def test_exist
|
121
|
-
assert_true(match?(["body.result", :exist
|
121
|
+
assert_true(match?(["body.result", :exist],
|
122
122
|
{
|
123
123
|
"body" => {
|
124
124
|
"result" => nil,
|
@@ -127,11 +127,34 @@ class MessageMatcherTest < Test::Unit::TestCase
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_not_exist
|
130
|
-
assert_false(match?(["body.result", :exist
|
130
|
+
assert_false(match?(["body.result", :exist],
|
131
131
|
{
|
132
132
|
"body" => nil,
|
133
133
|
}))
|
134
134
|
end
|
135
135
|
end
|
136
|
+
|
137
|
+
class StartWithTest < self
|
138
|
+
def test_start_with
|
139
|
+
assert_true(match?(["type", :start_with, "watch."],
|
140
|
+
{
|
141
|
+
"type" => "watch.subscribe",
|
142
|
+
}))
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_not_start_with
|
146
|
+
assert_false(match?(["type", :start_with, "watch."],
|
147
|
+
{
|
148
|
+
"type" => "table_create",
|
149
|
+
}))
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_nil_value
|
153
|
+
assert_false(match?(["type", :start_with, "watch."],
|
154
|
+
{
|
155
|
+
"type" => nil,
|
156
|
+
}))
|
157
|
+
end
|
158
|
+
end
|
136
159
|
end
|
137
160
|
end
|