droonga-engine 1.0.1
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.
- data/.dir-locals.el +3 -0
- data/.gitignore +6 -0
- data/.travis.yml +15 -0
- data/.yardopts +7 -0
- data/Gemfile +66 -0
- data/LICENSE.txt +14 -0
- data/README.md +17 -0
- data/Rakefile +64 -0
- data/benchmark/benchmark.rb +123 -0
- data/benchmark/utils.rb +246 -0
- data/benchmark/watch/benchmark-notify.rb +143 -0
- data/benchmark/watch/benchmark-notify.sh +20 -0
- data/benchmark/watch/benchmark-publish.rb +120 -0
- data/benchmark/watch/benchmark-scan.rb +213 -0
- data/bin/droonga-catalog-generate +103 -0
- data/bin/droonga-engine +20 -0
- data/bin/droonga-engine-service +20 -0
- data/doc/text/news.md +106 -0
- data/droonga-engine.gemspec +52 -0
- data/lib/droonga/adapter.rb +48 -0
- data/lib/droonga/adapter_runner.rb +104 -0
- data/lib/droonga/catalog/base.rb +41 -0
- data/lib/droonga/catalog/collection_volume.rb +106 -0
- data/lib/droonga/catalog/dataset.rb +69 -0
- data/lib/droonga/catalog/errors.rb +113 -0
- data/lib/droonga/catalog/schema.rb +186 -0
- data/lib/droonga/catalog/single_volume.rb +28 -0
- data/lib/droonga/catalog/slice.rb +41 -0
- data/lib/droonga/catalog/version1.rb +427 -0
- data/lib/droonga/catalog/version2.rb +96 -0
- data/lib/droonga/catalog/version2_validator.rb +63 -0
- data/lib/droonga/catalog/volume.rb +33 -0
- data/lib/droonga/catalog/volume_collection.rb +56 -0
- data/lib/droonga/catalog_generator.rb +156 -0
- data/lib/droonga/catalog_loader.rb +56 -0
- data/lib/droonga/catalog_observer.rb +83 -0
- data/lib/droonga/collector.rb +38 -0
- data/lib/droonga/collector_message.rb +71 -0
- data/lib/droonga/collector_runner.rb +64 -0
- data/lib/droonga/collectors/and.rb +26 -0
- data/lib/droonga/collectors/or.rb +26 -0
- data/lib/droonga/collectors/sum.rb +26 -0
- data/lib/droonga/collectors.rb +18 -0
- data/lib/droonga/dispatcher.rb +326 -0
- data/lib/droonga/distributed_command_planner.rb +179 -0
- data/lib/droonga/distributor.rb +87 -0
- data/lib/droonga/engine/command/droonga_engine.rb +441 -0
- data/lib/droonga/engine/version.rb +20 -0
- data/lib/droonga/engine.rb +80 -0
- data/lib/droonga/engine_state.rb +79 -0
- data/lib/droonga/error.rb +73 -0
- data/lib/droonga/error_messages.rb +33 -0
- data/lib/droonga/event_loop.rb +46 -0
- data/lib/droonga/farm.rb +58 -0
- data/lib/droonga/fluent_message_receiver.rb +191 -0
- data/lib/droonga/fluent_message_sender.rb +140 -0
- data/lib/droonga/forwarder.rb +119 -0
- data/lib/droonga/handler.rb +49 -0
- data/lib/droonga/handler_message.rb +61 -0
- data/lib/droonga/handler_messenger.rb +119 -0
- data/lib/droonga/handler_runner.rb +125 -0
- data/lib/droonga/input_message.rb +51 -0
- data/lib/droonga/job_protocol.rb +20 -0
- data/lib/droonga/job_pusher.rb +179 -0
- data/lib/droonga/job_receiver.rb +70 -0
- data/lib/droonga/loggable.rb +29 -0
- data/lib/droonga/logger.rb +142 -0
- data/lib/droonga/message_matcher.rb +109 -0
- data/lib/droonga/output_message.rb +55 -0
- data/lib/droonga/planner.rb +47 -0
- data/lib/droonga/pluggable.rb +31 -0
- data/lib/droonga/plugin/metadata/adapter_input_message.rb +39 -0
- 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/handler_action.rb +39 -0
- data/lib/droonga/plugin/metadata/input_message.rb +54 -0
- data/lib/droonga/plugin.rb +43 -0
- data/lib/droonga/plugin_loader.rb +63 -0
- data/lib/droonga/plugin_registry.rb +66 -0
- data/lib/droonga/plugins/basic.rb +54 -0
- data/lib/droonga/plugins/crud.rb +145 -0
- data/lib/droonga/plugins/dump.rb +97 -0
- data/lib/droonga/plugins/error.rb +51 -0
- data/lib/droonga/plugins/groonga/column_create.rb +123 -0
- data/lib/droonga/plugins/groonga/column_list.rb +124 -0
- data/lib/droonga/plugins/groonga/column_remove.rb +65 -0
- data/lib/droonga/plugins/groonga/column_rename.rb +67 -0
- data/lib/droonga/plugins/groonga/delete.rb +117 -0
- data/lib/droonga/plugins/groonga/generic_command.rb +105 -0
- data/lib/droonga/plugins/groonga/generic_response.rb +43 -0
- data/lib/droonga/plugins/groonga/select.rb +236 -0
- data/lib/droonga/plugins/groonga/table_create.rb +111 -0
- data/lib/droonga/plugins/groonga/table_list.rb +120 -0
- data/lib/droonga/plugins/groonga/table_remove.rb +57 -0
- data/lib/droonga/plugins/groonga.rb +37 -0
- data/lib/droonga/plugins/search/distributed_search_planner.rb +407 -0
- data/lib/droonga/plugins/search.rb +146 -0
- data/lib/droonga/plugins/watch.rb +178 -0
- data/lib/droonga/processor.rb +63 -0
- data/lib/droonga/reducer.rb +169 -0
- data/lib/droonga/replier.rb +49 -0
- data/lib/droonga/schema_applier.rb +167 -0
- data/lib/droonga/searcher/mecab_filter.rb +67 -0
- data/lib/droonga/searcher.rb +733 -0
- data/lib/droonga/server.rb +45 -0
- data/lib/droonga/session.rb +99 -0
- data/lib/droonga/single_step.rb +68 -0
- data/lib/droonga/single_step_definition.rb +54 -0
- data/lib/droonga/slice.rb +122 -0
- data/lib/droonga/status_code.rb +25 -0
- data/lib/droonga/step_runner.rb +64 -0
- data/lib/droonga/sweeper.rb +42 -0
- data/lib/droonga/test/stub_handler.rb +37 -0
- data/lib/droonga/test/stub_handler_message.rb +35 -0
- data/lib/droonga/test/stub_handler_messenger.rb +34 -0
- data/lib/droonga/test/stub_planner.rb +31 -0
- data/lib/droonga/test.rb +21 -0
- data/lib/droonga/watch_schema.rb +92 -0
- data/lib/droonga/watcher.rb +257 -0
- data/lib/droonga/worker.rb +61 -0
- data/sample/cluster/catalog.json +42 -0
- data/sample/mecab_filter/data.grn +7 -0
- data/sample/mecab_filter/ddl.grn +7 -0
- data/sample/mecab_filter/search_with_mecab_filter.json +21 -0
- data/sample/mecab_filter/search_without_mecab_filter.json +21 -0
- data/test/command/config/default/catalog.json +85 -0
- data/test/command/config/default/fluentd.conf +11 -0
- data/test/command/config/version1/catalog.json +68 -0
- data/test/command/config/version1/fluentd.conf +11 -0
- data/test/command/fixture/documents.jsons +208 -0
- data/test/command/fixture/event.jsons +41 -0
- data/test/command/fixture/user-table-array.jsons +38 -0
- data/test/command/fixture/user-table.jsons +47 -0
- data/test/command/run-test.rb +34 -0
- data/test/command/suite/add/dimension/column.catalog.json +28 -0
- data/test/command/suite/add/dimension/column.expected +41 -0
- data/test/command/suite/add/dimension/column.test +51 -0
- data/test/command/suite/add/dimension/integer.catalog.json +19 -0
- data/test/command/suite/add/dimension/integer.expected +41 -0
- data/test/command/suite/add/dimension/integer.test +51 -0
- data/test/command/suite/add/error/invalid-integer.expected +46 -0
- data/test/command/suite/add/error/invalid-integer.test +12 -0
- data/test/command/suite/add/error/invalid-time.expected +46 -0
- data/test/command/suite/add/error/invalid-time.test +12 -0
- data/test/command/suite/add/error/missing-key.expected +25 -0
- data/test/command/suite/add/error/missing-key.test +16 -0
- data/test/command/suite/add/error/missing-table.expected +25 -0
- data/test/command/suite/add/error/missing-table.test +16 -0
- data/test/command/suite/add/error/unknown-column.expected +46 -0
- data/test/command/suite/add/error/unknown-column.test +12 -0
- data/test/command/suite/add/error/unknown-table.expected +25 -0
- data/test/command/suite/add/error/unknown-table.test +17 -0
- data/test/command/suite/add/minimum.expected +6 -0
- data/test/command/suite/add/minimum.test +11 -0
- data/test/command/suite/add/with-values.expected +6 -0
- data/test/command/suite/add/with-values.test +17 -0
- data/test/command/suite/add/without-key.expected +6 -0
- data/test/command/suite/add/without-key.test +16 -0
- data/test/command/suite/groonga/column_create/scalar.expected +26 -0
- data/test/command/suite/groonga/column_create/scalar.test +17 -0
- data/test/command/suite/groonga/column_create/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_create/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_create/vector.expected +26 -0
- data/test/command/suite/groonga/column_create/vector.test +18 -0
- data/test/command/suite/groonga/column_list/success.expected +86 -0
- data/test/command/suite/groonga/column_list/success.test +24 -0
- data/test/command/suite/groonga/column_list/unknown-table.expected +13 -0
- data/test/command/suite/groonga/column_list/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_remove/success.expected +39 -0
- data/test/command/suite/groonga/column_remove/success.test +25 -0
- data/test/command/suite/groonga/column_remove/unknown-column.expected +27 -0
- data/test/command/suite/groonga/column_remove/unknown-column.test +16 -0
- data/test/command/suite/groonga/column_remove/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_remove/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_rename/success.expected +39 -0
- data/test/command/suite/groonga/column_rename/success.test +26 -0
- data/test/command/suite/groonga/column_rename/unknown-column.expected +27 -0
- data/test/command/suite/groonga/column_rename/unknown-column.test +16 -0
- data/test/command/suite/groonga/column_rename/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_rename/unknown-table.test +7 -0
- data/test/command/suite/groonga/delete/duplicated-identifiers.expected +27 -0
- data/test/command/suite/groonga/delete/duplicated-identifiers.test +17 -0
- data/test/command/suite/groonga/delete/filter.expected +19 -0
- data/test/command/suite/groonga/delete/filter.test +19 -0
- data/test/command/suite/groonga/delete/invalid-filter.expected +14 -0
- data/test/command/suite/groonga/delete/invalid-filter.test +9 -0
- data/test/command/suite/groonga/delete/no-identifier.expected +27 -0
- data/test/command/suite/groonga/delete/no-identifier.test +15 -0
- data/test/command/suite/groonga/delete/success.expected +19 -0
- data/test/command/suite/groonga/delete/success.test +19 -0
- data/test/command/suite/groonga/delete/unknown-table.expected +14 -0
- data/test/command/suite/groonga/delete/unknown-table.test +7 -0
- data/test/command/suite/groonga/select/minimum.expected +22 -0
- data/test/command/suite/groonga/select/minimum.test +8 -0
- data/test/command/suite/groonga/table_create/array.expected +14 -0
- data/test/command/suite/groonga/table_create/array.test +8 -0
- data/test/command/suite/groonga/table_create/hash.expected +13 -0
- data/test/command/suite/groonga/table_create/hash.test +8 -0
- data/test/command/suite/groonga/table_list/success.expected +71 -0
- data/test/command/suite/groonga/table_list/success.test +15 -0
- data/test/command/suite/groonga/table_remove/success.expected +13 -0
- data/test/command/suite/groonga/table_remove/success.test +8 -0
- data/test/command/suite/groonga/table_remove/unknown-table.expected +14 -0
- data/test/command/suite/groonga/table_remove/unknown-table.test +7 -0
- data/test/command/suite/message/error/missing-dataset.expected +9 -0
- data/test/command/suite/message/error/missing-dataset.test +5 -0
- data/test/command/suite/message/error/unknown-dataset.expected +9 -0
- data/test/command/suite/message/error/unknown-dataset.test +6 -0
- data/test/command/suite/message/error/unknown-type.expected +9 -0
- data/test/command/suite/message/error/unknown-type.test +6 -0
- data/test/command/suite/search/adjusters/multiple.catalog.json +38 -0
- data/test/command/suite/search/adjusters/multiple.expected +19 -0
- data/test/command/suite/search/adjusters/multiple.test +75 -0
- data/test/command/suite/search/adjusters/one.catalog.json +38 -0
- data/test/command/suite/search/adjusters/one.expected +19 -0
- data/test/command/suite/search/adjusters/one.test +66 -0
- data/test/command/suite/search/attributes/array.expected +21 -0
- data/test/command/suite/search/attributes/array.test +28 -0
- data/test/command/suite/search/attributes/hash.expected +30 -0
- data/test/command/suite/search/attributes/hash.test +36 -0
- data/test/command/suite/search/complex.expected +48 -0
- data/test/command/suite/search/complex.test +23 -0
- data/test/command/suite/search/condition/nested.expected +15 -0
- data/test/command/suite/search/condition/nested.test +27 -0
- data/test/command/suite/search/condition/query/nonexistent_column.catalog.json +37 -0
- data/test/command/suite/search/condition/query/nonexistent_column.expected +48 -0
- data/test/command/suite/search/condition/query/nonexistent_column.test +33 -0
- data/test/command/suite/search/condition/query/syntax_error.catalog.json +36 -0
- data/test/command/suite/search/condition/query/syntax_error.expected +48 -0
- data/test/command/suite/search/condition/query/syntax_error.test +33 -0
- data/test/command/suite/search/condition/query.expected +24 -0
- data/test/command/suite/search/condition/query.test +23 -0
- data/test/command/suite/search/condition/script.expected +24 -0
- data/test/command/suite/search/condition/script.test +26 -0
- data/test/command/suite/search/error/cyclic-source.expected +14 -0
- data/test/command/suite/search/error/cyclic-source.test +12 -0
- data/test/command/suite/search/error/deeply-cyclic-source.expected +17 -0
- data/test/command/suite/search/error/deeply-cyclic-source.test +15 -0
- data/test/command/suite/search/error/missing-source-parameter.expected +13 -0
- data/test/command/suite/search/error/missing-source-parameter.test +11 -0
- data/test/command/suite/search/error/no-query.expected +9 -0
- data/test/command/suite/search/error/no-query.test +7 -0
- data/test/command/suite/search/error/unknown-source.expected +52 -0
- data/test/command/suite/search/error/unknown-source.test +12 -0
- data/test/command/suite/search/group/count.expected +10 -0
- data/test/command/suite/search/group/count.test +18 -0
- data/test/command/suite/search/group/limit.expected +15 -0
- data/test/command/suite/search/group/limit.test +20 -0
- data/test/command/suite/search/group/string.expected +32 -0
- data/test/command/suite/search/group/string.test +40 -0
- data/test/command/suite/search/group/subrecord/with-sort.catalog.json +33 -0
- data/test/command/suite/search/group/subrecord/with-sort.expected +30 -0
- data/test/command/suite/search/group/subrecord/with-sort.test +81 -0
- data/test/command/suite/search/multiple/chained.expected +41 -0
- data/test/command/suite/search/multiple/chained.test +39 -0
- data/test/command/suite/search/multiple/parallel.expected +35 -0
- data/test/command/suite/search/multiple/parallel.test +35 -0
- data/test/command/suite/search/output/attributes/invalid.catalog.json +13 -0
- data/test/command/suite/search/output/attributes/invalid.expected +44 -0
- data/test/command/suite/search/output/attributes/invalid.test +28 -0
- data/test/command/suite/search/range/only-output.expected +24 -0
- data/test/command/suite/search/range/only-output.test +23 -0
- data/test/command/suite/search/range/only-sort.expected +24 -0
- data/test/command/suite/search/range/only-sort.test +26 -0
- data/test/command/suite/search/range/sort-and-output.expected +21 -0
- data/test/command/suite/search/range/sort-and-output.test +27 -0
- data/test/command/suite/search/range/too-large-output-offset.expected +12 -0
- data/test/command/suite/search/range/too-large-output-offset.test +23 -0
- data/test/command/suite/search/range/too-large-sort-offset.expected +12 -0
- data/test/command/suite/search/range/too-large-sort-offset.test +26 -0
- data/test/command/suite/search/response/elapsed_time.catalog.json +13 -0
- data/test/command/suite/search/response/elapsed_time.expected +11 -0
- data/test/command/suite/search/response/elapsed_time.test +26 -0
- data/test/command/suite/search/response/records/value/time.expected +20 -0
- data/test/command/suite/search/response/records/value/time.test +22 -0
- data/test/command/suite/search/simple.expected +48 -0
- data/test/command/suite/search/simple.test +22 -0
- data/test/command/suite/search/sort/default-offset-limit.expected +39 -0
- data/test/command/suite/search/sort/default-offset-limit.test +24 -0
- data/test/command/suite/search/sort/invisible-column.expected +24 -0
- data/test/command/suite/search/sort/invisible-column.test +26 -0
- data/test/command/suite/watch/subscribe.expected +6 -0
- data/test/command/suite/watch/subscribe.test +9 -0
- data/test/command/suite/watch/unsubscribe.expected +6 -0
- data/test/command/suite/watch/unsubscribe.test +9 -0
- data/test/performance/run-test.rb +56 -0
- data/test/performance/watch/catalog.json +33 -0
- data/test/performance/watch/feed.json +9 -0
- data/test/performance/watch/fluentd.conf +11 -0
- data/test/performance/watch/subscribe.json +3 -0
- data/test/unit/catalog/test_collection_volume.rb +103 -0
- data/test/unit/catalog/test_dataset.rb +104 -0
- data/test/unit/catalog/test_schema.rb +226 -0
- data/test/unit/catalog/test_single_volume.rb +31 -0
- data/test/unit/catalog/test_slice.rb +92 -0
- data/test/unit/catalog/test_version1.rb +361 -0
- data/test/unit/catalog/test_version2.rb +124 -0
- data/test/unit/catalog/test_version2_validator.rb +66 -0
- data/test/unit/catalog/test_volume_collection.rb +50 -0
- data/test/unit/fixtures/array.grn +18 -0
- data/test/unit/fixtures/catalog/version1.json +40 -0
- data/test/unit/fixtures/catalog/version2.json +62 -0
- data/test/unit/fixtures/document.grn +34 -0
- data/test/unit/fixtures/reference/array.grn +11 -0
- data/test/unit/fixtures/reference/hash.grn +7 -0
- data/test/unit/helper/distributed_search_planner_helper.rb +83 -0
- data/test/unit/helper/fixture.rb +28 -0
- data/test/unit/helper/plugin_helper.rb +38 -0
- data/test/unit/helper/sandbox.rb +86 -0
- data/test/unit/helper/stub_worker.rb +27 -0
- data/test/unit/helper/watch_helper.rb +23 -0
- data/test/unit/helper.rb +28 -0
- data/test/unit/plugins/crud/test_add.rb +190 -0
- data/test/unit/plugins/groonga/select/test_adapter_input.rb +510 -0
- data/test/unit/plugins/groonga/select/test_adapter_output.rb +201 -0
- data/test/unit/plugins/groonga/test_column_create.rb +171 -0
- data/test/unit/plugins/groonga/test_column_list.rb +170 -0
- data/test/unit/plugins/groonga/test_column_remove.rb +98 -0
- data/test/unit/plugins/groonga/test_column_rename.rb +105 -0
- data/test/unit/plugins/groonga/test_delete.rb +127 -0
- data/test/unit/plugins/groonga/test_table_create.rb +147 -0
- data/test/unit/plugins/groonga/test_table_list.rb +184 -0
- data/test/unit/plugins/groonga/test_table_remove.rb +61 -0
- data/test/unit/plugins/search/planner/test_basic.rb +120 -0
- data/test/unit/plugins/search/planner/test_group_by.rb +573 -0
- data/test/unit/plugins/search/planner/test_output.rb +388 -0
- data/test/unit/plugins/search/planner/test_sort_by.rb +938 -0
- data/test/unit/plugins/search/test_collector.rb +806 -0
- data/test/unit/plugins/search/test_handler.rb +930 -0
- data/test/unit/plugins/search/test_planner.rb +174 -0
- data/test/unit/plugins/test_basic.rb +510 -0
- data/test/unit/plugins/test_groonga.rb +70 -0
- data/test/unit/plugins/test_watch.rb +211 -0
- data/test/unit/run-test.rb +56 -0
- data/test/unit/test_catalog_generator.rb +93 -0
- data/test/unit/test_message_matcher.rb +160 -0
- data/test/unit/test_schema_applier.rb +59 -0
- data/test/unit/test_sweeper.rb +95 -0
- data/test/unit/test_watch_schema.rb +57 -0
- data/test/unit/test_watcher.rb +336 -0
- metadata +759 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "droonga/plugins/groonga"
|
|
17
|
+
|
|
18
|
+
class GroongaHandlerTest < Test::Unit::TestCase
|
|
19
|
+
include PluginHelper
|
|
20
|
+
|
|
21
|
+
def setup
|
|
22
|
+
setup_database
|
|
23
|
+
setup_plugin
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def teardown
|
|
27
|
+
teardown_plugin
|
|
28
|
+
teardown_database
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
def setup_plugin
|
|
33
|
+
@handler = Droonga::Test::StubHandler.new
|
|
34
|
+
@messenger = Droonga::Test::StubHandlerMessenger.new
|
|
35
|
+
@loop = nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def teardown_plugin
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def dump
|
|
42
|
+
database_dumper = Groonga::DatabaseDumper.new(:database => @database)
|
|
43
|
+
database_dumper.dump
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def process(command, request)
|
|
47
|
+
message = Droonga::Test::StubHandlerMessage.new(request)
|
|
48
|
+
handler = create_handler
|
|
49
|
+
handler.handle(message)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
NORMALIZED_START_TIME = Time.parse("2013-07-11T16:04:28+0900").to_i
|
|
53
|
+
NORMALIZED_ELAPSED_TIME = 1
|
|
54
|
+
def normalize_header(header)
|
|
55
|
+
start_time = NORMALIZED_START_TIME
|
|
56
|
+
elapsed_time = NORMALIZED_ELAPSED_TIME
|
|
57
|
+
[header[0], start_time, elapsed_time]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
NORMALIZED_HEADER_SUCCESS = [
|
|
61
|
+
Droonga::Plugins::Groonga::Status::SUCCESS,
|
|
62
|
+
NORMALIZED_START_TIME,
|
|
63
|
+
NORMALIZED_ELAPSED_TIME,
|
|
64
|
+
]
|
|
65
|
+
NORMALIZED_HEADER_INVALID_ARGUMENT = [
|
|
66
|
+
Droonga::Plugins::Groonga::Status::INVALID_ARGUMENT,
|
|
67
|
+
NORMALIZED_START_TIME,
|
|
68
|
+
NORMALIZED_ELAPSED_TIME,
|
|
69
|
+
]
|
|
70
|
+
end
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2013-2014 Droonga Project
|
|
4
|
+
#
|
|
5
|
+
# This library is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
8
|
+
#
|
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+
# Lesser General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
15
|
+
# License along with this library; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
+
|
|
18
|
+
require "droonga/plugins/watch"
|
|
19
|
+
|
|
20
|
+
class WatchHandlerTest < Test::Unit::TestCase
|
|
21
|
+
include WatchHelper
|
|
22
|
+
|
|
23
|
+
SUCCESS_RESULT = true
|
|
24
|
+
|
|
25
|
+
def setup
|
|
26
|
+
setup_database
|
|
27
|
+
setup_schema
|
|
28
|
+
setup_plugin
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def teardown
|
|
32
|
+
teardown_plugin
|
|
33
|
+
teardown_database
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
def setup_plugin
|
|
38
|
+
@handler = Droonga::Test::StubHandler.new
|
|
39
|
+
@messenger = Droonga::Test::StubHandlerMessenger.new
|
|
40
|
+
@loop = nil
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def teardown_plugin
|
|
44
|
+
@plugin = nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def process(command, request, headers={})
|
|
48
|
+
message = Droonga::Test::StubHandlerMessage.new(request, headers)
|
|
49
|
+
create_plugin.handle(message)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
public
|
|
53
|
+
class SubscribeTest < self
|
|
54
|
+
def create_plugin
|
|
55
|
+
Droonga::Plugins::Watch::SubscribeHandler.new("droonga",
|
|
56
|
+
@handler.context,
|
|
57
|
+
@messenger,
|
|
58
|
+
@loop)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_subscribe
|
|
62
|
+
request = {
|
|
63
|
+
"route" => "localhost:23003/output",
|
|
64
|
+
"condition" => "たいやき",
|
|
65
|
+
"subscriber" => "localhost"
|
|
66
|
+
}
|
|
67
|
+
response = process(:subscribe, request)
|
|
68
|
+
assert_equal(SUCCESS_RESULT, response)
|
|
69
|
+
|
|
70
|
+
assert_equal(
|
|
71
|
+
["localhost:23003/output"],
|
|
72
|
+
actual_routes_for_query("たいやき")
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_subscribe_route_omitted_from_specified
|
|
77
|
+
request = {
|
|
78
|
+
"condition" => "たいやき",
|
|
79
|
+
"subscriber" => "localhost"
|
|
80
|
+
}
|
|
81
|
+
response = process(:subscribe, request, "from" => "localhost:23004/output")
|
|
82
|
+
assert_equal(SUCCESS_RESULT, response)
|
|
83
|
+
|
|
84
|
+
assert_equal(
|
|
85
|
+
["localhost:23004/output"],
|
|
86
|
+
actual_routes_for_query("たいやき")
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_subscribe_both_route_and_from_specified
|
|
91
|
+
request = {
|
|
92
|
+
"condition" => "たいやき",
|
|
93
|
+
"subscriber" => "localhost",
|
|
94
|
+
"route" => "localhost:23003/output"
|
|
95
|
+
}
|
|
96
|
+
response = process(:subscribe, request, "from" => "localhost:23004/output")
|
|
97
|
+
assert_equal(SUCCESS_RESULT, response)
|
|
98
|
+
|
|
99
|
+
assert_equal(
|
|
100
|
+
["localhost:23003/output"],
|
|
101
|
+
actual_routes_for_query("たいやき")
|
|
102
|
+
)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
private
|
|
106
|
+
def actual_routes_for_query(query)
|
|
107
|
+
@handler.context["Subscriber"].select {|record|
|
|
108
|
+
record[:subscriptions] =~ query.to_json
|
|
109
|
+
}.map {|subscriber|
|
|
110
|
+
subscriber.route.key
|
|
111
|
+
}
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
class UnsubscribeTest < self
|
|
116
|
+
def setup
|
|
117
|
+
super
|
|
118
|
+
setup_subscription
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def create_plugin
|
|
122
|
+
Droonga::Plugins::Watch::UnsubscribeHandler.new("droonga",
|
|
123
|
+
@handler.context,
|
|
124
|
+
@messenger,
|
|
125
|
+
@loop)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_unsubscribe
|
|
129
|
+
request = {
|
|
130
|
+
"route" => "localhost:23003/output",
|
|
131
|
+
"condition" => "たいやき",
|
|
132
|
+
"subscriber" => "localhost"
|
|
133
|
+
}
|
|
134
|
+
response = process(:unsubscribe, request)
|
|
135
|
+
assert_equal(SUCCESS_RESULT, response)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
private
|
|
139
|
+
def setup_subscription
|
|
140
|
+
request = {
|
|
141
|
+
"route" => "localhost:23003/output",
|
|
142
|
+
"condition" => "たいやき",
|
|
143
|
+
"subscriber" => "localhost"
|
|
144
|
+
}
|
|
145
|
+
response = process(:subscribe, request)
|
|
146
|
+
assert_equal(SUCCESS_RESULT, response)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
class FeedTest < self
|
|
151
|
+
def setup
|
|
152
|
+
super
|
|
153
|
+
setup_subscription
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def create_plugin
|
|
157
|
+
Droonga::Plugins::Watch::FeedHandler.new("droonga",
|
|
158
|
+
@handler.context,
|
|
159
|
+
@messenger,
|
|
160
|
+
@loop)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_feed_match
|
|
164
|
+
request = {
|
|
165
|
+
"targets" => {
|
|
166
|
+
"text" => "たいやきおいしいです"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
process(:feed, request)
|
|
170
|
+
assert_equal([
|
|
171
|
+
[
|
|
172
|
+
{
|
|
173
|
+
"body" => request,
|
|
174
|
+
"to" => ["localhost"],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"to" => "localhost:23003/output",
|
|
178
|
+
"type" => "watch.publish",
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
],
|
|
182
|
+
@messenger.messages)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_feed_not_match
|
|
186
|
+
request = {
|
|
187
|
+
"targets" => {
|
|
188
|
+
"text" => "たこやきおいしいです"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
assert_nil(process(:feed, request))
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
private
|
|
195
|
+
def setup_subscription
|
|
196
|
+
request = {
|
|
197
|
+
"route" => "localhost:23003/output",
|
|
198
|
+
"condition" => "たいやき",
|
|
199
|
+
"subscriber" => "localhost"
|
|
200
|
+
}
|
|
201
|
+
message = Droonga::Test::StubHandlerMessage.new(request, {})
|
|
202
|
+
subscribe_handler =
|
|
203
|
+
Droonga::Plugins::Watch::SubscribeHandler.new("droonga",
|
|
204
|
+
@handler.context,
|
|
205
|
+
@messenger,
|
|
206
|
+
@loop)
|
|
207
|
+
response = subscribe_handler.handle(message)
|
|
208
|
+
assert_equal(SUCCESS_RESULT, response)
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2013 Droonga Project
|
|
5
|
+
#
|
|
6
|
+
# This library is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
8
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
9
|
+
#
|
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
# Lesser General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
# License along with this library; if not, write to the Free Software
|
|
17
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
+
|
|
19
|
+
require "pathname"
|
|
20
|
+
|
|
21
|
+
require "rubygems"
|
|
22
|
+
require "bundler"
|
|
23
|
+
begin
|
|
24
|
+
Bundler.setup(:default, :development)
|
|
25
|
+
rescue Bundler::BundlerError => e
|
|
26
|
+
$stderr.puts e.message
|
|
27
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
28
|
+
exit e.status_code
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
require "test-unit"
|
|
32
|
+
require "test/unit/notify"
|
|
33
|
+
require "test/unit/rr"
|
|
34
|
+
|
|
35
|
+
require "cool.io"
|
|
36
|
+
|
|
37
|
+
$VERBOSE = true
|
|
38
|
+
|
|
39
|
+
base_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
|
40
|
+
lib_dir = File.join(base_dir, "lib")
|
|
41
|
+
test_dir = File.join(base_dir, "test", "unit")
|
|
42
|
+
|
|
43
|
+
$LOAD_PATH.unshift(lib_dir)
|
|
44
|
+
|
|
45
|
+
require "droonga/engine"
|
|
46
|
+
require "droonga/plugin_loader"
|
|
47
|
+
|
|
48
|
+
Droonga::PluginLoader.load_all
|
|
49
|
+
|
|
50
|
+
$LOAD_PATH.unshift(test_dir)
|
|
51
|
+
|
|
52
|
+
require "helper"
|
|
53
|
+
|
|
54
|
+
ARGV.unshift("--max-diff-target-string-size=10000")
|
|
55
|
+
|
|
56
|
+
exit Test::Unit::AutoRunner.run(true, test_dir)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "droonga/catalog_generator"
|
|
17
|
+
|
|
18
|
+
class CatalogGeneratorTest < Test::Unit::TestCase
|
|
19
|
+
def setup
|
|
20
|
+
@generator = Droonga::CatalogGenerator.new
|
|
21
|
+
@normalized_time_value = "2014-02-09T00:00:00Z"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def generate
|
|
25
|
+
normalize_catalog(@generator.generate)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def normalize_catalog(catalog)
|
|
29
|
+
normalize_time(catalog, "effectiveDate")
|
|
30
|
+
catalog
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def normalize_time(catalog, key)
|
|
34
|
+
begin
|
|
35
|
+
Time.iso8601(catalog[key])
|
|
36
|
+
rescue ArgumentError
|
|
37
|
+
# Do nothing for invalid time value
|
|
38
|
+
else
|
|
39
|
+
catalog[key] = @normalized_time_value
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_default
|
|
44
|
+
catalog = {
|
|
45
|
+
"version" => 2,
|
|
46
|
+
"effectiveDate" => @normalized_time_value,
|
|
47
|
+
"datasets" => {
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
assert_equal(catalog, generate)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class DatasetTest < self
|
|
54
|
+
def test_default
|
|
55
|
+
@generator.add_dataset("Droonga", {})
|
|
56
|
+
dataset = {
|
|
57
|
+
"nWorkers" => 4,
|
|
58
|
+
"plugins" => ["groonga", "search", "crud"],
|
|
59
|
+
"schema" => {},
|
|
60
|
+
"replicas" => [
|
|
61
|
+
{
|
|
62
|
+
"dimension" => "_key",
|
|
63
|
+
"slicer" => "hash",
|
|
64
|
+
"slices" => [
|
|
65
|
+
{
|
|
66
|
+
"volume" => {
|
|
67
|
+
"address" => "127.0.0.1:10031/droonga.000",
|
|
68
|
+
},
|
|
69
|
+
"weight" => 100,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
}
|
|
75
|
+
assert_equal(dataset, generate["datasets"]["Droonga"])
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_n_workers
|
|
79
|
+
@generator.add_dataset("Droonga", :n_workers => 3)
|
|
80
|
+
assert_equal(3, generate["datasets"]["Droonga"]["nWorkers"])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_plugins
|
|
84
|
+
@generator.add_dataset("Droonga", :plugins => ["search"])
|
|
85
|
+
assert_equal(["search"], generate["datasets"]["Droonga"]["plugins"])
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_fact
|
|
89
|
+
@generator.add_dataset("Droonga", :fact => "Entries")
|
|
90
|
+
assert_equal("Entries", generate["datasets"]["Droonga"]["fact"])
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "droonga/message_matcher"
|
|
17
|
+
|
|
18
|
+
class MessageMatcherTest < Test::Unit::TestCase
|
|
19
|
+
def matcher(pattern)
|
|
20
|
+
Droonga::MessageMatcher.new(pattern)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class ExtractTargetTest < self
|
|
24
|
+
def extract_target(path, message)
|
|
25
|
+
matcher([path]).send(:extract_target, message)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_nonexistent
|
|
29
|
+
assert_equal(Droonga::MessageMatcher::NONEXISTENT_PATH,
|
|
30
|
+
extract_target("nonexistent.path", {}))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_top_level
|
|
34
|
+
assert_equal("select",
|
|
35
|
+
extract_target("type",
|
|
36
|
+
{
|
|
37
|
+
"type" => "select"
|
|
38
|
+
}))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_nested
|
|
42
|
+
assert_equal(10,
|
|
43
|
+
extract_target("body.output.limit",
|
|
44
|
+
{
|
|
45
|
+
"body" => {
|
|
46
|
+
"output" => {
|
|
47
|
+
"limit" => 10,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}))
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class MatchTest < self
|
|
55
|
+
def match?(pattern, message)
|
|
56
|
+
matcher(pattern).match?(message)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class EqualTest < self
|
|
60
|
+
def test_same_value
|
|
61
|
+
assert_true(match?(["type", :equal, "select"],
|
|
62
|
+
{
|
|
63
|
+
"type" => "select"
|
|
64
|
+
}))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_different_value
|
|
68
|
+
assert_false(match?(["type", :equal, "select"],
|
|
69
|
+
{
|
|
70
|
+
"type" => "search",
|
|
71
|
+
}))
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class InTest < self
|
|
76
|
+
def test_exist
|
|
77
|
+
assert_true(match?(["type", :in, ["table_create", "table_remove"]],
|
|
78
|
+
{
|
|
79
|
+
"type" => "table_remove"
|
|
80
|
+
}))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_not_exist
|
|
84
|
+
assert_false(match?(["type", :in, ["table_create", "table_remove"]],
|
|
85
|
+
{
|
|
86
|
+
"type" => "column_create",
|
|
87
|
+
}))
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class IncludeTest < self
|
|
92
|
+
def test_exist
|
|
93
|
+
assert_true(match?(["originalTypes", :include, "select"],
|
|
94
|
+
{
|
|
95
|
+
"originalTypes" => ["search", "select"],
|
|
96
|
+
}))
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_not_exist
|
|
100
|
+
assert_false(match?(["originalTypes", :include, "select"],
|
|
101
|
+
{
|
|
102
|
+
"originalTypes" => ["load"],
|
|
103
|
+
}))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_no_key
|
|
107
|
+
assert_false(match?(["originalTypes", :include, "select"],
|
|
108
|
+
{}))
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_not_enumerable
|
|
112
|
+
assert_false(match?(["originalTypes", :include, "select"],
|
|
113
|
+
{
|
|
114
|
+
"originalTypes" => 29,
|
|
115
|
+
}))
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
class ExistTest < self
|
|
120
|
+
def test_exist
|
|
121
|
+
assert_true(match?(["body.result", :exist],
|
|
122
|
+
{
|
|
123
|
+
"body" => {
|
|
124
|
+
"result" => nil,
|
|
125
|
+
},
|
|
126
|
+
}))
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_not_exist
|
|
130
|
+
assert_false(match?(["body.result", :exist],
|
|
131
|
+
{
|
|
132
|
+
"body" => nil,
|
|
133
|
+
}))
|
|
134
|
+
end
|
|
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
|
|
159
|
+
end
|
|
160
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
require "droonga/schema_applier"
|
|
17
|
+
|
|
18
|
+
class SchemaCreatorTest < Test::Unit::TestCase
|
|
19
|
+
include Sandbox
|
|
20
|
+
|
|
21
|
+
def setup
|
|
22
|
+
setup_database
|
|
23
|
+
@context = Groonga::Context.default
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def teardown
|
|
27
|
+
teardown_database
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def apply(schema_data)
|
|
31
|
+
schema = Droonga::Catalog::Schema.new("dataset", schema_data)
|
|
32
|
+
applier = Droonga::SchemaApplier.new(@context, schema)
|
|
33
|
+
applier.apply
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def dump
|
|
37
|
+
dumper = Groonga::SchemaDumper.new(:context => @context, :syntax => :command)
|
|
38
|
+
dumper.dump
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_reference_table
|
|
42
|
+
schema_data = {
|
|
43
|
+
"Users" => {
|
|
44
|
+
"type" => "Hash",
|
|
45
|
+
"keyType" => "Names",
|
|
46
|
+
},
|
|
47
|
+
"Names" => {
|
|
48
|
+
"type" => "Hash",
|
|
49
|
+
"keyType" => "ShortText",
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
apply(schema_data)
|
|
53
|
+
assert_equal(<<-DUMP, dump)
|
|
54
|
+
table_create Names TABLE_HASH_KEY --key_type ShortText
|
|
55
|
+
|
|
56
|
+
table_create Users TABLE_HASH_KEY --key_type Names
|
|
57
|
+
DUMP
|
|
58
|
+
end
|
|
59
|
+
end
|