fluentd 0.12.40 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/ISSUE_TEMPLATE.md +17 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- data/.gitignore +5 -0
- data/.gitlab/cicd-template.yaml +10 -0
- data/.gitlab-ci.yml +147 -0
- data/.travis.yml +56 -20
- data/ADOPTERS.md +5 -0
- data/CHANGELOG.md +1369 -0
- data/CONTRIBUTING.md +16 -5
- data/GOVERNANCE.md +55 -0
- data/Gemfile +5 -0
- data/GithubWorkflow.md +78 -0
- data/LICENSE +202 -0
- data/MAINTAINERS.md +7 -0
- data/README.md +23 -11
- data/Rakefile +48 -2
- data/Vagrantfile +17 -0
- data/appveyor.yml +37 -0
- data/bin/fluent-binlog-reader +7 -0
- data/bin/fluent-ca-generate +6 -0
- data/bin/fluent-plugin-config-format +5 -0
- data/bin/fluent-plugin-generate +5 -0
- data/bin/fluentd +3 -0
- data/code-of-conduct.md +3 -0
- data/example/copy_roundrobin.conf +39 -0
- data/example/counter.conf +18 -0
- data/example/in_dummy_blocks.conf +17 -0
- data/example/in_dummy_with_compression.conf +23 -0
- data/example/in_forward.conf +7 -0
- data/example/in_forward_client.conf +37 -0
- data/example/in_forward_shared_key.conf +15 -0
- data/example/in_forward_tls.conf +14 -0
- data/example/in_forward_users.conf +24 -0
- data/example/in_forward_workers.conf +21 -0
- data/example/in_http.conf +3 -1
- data/example/in_out_forward.conf +17 -0
- data/example/logevents.conf +25 -0
- data/example/multi_filters.conf +61 -0
- data/example/out_exec_filter.conf +42 -0
- data/example/out_forward.conf +13 -13
- data/example/out_forward_buf_file.conf +23 -0
- data/example/out_forward_client.conf +109 -0
- data/example/out_forward_heartbeat_none.conf +16 -0
- data/example/out_forward_shared_key.conf +36 -0
- data/example/out_forward_tls.conf +18 -0
- data/example/out_forward_users.conf +65 -0
- data/example/out_null.conf +36 -0
- data/example/secondary_file.conf +42 -0
- data/example/suppress_config_dump.conf +7 -0
- data/example/worker_section.conf +36 -0
- data/fluent.conf +29 -0
- data/fluentd.gemspec +21 -11
- data/lib/fluent/agent.rb +67 -90
- data/lib/fluent/clock.rb +62 -0
- data/lib/fluent/command/binlog_reader.rb +244 -0
- data/lib/fluent/command/ca_generate.rb +181 -0
- data/lib/fluent/command/cat.rb +42 -18
- data/lib/fluent/command/debug.rb +12 -10
- data/lib/fluent/command/fluentd.rb +153 -5
- data/lib/fluent/command/plugin_config_formatter.rb +292 -0
- data/lib/fluent/command/plugin_generator.rb +324 -0
- data/lib/fluent/compat/call_super_mixin.rb +67 -0
- data/lib/fluent/compat/detach_process_mixin.rb +33 -0
- data/lib/fluent/compat/exec_util.rb +129 -0
- data/lib/fluent/compat/file_util.rb +54 -0
- data/lib/fluent/compat/filter.rb +68 -0
- data/lib/fluent/compat/formatter.rb +111 -0
- data/lib/fluent/compat/formatter_utils.rb +85 -0
- data/lib/fluent/compat/handle_tag_and_time_mixin.rb +62 -0
- data/lib/fluent/compat/handle_tag_name_mixin.rb +53 -0
- data/lib/fluent/compat/input.rb +49 -0
- data/lib/fluent/compat/output.rb +718 -0
- data/lib/fluent/compat/output_chain.rb +60 -0
- data/lib/fluent/compat/parser.rb +310 -0
- data/lib/fluent/compat/parser_utils.rb +40 -0
- data/lib/fluent/compat/propagate_default.rb +62 -0
- data/lib/fluent/compat/record_filter_mixin.rb +34 -0
- data/lib/fluent/compat/set_tag_key_mixin.rb +50 -0
- data/lib/fluent/compat/set_time_key_mixin.rb +69 -0
- data/lib/fluent/compat/socket_util.rb +165 -0
- data/lib/fluent/compat/string_util.rb +34 -0
- data/lib/fluent/compat/structured_format_mixin.rb +26 -0
- data/lib/fluent/compat/type_converter.rb +90 -0
- data/lib/fluent/config/configure_proxy.rb +210 -62
- data/lib/fluent/config/dsl.rb +12 -5
- data/lib/fluent/config/element.rb +107 -9
- data/lib/fluent/config/literal_parser.rb +9 -3
- data/lib/fluent/config/parser.rb +4 -4
- data/lib/fluent/config/section.rb +51 -14
- data/lib/fluent/config/types.rb +28 -13
- data/lib/fluent/config/v1_parser.rb +3 -5
- data/lib/fluent/config.rb +23 -20
- data/lib/fluent/configurable.rb +79 -21
- data/lib/fluent/counter/base_socket.rb +46 -0
- data/lib/fluent/counter/client.rb +297 -0
- data/lib/fluent/counter/error.rb +86 -0
- data/lib/fluent/counter/mutex_hash.rb +163 -0
- data/lib/fluent/counter/server.rb +273 -0
- data/lib/fluent/counter/store.rb +205 -0
- data/lib/fluent/counter/validator.rb +145 -0
- data/lib/fluent/counter.rb +23 -0
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/engine.rb +102 -65
- data/lib/fluent/env.rb +7 -3
- data/lib/fluent/error.rb +30 -0
- data/lib/fluent/event.rb +197 -21
- data/lib/fluent/event_router.rb +93 -10
- data/lib/fluent/filter.rb +2 -50
- data/lib/fluent/formatter.rb +4 -293
- data/lib/fluent/input.rb +2 -32
- data/lib/fluent/label.rb +10 -2
- data/lib/fluent/load.rb +3 -3
- data/lib/fluent/log.rb +348 -81
- data/lib/fluent/match.rb +37 -36
- data/lib/fluent/mixin.rb +12 -176
- data/lib/fluent/msgpack_factory.rb +62 -0
- data/lib/fluent/output.rb +10 -612
- data/lib/fluent/output_chain.rb +23 -0
- data/lib/fluent/parser.rb +4 -800
- data/lib/fluent/plugin/bare_output.rb +63 -0
- data/lib/fluent/plugin/base.rb +192 -0
- data/lib/fluent/plugin/buf_file.rb +128 -174
- data/lib/fluent/plugin/buf_memory.rb +9 -92
- data/lib/fluent/plugin/buffer/chunk.rb +221 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +383 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +90 -0
- data/lib/fluent/plugin/buffer.rb +779 -0
- data/lib/fluent/plugin/compressable.rb +92 -0
- data/lib/fluent/plugin/exec_util.rb +3 -108
- data/lib/fluent/plugin/file_util.rb +4 -34
- data/lib/fluent/plugin/file_wrapper.rb +120 -0
- data/lib/fluent/plugin/filter.rb +93 -0
- data/lib/fluent/plugin/filter_grep.rb +117 -34
- data/lib/fluent/plugin/filter_parser.rb +85 -62
- data/lib/fluent/plugin/filter_record_transformer.rb +27 -39
- data/lib/fluent/plugin/filter_stdout.rb +15 -12
- data/lib/fluent/plugin/formatter.rb +50 -0
- data/lib/fluent/plugin/formatter_csv.rb +52 -0
- data/lib/fluent/plugin/formatter_hash.rb +33 -0
- data/lib/fluent/plugin/formatter_json.rb +55 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +42 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +33 -0
- data/lib/fluent/plugin/formatter_out_file.rb +51 -0
- data/lib/fluent/plugin/formatter_single_value.rb +34 -0
- data/lib/fluent/plugin/formatter_stdout.rb +76 -0
- data/lib/fluent/plugin/formatter_tsv.rb +38 -0
- data/lib/fluent/plugin/in_debug_agent.rb +17 -6
- data/lib/fluent/plugin/in_dummy.rb +47 -20
- data/lib/fluent/plugin/in_exec.rb +55 -123
- data/lib/fluent/plugin/in_forward.rb +299 -216
- data/lib/fluent/plugin/in_gc_stat.rb +14 -36
- data/lib/fluent/plugin/in_http.rb +204 -91
- data/lib/fluent/plugin/in_monitor_agent.rb +186 -258
- data/lib/fluent/plugin/in_object_space.rb +13 -41
- data/lib/fluent/plugin/in_syslog.rb +112 -134
- data/lib/fluent/plugin/in_tail.rb +408 -745
- data/lib/fluent/plugin/in_tcp.rb +66 -9
- data/lib/fluent/plugin/in_udp.rb +60 -11
- data/lib/fluent/plugin/{in_stream.rb → in_unix.rb} +8 -4
- data/lib/fluent/plugin/input.rb +37 -0
- data/lib/fluent/plugin/multi_output.rb +158 -0
- data/lib/fluent/plugin/out_copy.rb +23 -35
- data/lib/fluent/plugin/out_exec.rb +67 -70
- data/lib/fluent/plugin/out_exec_filter.rb +204 -271
- data/lib/fluent/plugin/out_file.rb +267 -73
- data/lib/fluent/plugin/out_forward.rb +854 -325
- data/lib/fluent/plugin/out_null.rb +42 -9
- data/lib/fluent/plugin/out_relabel.rb +9 -5
- data/lib/fluent/plugin/out_roundrobin.rb +18 -37
- data/lib/fluent/plugin/out_secondary_file.rb +133 -0
- data/lib/fluent/plugin/out_stdout.rb +43 -10
- data/lib/fluent/plugin/out_stream.rb +7 -2
- data/lib/fluent/plugin/output.rb +1498 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +191 -0
- data/lib/fluent/plugin/parser_apache.rb +28 -0
- data/lib/fluent/plugin/parser_apache2.rb +88 -0
- data/lib/fluent/plugin/parser_apache_error.rb +26 -0
- data/lib/fluent/plugin/parser_csv.rb +39 -0
- data/lib/fluent/plugin/parser_json.rb +94 -0
- data/lib/fluent/plugin/parser_ltsv.rb +49 -0
- data/lib/fluent/plugin/parser_msgpack.rb +50 -0
- data/lib/fluent/plugin/parser_multiline.rb +106 -0
- data/lib/fluent/plugin/parser_nginx.rb +28 -0
- data/lib/fluent/plugin/parser_none.rb +36 -0
- data/lib/fluent/plugin/parser_regexp.rb +68 -0
- data/lib/fluent/plugin/parser_syslog.rb +142 -0
- data/lib/fluent/plugin/parser_tsv.rb +42 -0
- data/lib/fluent/plugin/socket_util.rb +3 -143
- data/lib/fluent/plugin/storage.rb +84 -0
- data/lib/fluent/plugin/storage_local.rb +164 -0
- data/lib/fluent/plugin/string_util.rb +3 -15
- data/lib/fluent/plugin.rb +122 -121
- data/lib/fluent/plugin_helper/cert_option.rb +178 -0
- data/lib/fluent/plugin_helper/child_process.rb +364 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +333 -0
- data/lib/fluent/plugin_helper/counter.rb +51 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +93 -0
- data/lib/fluent/plugin_helper/event_loop.rb +170 -0
- data/lib/fluent/plugin_helper/extract.rb +104 -0
- data/lib/fluent/plugin_helper/formatter.rb +147 -0
- data/lib/fluent/plugin_helper/http_server/app.rb +79 -0
- data/lib/fluent/plugin_helper/http_server/compat/server.rb +81 -0
- data/lib/fluent/plugin_helper/http_server/compat/webrick_handler.rb +58 -0
- data/lib/fluent/plugin_helper/http_server/methods.rb +35 -0
- data/lib/fluent/plugin_helper/http_server/request.rb +42 -0
- data/lib/fluent/plugin_helper/http_server/router.rb +54 -0
- data/lib/fluent/plugin_helper/http_server/server.rb +87 -0
- data/lib/fluent/plugin_helper/http_server.rb +76 -0
- data/lib/fluent/plugin_helper/inject.rb +151 -0
- data/lib/fluent/plugin_helper/parser.rb +147 -0
- data/lib/fluent/plugin_helper/record_accessor.rb +210 -0
- data/lib/fluent/plugin_helper/retry_state.rb +205 -0
- data/lib/fluent/plugin_helper/server.rb +807 -0
- data/lib/fluent/plugin_helper/socket.rb +250 -0
- data/lib/fluent/plugin_helper/socket_option.rb +80 -0
- data/lib/fluent/plugin_helper/storage.rb +349 -0
- data/lib/fluent/plugin_helper/thread.rb +179 -0
- data/lib/fluent/plugin_helper/timer.rb +92 -0
- data/lib/fluent/plugin_helper.rb +73 -0
- data/lib/fluent/plugin_id.rb +80 -0
- data/lib/fluent/process.rb +3 -489
- data/lib/fluent/registry.rb +52 -10
- data/lib/fluent/root_agent.rb +204 -42
- data/lib/fluent/supervisor.rb +597 -359
- data/lib/fluent/system_config.rb +131 -42
- data/lib/fluent/test/base.rb +6 -54
- data/lib/fluent/test/driver/base.rb +224 -0
- data/lib/fluent/test/driver/base_owned.rb +70 -0
- data/lib/fluent/test/driver/base_owner.rb +135 -0
- data/lib/fluent/test/driver/event_feeder.rb +98 -0
- data/lib/fluent/test/driver/filter.rb +57 -0
- data/lib/fluent/test/driver/formatter.rb +30 -0
- data/lib/fluent/test/driver/input.rb +31 -0
- data/lib/fluent/test/driver/multi_output.rb +53 -0
- data/lib/fluent/test/driver/output.rb +102 -0
- data/lib/fluent/test/driver/parser.rb +30 -0
- data/lib/fluent/test/driver/test_event_router.rb +45 -0
- data/lib/fluent/test/filter_test.rb +0 -1
- data/lib/fluent/test/formatter_test.rb +4 -1
- data/lib/fluent/test/helpers.rb +58 -10
- data/lib/fluent/test/input_test.rb +27 -19
- data/lib/fluent/test/log.rb +79 -0
- data/lib/fluent/test/output_test.rb +28 -39
- data/lib/fluent/test/parser_test.rb +3 -1
- data/lib/fluent/test/startup_shutdown.rb +46 -0
- data/lib/fluent/test.rb +33 -1
- data/lib/fluent/time.rb +450 -1
- data/lib/fluent/timezone.rb +27 -3
- data/lib/fluent/{status.rb → unique_id.rb} +15 -24
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +85 -0
- data/templates/new_gem/Gemfile +3 -0
- data/templates/new_gem/README.md.erb +43 -0
- data/templates/new_gem/Rakefile +13 -0
- data/templates/new_gem/fluent-plugin.gemspec.erb +27 -0
- data/templates/new_gem/lib/fluent/plugin/filter.rb.erb +14 -0
- data/templates/new_gem/lib/fluent/plugin/formatter.rb.erb +14 -0
- data/templates/new_gem/lib/fluent/plugin/input.rb.erb +11 -0
- data/templates/new_gem/lib/fluent/plugin/output.rb.erb +11 -0
- data/templates/new_gem/lib/fluent/plugin/parser.rb.erb +15 -0
- data/templates/new_gem/test/helper.rb.erb +8 -0
- data/templates/new_gem/test/plugin/test_filter.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_formatter.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_input.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_output.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_parser.rb.erb +18 -0
- data/templates/plugin_config_formatter/param.md-compact.erb +25 -0
- data/templates/plugin_config_formatter/param.md.erb +34 -0
- data/templates/plugin_config_formatter/section.md.erb +12 -0
- data/test/command/test_binlog_reader.rb +346 -0
- data/test/command/test_ca_generate.rb +70 -0
- data/test/command/test_fluentd.rb +901 -0
- data/test/command/test_plugin_config_formatter.rb +276 -0
- data/test/command/test_plugin_generator.rb +92 -0
- data/test/compat/test_calls_super.rb +166 -0
- data/test/compat/test_parser.rb +92 -0
- data/test/config/test_config_parser.rb +126 -2
- data/test/config/test_configurable.rb +946 -187
- data/test/config/test_configure_proxy.rb +424 -74
- data/test/config/test_dsl.rb +11 -11
- data/test/config/test_element.rb +500 -0
- data/test/config/test_literal_parser.rb +8 -0
- data/test/config/test_plugin_configuration.rb +56 -0
- data/test/config/test_section.rb +79 -7
- data/test/config/test_system_config.rb +122 -35
- data/test/config/test_types.rb +38 -0
- data/test/counter/test_client.rb +559 -0
- data/test/counter/test_error.rb +44 -0
- data/test/counter/test_mutex_hash.rb +179 -0
- data/test/counter/test_server.rb +589 -0
- data/test/counter/test_store.rb +258 -0
- data/test/counter/test_validator.rb +137 -0
- data/test/helper.rb +89 -6
- data/test/helpers/fuzzy_assert.rb +89 -0
- data/test/plugin/test_bare_output.rb +118 -0
- data/test/plugin/test_base.rb +115 -0
- data/test/plugin/test_buf_file.rb +823 -460
- data/test/plugin/test_buf_memory.rb +32 -194
- data/test/plugin/test_buffer.rb +1233 -0
- data/test/plugin/test_buffer_chunk.rb +198 -0
- data/test/plugin/test_buffer_file_chunk.rb +844 -0
- data/test/plugin/test_buffer_memory_chunk.rb +338 -0
- data/test/plugin/test_compressable.rb +84 -0
- data/test/plugin/test_filter.rb +357 -0
- data/test/plugin/test_filter_grep.rb +540 -29
- data/test/plugin/test_filter_parser.rb +439 -452
- data/test/plugin/test_filter_record_transformer.rb +123 -166
- data/test/plugin/test_filter_stdout.rb +160 -72
- data/test/plugin/test_formatter_csv.rb +111 -0
- data/test/plugin/test_formatter_hash.rb +35 -0
- data/test/plugin/test_formatter_json.rb +51 -0
- data/test/plugin/test_formatter_ltsv.rb +62 -0
- data/test/plugin/test_formatter_msgpack.rb +28 -0
- data/test/plugin/test_formatter_out_file.rb +95 -0
- data/test/plugin/test_formatter_single_value.rb +38 -0
- data/test/plugin/test_formatter_tsv.rb +68 -0
- data/test/plugin/test_in_debug_agent.rb +24 -1
- data/test/plugin/test_in_dummy.rb +111 -18
- data/test/plugin/test_in_exec.rb +200 -113
- data/test/plugin/test_in_forward.rb +990 -387
- data/test/plugin/test_in_gc_stat.rb +10 -8
- data/test/plugin/test_in_http.rb +600 -224
- data/test/plugin/test_in_monitor_agent.rb +690 -0
- data/test/plugin/test_in_object_space.rb +24 -8
- data/test/plugin/test_in_syslog.rb +154 -215
- data/test/plugin/test_in_tail.rb +1006 -707
- data/test/plugin/test_in_tcp.rb +125 -48
- data/test/plugin/test_in_udp.rb +204 -63
- data/test/plugin/{test_in_stream.rb → test_in_unix.rb} +14 -13
- data/test/plugin/test_input.rb +126 -0
- data/test/plugin/test_metadata.rb +89 -0
- data/test/plugin/test_multi_output.rb +180 -0
- data/test/plugin/test_out_copy.rb +117 -112
- data/test/plugin/test_out_exec.rb +258 -53
- data/test/plugin/test_out_exec_filter.rb +538 -115
- data/test/plugin/test_out_file.rb +865 -178
- data/test/plugin/test_out_forward.rb +998 -210
- data/test/plugin/test_out_null.rb +105 -0
- data/test/plugin/test_out_relabel.rb +28 -0
- data/test/plugin/test_out_roundrobin.rb +36 -29
- data/test/plugin/test_out_secondary_file.rb +458 -0
- data/test/plugin/test_out_stdout.rb +135 -37
- data/test/plugin/test_out_stream.rb +18 -0
- data/test/plugin/test_output.rb +984 -0
- data/test/plugin/test_output_as_buffered.rb +2021 -0
- data/test/plugin/test_output_as_buffered_backup.rb +312 -0
- data/test/plugin/test_output_as_buffered_compress.rb +165 -0
- data/test/plugin/test_output_as_buffered_overflow.rb +250 -0
- data/test/plugin/test_output_as_buffered_retries.rb +911 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +874 -0
- data/test/plugin/test_output_as_standard.rb +374 -0
- data/test/plugin/test_owned_by.rb +35 -0
- data/test/plugin/test_parser.rb +359 -0
- data/test/plugin/test_parser_apache.rb +42 -0
- data/test/plugin/test_parser_apache2.rb +47 -0
- data/test/plugin/test_parser_apache_error.rb +45 -0
- data/test/plugin/test_parser_csv.rb +103 -0
- data/test/plugin/test_parser_json.rb +138 -0
- data/test/plugin/test_parser_labeled_tsv.rb +145 -0
- data/test/plugin/test_parser_multiline.rb +100 -0
- data/test/plugin/test_parser_nginx.rb +88 -0
- data/test/plugin/test_parser_none.rb +52 -0
- data/test/plugin/test_parser_regexp.rb +289 -0
- data/test/plugin/test_parser_syslog.rb +441 -0
- data/test/plugin/test_parser_tsv.rb +122 -0
- data/test/plugin/test_storage.rb +167 -0
- data/test/plugin/test_storage_local.rb +335 -0
- data/test/plugin_helper/data/cert/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert-with-no-newline.pem +19 -0
- data/test/plugin_helper/data/cert/cert.pem +19 -0
- data/test/plugin_helper/http_server/test_app.rb +65 -0
- data/test/plugin_helper/http_server/test_route.rb +32 -0
- data/test/plugin_helper/test_cert_option.rb +16 -0
- data/test/plugin_helper/test_child_process.rb +794 -0
- data/test/plugin_helper/test_compat_parameters.rb +353 -0
- data/test/plugin_helper/test_event_emitter.rb +51 -0
- data/test/plugin_helper/test_event_loop.rb +52 -0
- data/test/plugin_helper/test_extract.rb +194 -0
- data/test/plugin_helper/test_formatter.rb +255 -0
- data/test/plugin_helper/test_http_server_helper.rb +205 -0
- data/test/plugin_helper/test_inject.rb +519 -0
- data/test/plugin_helper/test_parser.rb +264 -0
- data/test/plugin_helper/test_record_accessor.rb +197 -0
- data/test/plugin_helper/test_retry_state.rb +442 -0
- data/test/plugin_helper/test_server.rb +1714 -0
- data/test/plugin_helper/test_storage.rb +542 -0
- data/test/plugin_helper/test_thread.rb +164 -0
- data/test/plugin_helper/test_timer.rb +132 -0
- data/test/scripts/exec_script.rb +0 -6
- data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +7 -0
- data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +7 -0
- data/test/scripts/fluent/plugin/out_test.rb +23 -15
- data/test/scripts/fluent/plugin/out_test2.rb +80 -0
- data/test/test_clock.rb +164 -0
- data/test/test_config.rb +16 -7
- data/test/test_configdsl.rb +2 -2
- data/test/test_event.rb +360 -13
- data/test/test_event_router.rb +108 -11
- data/test/test_event_time.rb +199 -0
- data/test/test_filter.rb +48 -6
- data/test/test_formatter.rb +11 -391
- data/test/test_input.rb +1 -1
- data/test/test_log.rb +591 -31
- data/test/test_mixin.rb +1 -1
- data/test/test_output.rb +121 -185
- data/test/test_plugin.rb +251 -0
- data/test/test_plugin_classes.rb +177 -10
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_plugin_id.rb +101 -0
- data/test/test_process.rb +8 -42
- data/test/test_root_agent.rb +766 -21
- data/test/test_supervisor.rb +481 -0
- data/test/test_test_drivers.rb +135 -0
- data/test/test_time_formatter.rb +282 -0
- data/test/test_time_parser.rb +231 -0
- data/test/test_unique_id.rb +47 -0
- metadata +454 -60
- data/COPYING +0 -14
- data/ChangeLog +0 -666
- data/lib/fluent/buffer.rb +0 -365
- data/lib/fluent/plugin/in_status.rb +0 -76
- data/test/plugin/test_in_status.rb +0 -38
- data/test/test_buffer.rb +0 -624
- data/test/test_parser.rb +0 -1305
@@ -1,97 +1,107 @@
|
|
1
1
|
require_relative '../helper'
|
2
2
|
require 'timecop'
|
3
|
+
require 'fluent/test/driver/filter'
|
3
4
|
require 'fluent/plugin/filter_parser'
|
4
5
|
require 'flexmock/test_unit'
|
5
6
|
|
6
7
|
class ParserFilterTest < Test::Unit::TestCase
|
7
8
|
include FlexMock::TestCase
|
8
9
|
|
9
|
-
setup
|
10
|
+
def setup
|
10
11
|
Fluent::Test.setup
|
11
|
-
@
|
12
|
-
|
12
|
+
@tag = 'test'
|
13
|
+
@default_time = Time.parse('2010-05-04 03:02:01 UTC')
|
14
|
+
Timecop.freeze(@default_time)
|
13
15
|
end
|
14
16
|
|
15
|
-
teardown
|
17
|
+
def teardown
|
18
|
+
super
|
16
19
|
Timecop.return
|
17
20
|
end
|
18
21
|
|
22
|
+
def assert_equal_parsed_time(expected, actual)
|
23
|
+
if expected.is_a?(Integer)
|
24
|
+
assert_equal(expected, actual.to_i)
|
25
|
+
else
|
26
|
+
assert_equal_event_time(expected, actual)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
ParserError = Fluent::Plugin::Parser::ParserError
|
19
31
|
CONFIG = %[
|
20
|
-
key_name
|
21
|
-
|
22
|
-
|
23
|
-
|
32
|
+
key_name message
|
33
|
+
reserve_data true
|
34
|
+
<parse>
|
35
|
+
@type regexp
|
36
|
+
expression /^(?<x>.)(?<y>.) (?<time>.+)$/
|
37
|
+
time_format %Y%m%d%H%M%S
|
38
|
+
</parse>
|
24
39
|
]
|
25
40
|
|
26
|
-
def create_driver(conf=CONFIG
|
27
|
-
Fluent::Test::
|
41
|
+
def create_driver(conf=CONFIG)
|
42
|
+
Fluent::Test::Driver::Filter.new(Fluent::Plugin::ParserFilter).configure(conf)
|
28
43
|
end
|
29
44
|
|
30
45
|
def test_configure
|
31
46
|
assert_raise(Fluent::ConfigError) {
|
32
|
-
|
47
|
+
create_driver('')
|
33
48
|
}
|
34
49
|
assert_raise(Fluent::ConfigError) {
|
35
|
-
|
36
|
-
format unknown_format_that_will_never_be_implemented
|
37
|
-
key_name foo
|
38
|
-
]
|
39
|
-
}
|
40
|
-
assert_nothing_raised {
|
41
|
-
d = create_driver %[
|
42
|
-
format /(?<x>.)/
|
50
|
+
create_driver %[
|
43
51
|
key_name foo
|
52
|
+
<parse>
|
53
|
+
@type unknown_format_that_will_never_be_implemented
|
54
|
+
</parse>
|
44
55
|
]
|
45
56
|
}
|
46
57
|
assert_nothing_raised {
|
47
|
-
|
48
|
-
format /(?<x>.)/
|
58
|
+
create_driver %[
|
49
59
|
key_name foo
|
60
|
+
<parse>
|
61
|
+
@type regexp
|
62
|
+
expression /(?<x>.)/
|
63
|
+
</parse>
|
50
64
|
]
|
51
65
|
}
|
52
66
|
assert_nothing_raised {
|
53
|
-
|
54
|
-
format /(?<x>.)/
|
67
|
+
create_driver %[
|
55
68
|
key_name foo
|
69
|
+
<parse>
|
70
|
+
@type json
|
71
|
+
</parse>
|
56
72
|
]
|
57
73
|
}
|
58
74
|
assert_nothing_raised {
|
59
|
-
|
60
|
-
format /(?<x>.)/
|
75
|
+
create_driver %[
|
61
76
|
key_name foo
|
62
|
-
]
|
63
|
-
}
|
64
|
-
assert_nothing_raised {
|
65
|
-
d = create_driver %[
|
66
77
|
format json
|
67
|
-
key_name foo
|
68
78
|
]
|
69
79
|
}
|
70
80
|
assert_nothing_raised {
|
71
|
-
|
72
|
-
format ltsv
|
81
|
+
create_driver %[
|
73
82
|
key_name foo
|
83
|
+
<parse>
|
84
|
+
@type ltsv
|
85
|
+
</parse>
|
74
86
|
]
|
75
87
|
}
|
76
88
|
assert_nothing_raised {
|
77
|
-
|
78
|
-
format /^col1=(?<col1>.+) col2=(?<col2>.+)$/
|
79
|
-
key_name message
|
80
|
-
suppress_parse_error_log true
|
81
|
-
]
|
82
|
-
}
|
83
|
-
assert_nothing_raised {
|
84
|
-
d = create_driver %[
|
85
|
-
format /^col1=(?<col1>.+) col2=(?<col2>.+)$/
|
89
|
+
create_driver %[
|
86
90
|
key_name message
|
87
|
-
|
91
|
+
<parse>
|
92
|
+
@type regexp
|
93
|
+
expression /^col1=(?<col1>.+) col2=(?<col2>.+)$/
|
94
|
+
</parse>
|
88
95
|
]
|
89
96
|
}
|
90
97
|
d = create_driver %[
|
91
98
|
key_name foo
|
92
|
-
|
99
|
+
<parse>
|
100
|
+
@type regexp
|
101
|
+
expression /(?<x>.)/
|
102
|
+
</parse>
|
93
103
|
]
|
94
|
-
|
104
|
+
assert_false d.instance.reserve_data
|
95
105
|
end
|
96
106
|
|
97
107
|
# CONFIG = %[
|
@@ -103,404 +113,463 @@ class ParserFilterTest < Test::Unit::TestCase
|
|
103
113
|
# reserve_data true
|
104
114
|
# ]
|
105
115
|
def test_filter
|
106
|
-
d1 = create_driver(CONFIG
|
107
|
-
time =
|
108
|
-
d1.run do
|
109
|
-
d1.
|
110
|
-
d1.
|
111
|
-
d1.
|
112
|
-
d1.
|
113
|
-
d1.
|
116
|
+
d1 = create_driver(CONFIG)
|
117
|
+
time = event_time("2012-01-02 13:14:15")
|
118
|
+
d1.run(default_tag: @tag) do
|
119
|
+
d1.feed(time, {'message' => '12 20120402182059'})
|
120
|
+
d1.feed(time, {'message' => '34 20120402182100'})
|
121
|
+
d1.feed(time, {'message' => '56 20120402182100'})
|
122
|
+
d1.feed(time, {'message' => '78 20120402182101'})
|
123
|
+
d1.feed(time, {'message' => '90 20120402182100'})
|
114
124
|
end
|
115
|
-
filtered = d1.
|
125
|
+
filtered = d1.filtered
|
116
126
|
assert_equal 5, filtered.length
|
117
127
|
|
118
128
|
first = filtered[0]
|
119
|
-
|
120
|
-
assert_equal
|
121
|
-
assert_equal '
|
122
|
-
assert_equal '
|
123
|
-
assert_equal '12 20120402182059', first[2]['message']
|
129
|
+
assert_equal_event_time event_time("2012-04-02 18:20:59"), first[0]
|
130
|
+
assert_equal '1', first[1]['x']
|
131
|
+
assert_equal '2', first[1]['y']
|
132
|
+
assert_equal '12 20120402182059', first[1]['message']
|
124
133
|
|
125
134
|
second = filtered[1]
|
126
|
-
|
127
|
-
assert_equal
|
128
|
-
assert_equal '
|
129
|
-
assert_equal '4', second[2]['y']
|
135
|
+
assert_equal_event_time event_time("2012-04-02 18:21:00"), second[0]
|
136
|
+
assert_equal '3', second[1]['x']
|
137
|
+
assert_equal '4', second[1]['y']
|
130
138
|
|
131
139
|
third = filtered[2]
|
132
|
-
|
133
|
-
assert_equal
|
134
|
-
assert_equal '
|
135
|
-
assert_equal '6', third[2]['y']
|
140
|
+
assert_equal_event_time event_time("2012-04-02 18:21:00"), third[0]
|
141
|
+
assert_equal '5', third[1]['x']
|
142
|
+
assert_equal '6', third[1]['y']
|
136
143
|
|
137
144
|
fourth = filtered[3]
|
138
|
-
|
139
|
-
assert_equal
|
140
|
-
assert_equal '
|
141
|
-
assert_equal '8', fourth[2]['y']
|
145
|
+
assert_equal_event_time event_time("2012-04-02 18:21:01"), fourth[0]
|
146
|
+
assert_equal '7', fourth[1]['x']
|
147
|
+
assert_equal '8', fourth[1]['y']
|
142
148
|
|
143
149
|
fifth = filtered[4]
|
144
|
-
|
145
|
-
assert_equal
|
146
|
-
assert_equal '
|
147
|
-
assert_equal '0', fifth[2]['y']
|
150
|
+
assert_equal_event_time event_time("2012-04-02 18:21:00"), fifth[0]
|
151
|
+
assert_equal '9', fifth[1]['x']
|
152
|
+
assert_equal '0', fifth[1]['y']
|
148
153
|
|
149
154
|
d2 = create_driver(%[
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
d2.
|
157
|
-
d2.filter({'data' => '34 20120402182100'}, time)
|
155
|
+
key_name data
|
156
|
+
format /^(?<x>.)(?<y>.) (?<t>.+)$/
|
157
|
+
])
|
158
|
+
time = Fluent::EventTime.from_time(@default_time) # EventTime emit test
|
159
|
+
d2.run(default_tag: @tag) do
|
160
|
+
d2.feed(time, {'data' => '12 20120402182059'})
|
161
|
+
d2.feed(time, {'data' => '34 20120402182100'})
|
158
162
|
end
|
159
|
-
filtered = d2.
|
163
|
+
filtered = d2.filtered
|
160
164
|
assert_equal 2, filtered.length
|
161
165
|
|
162
166
|
first = filtered[0]
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
assert_equal '
|
167
|
-
assert_equal '
|
168
|
-
assert_equal '20120402182059', first[2]['t']
|
167
|
+
assert_equal_event_time time, first[0]
|
168
|
+
assert_nil first[1]['data']
|
169
|
+
assert_equal '1', first[1]['x']
|
170
|
+
assert_equal '2', first[1]['y']
|
171
|
+
assert_equal '20120402182059', first[1]['t']
|
169
172
|
|
170
173
|
second = filtered[1]
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
assert_equal '
|
175
|
-
assert_equal '
|
176
|
-
assert_equal '20120402182100', second[2]['t']
|
174
|
+
assert_equal_event_time time, second[0]
|
175
|
+
assert_nil second[1]['data']
|
176
|
+
assert_equal '3', second[1]['x']
|
177
|
+
assert_equal '4', second[1]['y']
|
178
|
+
assert_equal '20120402182100', second[1]['t']
|
177
179
|
|
178
180
|
d3 = create_driver(%[
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
d3.
|
181
|
+
key_name data
|
182
|
+
<parse>
|
183
|
+
@type regexp
|
184
|
+
expression /^(?<x>[0-9])(?<y>[0-9]) (?<t>.+)$/
|
185
|
+
</parse>
|
186
|
+
])
|
187
|
+
time = Time.parse("2012-04-02 18:20:59").to_i
|
188
|
+
d3.run(default_tag: @tag) do
|
189
|
+
d3.feed(time, {'data' => '12 20120402182059'})
|
190
|
+
d3.feed(time, {'data' => '34 20120402182100'})
|
191
|
+
d3.feed(time, {'data' => 'xy 20120402182101'})
|
188
192
|
end
|
189
|
-
filtered = d3.
|
193
|
+
filtered = d3.filtered
|
190
194
|
assert_equal 2, filtered.length
|
191
195
|
|
192
|
-
d3x = create_driver(%[
|
193
|
-
tag parsed
|
194
|
-
key_name data
|
195
|
-
format /^(?<x>\\d)(?<y>\\d) (?<t>.+)$/
|
196
|
-
reserve_data yes
|
197
|
-
], 'test.no.change')
|
198
|
-
time = @time.to_i
|
199
|
-
d3x.run do
|
200
|
-
d3x.filter({'data' => '12 20120402182059'}, time)
|
201
|
-
d3x.filter({'data' => '34 20120402182100'}, time)
|
202
|
-
d3x.filter({'data' => 'xy 20120402182101'}, time)
|
203
|
-
end
|
204
|
-
filtered = d3x.filtered_as_array
|
205
|
-
assert_equal 3, filtered.length
|
206
|
-
|
207
196
|
d4 = create_driver(%[
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
d4.
|
197
|
+
key_name data
|
198
|
+
<parse>
|
199
|
+
@type json
|
200
|
+
</parse>
|
201
|
+
])
|
202
|
+
time = Time.parse("2012-04-02 18:20:59").to_i
|
203
|
+
d4.run(default_tag: @tag) do
|
204
|
+
d4.feed(time, {'data' => '{"xxx":"first","yyy":"second"}', 'xxx' => 'x', 'yyy' => 'y'})
|
205
|
+
d4.feed(time, {'data' => 'foobar', 'xxx' => 'x', 'yyy' => 'y'})
|
216
206
|
end
|
217
|
-
filtered = d4.
|
207
|
+
filtered = d4.filtered
|
218
208
|
assert_equal 1, filtered.length
|
219
209
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
210
|
+
end
|
211
|
+
|
212
|
+
data(:keep_key_name => false,
|
213
|
+
:remove_key_name => true)
|
214
|
+
def test_filter_with_reserved_data(remove_key_name)
|
215
|
+
d1 = create_driver(%[
|
216
|
+
key_name data
|
217
|
+
reserve_data yes
|
218
|
+
remove_key_name_field #{remove_key_name}
|
219
|
+
<parse>
|
220
|
+
@type regexp
|
221
|
+
expression /^(?<x>\\d)(?<y>\\d) (?<t>.+)$/
|
222
|
+
</parse>
|
223
|
+
])
|
224
|
+
time = event_time("2012-04-02 18:20:59")
|
225
|
+
d1.run(default_tag: @tag) do
|
226
|
+
d1.feed(time, {'data' => '12 20120402182059'})
|
227
|
+
d1.feed(time, {'data' => '34 20120402182100'})
|
228
|
+
d1.feed(time, {'data' => 'xy 20120402182101'})
|
230
229
|
end
|
231
|
-
filtered =
|
230
|
+
filtered = d1.filtered
|
231
|
+
assert_equal 3, filtered.length
|
232
|
+
|
233
|
+
d2 = create_driver(%[
|
234
|
+
key_name data
|
235
|
+
reserve_data yes
|
236
|
+
remove_key_name_field #{remove_key_name}
|
237
|
+
<parse>
|
238
|
+
@type json
|
239
|
+
</parse>
|
240
|
+
])
|
241
|
+
time = Fluent::EventTime.from_time(@default_time)
|
242
|
+
d2.run(default_tag: @tag) do
|
243
|
+
d2.feed(time, {'data' => '{"xxx":"first","yyy":"second"}', 'xxx' => 'x', 'yyy' => 'y'})
|
244
|
+
d2.feed(time, {'data' => 'foobar', 'xxx' => 'x', 'yyy' => 'y'})
|
245
|
+
end
|
246
|
+
filtered = d2.filtered
|
232
247
|
assert_equal 2, filtered.length
|
233
248
|
|
234
249
|
first = filtered[0]
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
250
|
+
assert_equal_event_time time, first[0]
|
251
|
+
if remove_key_name
|
252
|
+
assert_not_include first[1], 'data'
|
253
|
+
else
|
254
|
+
assert_equal '{"xxx":"first","yyy":"second"}', first[1]['data']
|
255
|
+
end
|
256
|
+
assert_equal 'first', first[1]['xxx']
|
257
|
+
assert_equal 'second', first[1]['yyy']
|
240
258
|
|
241
259
|
second = filtered[1]
|
242
|
-
|
243
|
-
assert_equal
|
244
|
-
assert_equal '
|
245
|
-
assert_equal '
|
246
|
-
assert_equal 'y', second[2]['yyy']
|
260
|
+
assert_equal_event_time time, second[0]
|
261
|
+
assert_equal 'foobar', second[1]['data']
|
262
|
+
assert_equal 'x', second[1]['xxx']
|
263
|
+
assert_equal 'y', second[1]['yyy']
|
247
264
|
end
|
248
265
|
|
266
|
+
|
249
267
|
CONFIG_LTSV = %[
|
250
|
-
format ltsv
|
251
268
|
key_name data
|
269
|
+
<parse>
|
270
|
+
@type ltsv
|
271
|
+
</parse>
|
252
272
|
]
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
273
|
+
CONFIG_LTSV_WITH_TYPES = %[
|
274
|
+
key_name data
|
275
|
+
<parse>
|
276
|
+
@type ltsv
|
277
|
+
types i:integer,s:string,f:float,b:bool
|
278
|
+
</parse>
|
279
|
+
]
|
280
|
+
data(:event_time => lambda { |time| Fluent::EventTime.from_time(time) },
|
281
|
+
:int_time => lambda { |time| time.to_i })
|
282
|
+
def test_filter_ltsv(time_parse)
|
283
|
+
d = create_driver(CONFIG_LTSV)
|
284
|
+
time = time_parse.call(@default_time)
|
285
|
+
d.run(default_tag: @tag) do
|
286
|
+
d.feed(time, {'data' => "xxx:first\tyyy:second", 'xxx' => 'x', 'yyy' => 'y'})
|
287
|
+
d.feed(time, {'data' => "xxx:first\tyyy:second2", 'xxx' => 'x', 'yyy' => 'y'})
|
259
288
|
end
|
260
|
-
filtered = d.
|
289
|
+
filtered = d.filtered
|
261
290
|
assert_equal 2, filtered.length
|
262
291
|
|
263
292
|
first = filtered[0]
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
assert_equal '
|
268
|
-
assert_equal 'second', first[2]['yyy']
|
293
|
+
assert_equal_parsed_time time, first[0]
|
294
|
+
assert_nil first[1]['data']
|
295
|
+
assert_equal 'first', first[1]['xxx']
|
296
|
+
assert_equal 'second', first[1]['yyy']
|
269
297
|
|
270
298
|
second = filtered[1]
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
assert_equal '
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
d.run do
|
282
|
-
d.filter({'data' => "xxx:first\tyyy:second", 'xxx' => 'x', 'yyy' => 'y'}, time)
|
283
|
-
d.filter({'data' => "xxx:first\tyyy:second2", 'xxx' => 'x', 'yyy' => 'y'}, time)
|
299
|
+
assert_equal_parsed_time time, second[0]
|
300
|
+
assert_nil first[1]['data']
|
301
|
+
assert_equal 'first', second[1]['xxx']
|
302
|
+
assert_equal 'second2', second[1]['yyy']
|
303
|
+
|
304
|
+
d = create_driver(CONFIG_LTSV + %[reserve_data yes])
|
305
|
+
time = @default_time.to_i
|
306
|
+
d.run(default_tag: @tag) do
|
307
|
+
d.feed(time, {'data' => "xxx:first\tyyy:second", 'xxx' => 'x', 'yyy' => 'y'})
|
308
|
+
d.feed(time, {'data' => "xxx:first\tyyy:second2", 'xxx' => 'x', 'yyy' => 'y'})
|
284
309
|
end
|
285
|
-
filtered = d.
|
310
|
+
filtered = d.filtered
|
286
311
|
assert_equal 2, filtered.length
|
287
312
|
|
288
313
|
first = filtered[0]
|
289
|
-
|
290
|
-
assert_equal
|
291
|
-
assert_equal
|
292
|
-
assert_equal '
|
293
|
-
assert_equal 'second', first[2]['yyy']
|
314
|
+
assert_equal_parsed_time time, first[0]
|
315
|
+
assert_equal "xxx:first\tyyy:second", first[1]['data']
|
316
|
+
assert_equal 'first', first[1]['xxx']
|
317
|
+
assert_equal 'second', first[1]['yyy']
|
294
318
|
|
295
319
|
second = filtered[1]
|
296
|
-
|
297
|
-
assert_equal
|
298
|
-
assert_equal
|
299
|
-
assert_equal '
|
300
|
-
assert_equal 'second2', second[2]['yyy']
|
320
|
+
assert_equal_parsed_time time, second[0]
|
321
|
+
assert_equal "xxx:first\tyyy:second", first[1]['data']
|
322
|
+
assert_equal 'first', second[1]['xxx']
|
323
|
+
assert_equal 'second2', second[1]['yyy']
|
301
324
|
|
302
325
|
# convert types
|
303
|
-
d = create_driver(CONFIG_LTSV + %[
|
304
|
-
|
305
|
-
|
306
|
-
time = @time.to_i
|
326
|
+
#d = create_driver(CONFIG_LTSV + %[
|
327
|
+
d = create_driver(CONFIG_LTSV_WITH_TYPES)
|
328
|
+
time = @default_time.to_i
|
307
329
|
d.run do
|
308
|
-
d.
|
330
|
+
d.feed(@tag, time, {'data' => "i:1\ts:2\tf:3\tb:true\tx:123"})
|
309
331
|
end
|
310
|
-
filtered = d.
|
332
|
+
filtered = d.filtered
|
311
333
|
assert_equal 1, filtered.length
|
312
334
|
|
313
335
|
first = filtered[0]
|
314
|
-
|
315
|
-
assert_equal
|
316
|
-
assert_equal
|
317
|
-
assert_equal
|
318
|
-
assert_equal
|
319
|
-
assert_equal
|
320
|
-
assert_equal '123', first[2]['x']
|
336
|
+
assert_equal_parsed_time time, first[0]
|
337
|
+
assert_equal 1, first[1]['i']
|
338
|
+
assert_equal '2', first[1]['s']
|
339
|
+
assert_equal 3.0, first[1]['f']
|
340
|
+
assert_equal true, first[1]['b']
|
341
|
+
assert_equal '123', first[1]['x']
|
321
342
|
end
|
322
343
|
|
323
344
|
CONFIG_TSV = %[
|
324
|
-
format tsv
|
325
345
|
key_name data
|
326
|
-
|
346
|
+
<parse>
|
347
|
+
@type tsv
|
348
|
+
keys key1,key2,key3
|
349
|
+
</parse>
|
327
350
|
]
|
328
|
-
|
329
|
-
|
330
|
-
|
351
|
+
data(:event_time => lambda { |time| Fluent::EventTime.from_time(time) },
|
352
|
+
:int_time => lambda { |time| time.to_i })
|
353
|
+
def test_filter_tsv(time_parse)
|
354
|
+
d = create_driver(CONFIG_TSV)
|
355
|
+
time = time_parse.call(@default_time)
|
331
356
|
d.run do
|
332
|
-
d.
|
357
|
+
d.feed(@tag, time, {'data' => "value1\tvalue2\tvalueThree", 'xxx' => 'x', 'yyy' => 'y'})
|
333
358
|
end
|
334
|
-
filtered = d.
|
359
|
+
filtered = d.filtered
|
335
360
|
assert_equal 1, filtered.length
|
336
361
|
|
337
362
|
first = filtered[0]
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
assert_equal '
|
342
|
-
assert_equal '
|
343
|
-
assert_equal 'valueThree', first[2]['key3']
|
363
|
+
assert_equal_parsed_time time, first[0]
|
364
|
+
assert_nil first[1]['data']
|
365
|
+
assert_equal 'value1', first[1]['key1']
|
366
|
+
assert_equal 'value2', first[1]['key2']
|
367
|
+
assert_equal 'valueThree', first[1]['key3']
|
344
368
|
end
|
345
369
|
|
346
370
|
CONFIG_CSV = %[
|
347
|
-
format csv
|
348
371
|
key_name data
|
372
|
+
<parse>
|
373
|
+
@type csv
|
374
|
+
keys key1,key2,key3
|
375
|
+
</parse>
|
376
|
+
]
|
377
|
+
CONFIG_CSV_COMPAT = %[
|
378
|
+
key_name data
|
379
|
+
format csv
|
349
380
|
keys key1,key2,key3
|
350
381
|
]
|
351
|
-
|
352
|
-
|
353
|
-
|
382
|
+
data(new_conf: CONFIG_CSV,
|
383
|
+
compat_conf: CONFIG_CSV_COMPAT)
|
384
|
+
def test_filter_csv(conf)
|
385
|
+
d = create_driver(conf)
|
386
|
+
time = @default_time.to_i
|
354
387
|
d.run do
|
355
|
-
d.
|
388
|
+
d.feed(@tag, time, {'data' => 'value1,"value2","value""ThreeYes!"', 'xxx' => 'x', 'yyy' => 'y'})
|
356
389
|
end
|
357
|
-
filtered = d.
|
390
|
+
filtered = d.filtered
|
358
391
|
assert_equal 1, filtered.length
|
359
392
|
|
360
393
|
first = filtered[0]
|
361
|
-
assert_equal
|
362
|
-
|
363
|
-
|
364
|
-
assert_equal '
|
365
|
-
assert_equal '
|
366
|
-
|
394
|
+
assert_equal time, first[0]
|
395
|
+
assert_nil first[1]['data']
|
396
|
+
assert_equal 'value1', first[1]['key1']
|
397
|
+
assert_equal 'value2', first[1]['key2']
|
398
|
+
assert_equal 'value"ThreeYes!', first[1]['key3']
|
399
|
+
end
|
400
|
+
|
401
|
+
def test_filter_with_nested_record
|
402
|
+
d = create_driver(%[
|
403
|
+
key_name $.data.log
|
404
|
+
<parse>
|
405
|
+
@type csv
|
406
|
+
keys key1,key2,key3
|
407
|
+
</parse>
|
408
|
+
])
|
409
|
+
time = @default_time.to_i
|
410
|
+
d.run do
|
411
|
+
d.feed(@tag, time, {'data' => {'log' => 'value1,"value2","value""ThreeYes!"'}, 'xxx' => 'x', 'yyy' => 'y'})
|
412
|
+
end
|
413
|
+
filtered = d.filtered
|
414
|
+
assert_equal 1, filtered.length
|
415
|
+
|
416
|
+
first = filtered[0]
|
417
|
+
assert_equal time, first[0]
|
418
|
+
assert_nil first[1]['data']
|
419
|
+
assert_equal 'value1', first[1]['key1']
|
420
|
+
assert_equal 'value2', first[1]['key2']
|
421
|
+
assert_equal 'value"ThreeYes!', first[1]['key3']
|
367
422
|
end
|
368
423
|
|
369
424
|
CONFIG_HASH_VALUE_FIELD = %[
|
370
|
-
|
371
|
-
key_name data
|
425
|
+
key_name data
|
372
426
|
hash_value_field parsed
|
427
|
+
<parse>
|
428
|
+
@type json
|
429
|
+
</parse>
|
373
430
|
]
|
374
431
|
CONFIG_HASH_VALUE_FIELD_RESERVE_DATA = %[
|
375
|
-
|
376
|
-
key_name data
|
432
|
+
key_name data
|
377
433
|
reserve_data yes
|
378
434
|
hash_value_field parsed
|
435
|
+
<parse>
|
436
|
+
@type json
|
437
|
+
</parse>
|
379
438
|
]
|
380
439
|
CONFIG_HASH_VALUE_FIELD_WITH_INJECT_KEY_PREFIX = %[
|
381
|
-
|
382
|
-
key_name data
|
440
|
+
key_name data
|
383
441
|
hash_value_field parsed
|
384
442
|
inject_key_prefix data.
|
443
|
+
<parse>
|
444
|
+
@type json
|
445
|
+
</parse>
|
385
446
|
]
|
386
|
-
|
447
|
+
data(:event_time => lambda { |time| Fluent::EventTime.from_time(time) },
|
448
|
+
:int_time => lambda { |time| time.to_i })
|
449
|
+
def test_filter_inject_hash_value_field(time_parse)
|
387
450
|
original = {'data' => '{"xxx":"first","yyy":"second"}', 'xxx' => 'x', 'yyy' => 'y'}
|
388
451
|
|
389
|
-
d = create_driver(CONFIG_HASH_VALUE_FIELD
|
390
|
-
time = @
|
452
|
+
d = create_driver(CONFIG_HASH_VALUE_FIELD)
|
453
|
+
time = time_parse.call(@default_time)
|
391
454
|
d.run do
|
392
|
-
d.
|
455
|
+
d.feed(@tag, time, original)
|
393
456
|
end
|
394
|
-
filtered = d.
|
457
|
+
filtered = d.filtered
|
395
458
|
assert_equal 1, filtered.length
|
396
459
|
|
397
460
|
first = filtered[0]
|
398
|
-
|
399
|
-
assert_equal time, first[1]
|
461
|
+
assert_equal_parsed_time time, first[0]
|
400
462
|
|
401
|
-
record = first[
|
463
|
+
record = first[1]
|
402
464
|
assert_equal 1, record.keys.size
|
403
465
|
assert_equal({"xxx"=>"first","yyy"=>"second"}, record['parsed'])
|
404
466
|
|
405
|
-
d = create_driver(CONFIG_HASH_VALUE_FIELD_RESERVE_DATA
|
406
|
-
time = @
|
467
|
+
d = create_driver(CONFIG_HASH_VALUE_FIELD_RESERVE_DATA)
|
468
|
+
time = @default_time.to_i
|
407
469
|
d.run do
|
408
|
-
d.
|
470
|
+
d.feed(@tag, time, original)
|
409
471
|
end
|
410
|
-
filtered = d.
|
472
|
+
filtered = d.filtered
|
411
473
|
assert_equal 1, filtered.length
|
412
474
|
|
413
475
|
first = filtered[0]
|
414
|
-
|
415
|
-
assert_equal time, first[1]
|
476
|
+
assert_equal_parsed_time time, first[0]
|
416
477
|
|
417
|
-
record = first[
|
478
|
+
record = first[1]
|
418
479
|
assert_equal 4, record.keys.size
|
419
480
|
assert_equal original['data'], record['data']
|
420
481
|
assert_equal original['xxx'], record['xxx']
|
421
482
|
assert_equal original['yyy'], record['yyy']
|
422
483
|
assert_equal({"xxx"=>"first","yyy"=>"second"}, record['parsed'])
|
423
484
|
|
424
|
-
d = create_driver(CONFIG_HASH_VALUE_FIELD_WITH_INJECT_KEY_PREFIX
|
425
|
-
time = @
|
485
|
+
d = create_driver(CONFIG_HASH_VALUE_FIELD_WITH_INJECT_KEY_PREFIX)
|
486
|
+
time = @default_time.to_i
|
426
487
|
d.run do
|
427
|
-
d.
|
488
|
+
d.feed(@tag, time, original)
|
428
489
|
end
|
429
|
-
filtered = d.
|
490
|
+
filtered = d.filtered
|
430
491
|
assert_equal 1, filtered.length
|
431
492
|
|
432
493
|
first = filtered[0]
|
433
|
-
|
434
|
-
assert_equal time, first[1]
|
494
|
+
assert_equal_parsed_time time, first[0]
|
435
495
|
|
436
|
-
record = first[
|
496
|
+
record = first[1]
|
437
497
|
assert_equal 1, record.keys.size
|
438
498
|
assert_equal({"data.xxx"=>"first","data.yyy"=>"second"}, record['parsed'])
|
439
499
|
end
|
440
500
|
|
441
501
|
CONFIG_DONT_PARSE_TIME = %[
|
442
502
|
key_name data
|
503
|
+
reserve_time true
|
504
|
+
<parse>
|
505
|
+
@type json
|
506
|
+
keep_time_key true
|
507
|
+
</parse>
|
508
|
+
]
|
509
|
+
CONFIG_DONT_PARSE_TIME_COMPAT = %[
|
510
|
+
key_name data
|
511
|
+
reserve_time true
|
443
512
|
format json
|
444
|
-
|
513
|
+
keep_time_key true
|
445
514
|
]
|
446
|
-
|
515
|
+
data(new_conf: CONFIG_DONT_PARSE_TIME,
|
516
|
+
compat_conf: CONFIG_DONT_PARSE_TIME_COMPAT)
|
517
|
+
def test_time_should_be_reserved(conf)
|
447
518
|
t = Time.now.to_i
|
448
|
-
d = create_driver(
|
449
|
-
|
450
|
-
|
451
|
-
d.
|
452
|
-
d.
|
453
|
-
d.filter({'data' => '{"time":"2013-10-31 12:34:03 +0900", "f1":"v1"}'}, t)
|
519
|
+
d = create_driver(conf)
|
520
|
+
d.run(default_tag: @tag) do
|
521
|
+
d.feed(t, {'data' => '{"time":1383190430, "f1":"v1"}'})
|
522
|
+
d.feed(t, {'data' => '{"time":"1383190430", "f1":"v1"}'})
|
523
|
+
d.feed(t, {'data' => '{"time":"2013-10-31 12:34:03 +0900", "f1":"v1"}'})
|
454
524
|
end
|
455
|
-
filtered = d.
|
525
|
+
filtered = d.filtered
|
456
526
|
assert_equal 3, filtered.length
|
457
527
|
|
458
|
-
assert_equal '
|
459
|
-
assert_equal
|
460
|
-
assert_equal
|
461
|
-
assert_equal t, filtered[0][1]
|
528
|
+
assert_equal 'v1', filtered[0][1]['f1']
|
529
|
+
assert_equal 1383190430, filtered[0][1]['time']
|
530
|
+
assert_equal t, filtered[0][0]
|
462
531
|
|
463
|
-
assert_equal '
|
464
|
-
assert_equal
|
465
|
-
assert_equal
|
466
|
-
assert_equal t, filtered[1][1]
|
532
|
+
assert_equal 'v1', filtered[1][1]['f1']
|
533
|
+
assert_equal "1383190430", filtered[1][1]['time']
|
534
|
+
assert_equal t, filtered[1][0]
|
467
535
|
|
468
|
-
assert_equal '
|
469
|
-
assert_equal '
|
470
|
-
assert_equal
|
471
|
-
assert_equal t, filtered[2][1]
|
536
|
+
assert_equal 'v1', filtered[2][1]['f1']
|
537
|
+
assert_equal '2013-10-31 12:34:03 +0900', filtered[2][1]['time']
|
538
|
+
assert_equal t, filtered[2][0]
|
472
539
|
end
|
473
540
|
|
474
541
|
CONFIG_INVALID_TIME_VALUE = %[
|
475
|
-
remove_prefix test
|
476
542
|
key_name data
|
477
|
-
|
543
|
+
<parse>
|
544
|
+
@type json
|
545
|
+
</parse>
|
478
546
|
] # 'time' is implicit @time_key
|
479
547
|
def test_filter_invalid_time_data
|
480
548
|
# should not raise errors
|
481
|
-
|
482
|
-
d = create_driver(CONFIG_INVALID_TIME_VALUE
|
549
|
+
time = Time.now.to_i
|
550
|
+
d = create_driver(CONFIG_INVALID_TIME_VALUE)
|
483
551
|
assert_nothing_raised {
|
484
|
-
d.run do
|
485
|
-
d.
|
486
|
-
d.
|
552
|
+
d.run(default_tag: @tag) do
|
553
|
+
d.feed(time, {'data' => '{"time":[], "f1":"v1"}'})
|
554
|
+
d.feed(time, {'data' => '{"time":"thisisnottime", "f1":"v1"}'})
|
487
555
|
end
|
488
556
|
}
|
489
|
-
filtered = d.
|
557
|
+
filtered = d.filtered
|
490
558
|
assert_equal 1, filtered.length
|
491
559
|
|
492
|
-
assert_equal
|
493
|
-
assert_equal
|
494
|
-
assert_equal
|
495
|
-
assert_equal 0, filtered[0][2]['time'].to_i
|
560
|
+
assert_equal 0, filtered[0][0].to_i
|
561
|
+
assert_equal 'v1', filtered[0][1]['f1']
|
562
|
+
assert_equal nil, filtered[0][1]['time']
|
496
563
|
end
|
497
564
|
|
498
565
|
# REGEXP = /^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$/
|
499
566
|
|
500
567
|
CONFIG_NOT_REPLACE = %[
|
501
|
-
|
502
|
-
|
503
|
-
|
568
|
+
key_name data
|
569
|
+
<parse>
|
570
|
+
@type regexp
|
571
|
+
expression /^(?<message>.*)$/
|
572
|
+
</parse>
|
504
573
|
]
|
505
574
|
CONFIG_INVALID_BYTE = CONFIG_NOT_REPLACE + %[
|
506
575
|
replace_invalid_sequence true
|
@@ -508,237 +577,155 @@ class ParserFilterTest < Test::Unit::TestCase
|
|
508
577
|
def test_filter_invalid_byte
|
509
578
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
510
579
|
|
511
|
-
d = create_driver(CONFIG_NOT_REPLACE
|
512
|
-
|
513
|
-
d.
|
514
|
-
|
515
|
-
|
516
|
-
|
580
|
+
d = create_driver(CONFIG_NOT_REPLACE)
|
581
|
+
d.run do
|
582
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'data' => invalid_utf8})
|
583
|
+
end
|
584
|
+
error_event = d.error_events.first
|
585
|
+
assert_equal "test", error_event[0]
|
586
|
+
assert_instance_of ArgumentError, error_event[3]
|
517
587
|
|
518
|
-
d = create_driver(CONFIG_INVALID_BYTE
|
588
|
+
d = create_driver(CONFIG_INVALID_BYTE)
|
519
589
|
assert_nothing_raised {
|
520
590
|
d.run do
|
521
|
-
d.
|
591
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'data' => invalid_utf8})
|
522
592
|
end
|
523
593
|
}
|
524
|
-
filtered = d.
|
594
|
+
filtered = d.filtered
|
525
595
|
assert_equal 1, filtered.length
|
526
|
-
assert_nil filtered[0][
|
527
|
-
assert_equal '?'.force_encoding('UTF-8'), filtered[0][
|
596
|
+
assert_nil filtered[0][1]['data']
|
597
|
+
assert_equal '?'.force_encoding('UTF-8'), filtered[0][1]['message']
|
528
598
|
|
529
|
-
d = create_driver(CONFIG_INVALID_BYTE + %[
|
530
|
-
reserve_data yes
|
531
|
-
], 'test.no.change')
|
599
|
+
d = create_driver(CONFIG_INVALID_BYTE + %[reserve_data yes])
|
532
600
|
assert_nothing_raised {
|
533
601
|
d.run do
|
534
|
-
d.
|
602
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'data' => invalid_utf8})
|
535
603
|
end
|
536
604
|
}
|
537
|
-
filtered = d.
|
605
|
+
filtered = d.filtered
|
538
606
|
assert_equal 1, filtered.length
|
539
|
-
assert_equal invalid_utf8, filtered[0][
|
540
|
-
assert_equal '?'.force_encoding('UTF-8'), filtered[0][
|
607
|
+
assert_equal invalid_utf8, filtered[0][1]['data']
|
608
|
+
assert_equal '?'.force_encoding('UTF-8'), filtered[0][1]['message']
|
541
609
|
|
542
610
|
invalid_ascii = "\xff".force_encoding('US-ASCII')
|
543
|
-
d = create_driver(CONFIG_INVALID_BYTE
|
611
|
+
d = create_driver(CONFIG_INVALID_BYTE)
|
544
612
|
assert_nothing_raised {
|
545
613
|
d.run do
|
546
|
-
d.
|
614
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'data' => invalid_ascii})
|
547
615
|
end
|
548
616
|
}
|
549
|
-
filtered = d.
|
617
|
+
filtered = d.filtered
|
550
618
|
assert_equal 1, filtered.length
|
551
|
-
assert_nil filtered[0][
|
552
|
-
assert_equal '?'.force_encoding('US-ASCII'), filtered[0][
|
619
|
+
assert_nil filtered[0][1]['data']
|
620
|
+
assert_equal '?'.force_encoding('US-ASCII'), filtered[0][1]['message']
|
553
621
|
end
|
554
622
|
|
555
623
|
CONFIG_NOT_IGNORE = %[
|
556
|
-
|
557
|
-
key_name data
|
558
|
-
format json
|
624
|
+
key_name data
|
559
625
|
hash_value_field parsed
|
626
|
+
<parse>
|
627
|
+
@type json
|
628
|
+
</parse>
|
560
629
|
]
|
561
|
-
|
562
|
-
ignore_key_not_exist true
|
563
|
-
]
|
564
|
-
CONFIG_PASS_SAME_RECORD = CONFIG_IGNORE + %[
|
630
|
+
CONFIG_PASS_SAME_RECORD = CONFIG_NOT_IGNORE + %[
|
565
631
|
reserve_data true
|
566
632
|
]
|
567
633
|
def test_filter_key_not_exist
|
568
|
-
d = create_driver(CONFIG_NOT_IGNORE
|
569
|
-
|
570
|
-
|
571
|
-
d.filter({'foo' => 'bar'}, Time.now.to_i)
|
572
|
-
end
|
573
|
-
}
|
574
|
-
assert_match /data does not exist/, d.instance.log.out.logs.first
|
575
|
-
|
576
|
-
d = create_driver(CONFIG_IGNORE, 'test.ignore')
|
634
|
+
d = create_driver(CONFIG_NOT_IGNORE)
|
635
|
+
flexmock(d.instance.router).should_receive(:emit_error_event).
|
636
|
+
with(String, Integer, Hash, ArgumentError.new("data does not exist")).once
|
577
637
|
assert_nothing_raised {
|
578
638
|
d.run do
|
579
|
-
d.
|
639
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'foo' => 'bar'})
|
580
640
|
end
|
581
641
|
}
|
582
|
-
assert_not_match /data does not exist/, d.instance.log.out.logs.first
|
583
642
|
|
584
|
-
d = create_driver(CONFIG_PASS_SAME_RECORD
|
643
|
+
d = create_driver(CONFIG_PASS_SAME_RECORD)
|
585
644
|
assert_nothing_raised {
|
586
645
|
d.run do
|
587
|
-
d.
|
646
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'foo' => 'bar'})
|
588
647
|
end
|
589
648
|
}
|
590
|
-
filtered = d.
|
649
|
+
filtered = d.filtered
|
591
650
|
assert_equal 1, filtered.length
|
592
|
-
assert_nil filtered[0][
|
593
|
-
assert_equal 'bar', filtered[0][
|
594
|
-
|
595
|
-
d = create_driver(CONFIG_NOT_IGNORE + "emit_invalid_record_to_error true", 'test.no.ignore')
|
596
|
-
assert_nothing_raised {
|
597
|
-
flexmock(d.instance.router).should_receive(:emit_error_event).
|
598
|
-
with(String, Integer, Hash, ArgumentError).once
|
599
|
-
d.run do
|
600
|
-
d.filter({'foo' => 'bar'}, Time.now.to_i)
|
601
|
-
end
|
602
|
-
}
|
651
|
+
assert_nil filtered[0][1]['data']
|
652
|
+
assert_equal 'bar', filtered[0][1]['foo']
|
603
653
|
end
|
604
654
|
|
605
|
-
#
|
606
|
-
CONFIG_DISABELED_SUPPRESS_PARSE_ERROR_LOG = %[
|
607
|
-
tag hogelog
|
608
|
-
format /^col1=(?<col1>.+) col2=(?<col2>.+)$/
|
609
|
-
key_name message
|
610
|
-
suppress_parse_error_log false
|
611
|
-
]
|
612
|
-
CONFIG_ENABELED_SUPPRESS_PARSE_ERROR_LOG = %[
|
613
|
-
tag hogelog
|
614
|
-
format /^col1=(?<col1>.+) col2=(?<col2>.+)$/
|
615
|
-
key_name message
|
616
|
-
suppress_parse_error_log true
|
617
|
-
]
|
618
|
-
CONFIG_DEFAULT_SUPPRESS_PARSE_ERROR_LOG = %[
|
619
|
-
tag hogelog
|
620
|
-
format /^col1=(?<col1>.+) col2=(?<col2>.+)$/
|
621
|
-
key_name message
|
622
|
-
]
|
623
|
-
|
655
|
+
# emit_error_event test
|
624
656
|
INVALID_MESSAGE = 'foo bar'
|
625
657
|
VALID_MESSAGE = 'col1=foo col2=bar'
|
626
658
|
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
raise DummyLoggerWarnedException
|
659
|
+
def test_call_emit_error_event_when_parser_error
|
660
|
+
d = create_driver(CONFIG_INVALID_TIME_VALUE)
|
661
|
+
flexmock(d.instance.router).should_receive(:emit_error_event).
|
662
|
+
with(String, Integer, Hash, ParserError).once
|
663
|
+
d.run do
|
664
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'data' => '{"time":[], "f1":"v1"}'})
|
634
665
|
end
|
635
666
|
end
|
636
667
|
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
yield
|
645
|
-
|
646
|
-
restore.call
|
647
|
-
end
|
648
|
-
|
649
|
-
def test_parser_error_warning
|
650
|
-
d = create_driver(CONFIG_INVALID_TIME_VALUE, 'test.no.change')
|
651
|
-
swap_logger(d.instance) do
|
652
|
-
assert_raise(DummyLoggerWarnedException) {
|
653
|
-
d.run do
|
654
|
-
d.filter({'data' => '{"time":[], "f1":"v1"}'}, Time.now.to_i)
|
655
|
-
end
|
656
|
-
}
|
657
|
-
end
|
658
|
-
end
|
668
|
+
CONFIG_UNMATCHED_PATTERN_LOG = %[
|
669
|
+
key_name message
|
670
|
+
<parse>
|
671
|
+
@type regexp
|
672
|
+
expression /^col1=(?<col1>.+) col2=(?<col2>.+)$/
|
673
|
+
</parse>
|
674
|
+
]
|
659
675
|
|
660
|
-
class
|
661
|
-
|
662
|
-
|
663
|
-
@d = create_driver(CONFIG_DEFAULT_SUPPRESS_PARSE_ERROR_LOG, 'test.no.change')
|
676
|
+
class UnmatchedPatternLogTest < self
|
677
|
+
setup do
|
678
|
+
@d = create_driver(CONFIG_UNMATCHED_PATTERN_LOG)
|
664
679
|
end
|
665
680
|
|
666
|
-
def
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
end
|
672
|
-
}
|
681
|
+
def test_call_emit_error_event_when_pattern_is_mismached
|
682
|
+
flexmock(@d.instance.router).should_receive(:emit_error_event).
|
683
|
+
with(String, Integer, Hash, ParserError.new("pattern not matched with data '#{INVALID_MESSAGE}'")).once
|
684
|
+
@d.run do
|
685
|
+
@d.feed(@tag, Fluent::EventTime.now.to_i, {'message' => INVALID_MESSAGE})
|
673
686
|
end
|
674
687
|
end
|
675
688
|
|
676
|
-
def
|
677
|
-
|
678
|
-
|
679
|
-
@d.
|
680
|
-
@d.filter({'message' => VALID_MESSAGE}, Time.now.to_i)
|
681
|
-
end
|
682
|
-
}
|
689
|
+
def test_not_call_emit_error_event_when_pattern_is_mached
|
690
|
+
flexmock(@d.instance.router).should_receive(:emit_error_event).never
|
691
|
+
@d.run do
|
692
|
+
@d.feed(@tag, Fluent::EventTime.now.to_i, {'message' => VALID_MESSAGE})
|
683
693
|
end
|
684
694
|
end
|
685
695
|
end
|
686
696
|
|
687
|
-
class
|
688
|
-
def
|
689
|
-
|
690
|
-
|
691
|
-
end
|
692
|
-
|
693
|
-
def test_raise_exception
|
694
|
-
swap_logger(@d.instance) do
|
695
|
-
assert_raise(DummyLoggerWarnedException) {
|
696
|
-
@d.run do
|
697
|
-
@d.filter({'message' => INVALID_MESSAGE}, Time.now.to_i)
|
698
|
-
end
|
699
|
-
}
|
700
|
-
end
|
701
|
-
end
|
702
|
-
|
703
|
-
def test_nothing_raised
|
697
|
+
class EmitInvalidRecordToErrorTest < self
|
698
|
+
def test_pattern_is_mismached_with_emit_invalid_record_to_error
|
699
|
+
d = create_driver(CONFIG_UNMATCHED_PATTERN_LOG + "emit_invalid_record_to_error false")
|
700
|
+
flexmock(d.instance.router).should_receive(:emit_error_event).never
|
704
701
|
assert_nothing_raised {
|
705
|
-
|
706
|
-
|
702
|
+
d.run do
|
703
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'message' => INVALID_MESSAGE})
|
707
704
|
end
|
708
705
|
}
|
709
|
-
|
710
|
-
end
|
711
|
-
|
712
|
-
class EnabledSuppressParseErrorLogTest < self
|
713
|
-
def setup
|
714
|
-
# enabled 'suppress_parse_error_log'
|
715
|
-
@d = create_driver(CONFIG_ENABELED_SUPPRESS_PARSE_ERROR_LOG, 'test.no.change')
|
706
|
+
assert_equal 0, d.filtered.length
|
716
707
|
end
|
717
708
|
|
718
|
-
def
|
709
|
+
def test_parser_error_with_emit_invalid_record_to_error
|
710
|
+
d = create_driver(CONFIG_INVALID_TIME_VALUE + "emit_invalid_record_to_error false")
|
711
|
+
flexmock(d.instance.router).should_receive(:emit_error_event).never
|
719
712
|
assert_nothing_raised {
|
720
|
-
|
721
|
-
|
722
|
-
@d.filter({'message' => VALID_MESSAGE}, Time.now.to_i)
|
713
|
+
d.run do
|
714
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'data' => '{"time":[], "f1":"v1"}'})
|
723
715
|
end
|
724
716
|
}
|
717
|
+
assert_equal 0, d.filtered.length
|
725
718
|
end
|
726
|
-
end
|
727
719
|
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
@d = create_driver(CONFIG_ENABELED_SUPPRESS_PARSE_ERROR_LOG + "emit_invalid_record_to_error true", 'test.no.change')
|
732
|
-
end
|
733
|
-
|
734
|
-
def test_nothing_raised
|
735
|
-
flexmock(@d.instance.router).should_receive(:emit_error_event).
|
736
|
-
with(String, Integer, Hash, Fluent::ParserError).once
|
720
|
+
def test_key_not_exist_with_emit_invalid_record_to_error
|
721
|
+
d = create_driver(CONFIG_NOT_IGNORE + "emit_invalid_record_to_error false")
|
722
|
+
flexmock(d.instance.router).should_receive(:emit_error_event).never
|
737
723
|
assert_nothing_raised {
|
738
|
-
|
739
|
-
|
724
|
+
d.run do
|
725
|
+
d.feed(@tag, Fluent::EventTime.now.to_i, {'foo' => 'bar'})
|
740
726
|
end
|
741
727
|
}
|
728
|
+
assert_equal 0, d.filtered.length
|
742
729
|
end
|
743
730
|
end
|
744
731
|
end
|