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
data/test/config/test_dsl.rb
CHANGED
@@ -44,7 +44,7 @@ def prepare_config1
|
|
44
44
|
</elem2>
|
45
45
|
]
|
46
46
|
write_config "#{TMP_DIR}/dir/config_test_9.conf", %[
|
47
|
-
k9
|
47
|
+
k9 embedded
|
48
48
|
<elem3 name>
|
49
49
|
nested nested_value
|
50
50
|
include hoge
|
@@ -176,7 +176,7 @@ module Fluent::Config
|
|
176
176
|
assert_equal('source', ele4.name)
|
177
177
|
assert_predicate(ele4.arg, :empty?)
|
178
178
|
assert_equal(2, ele4.keys.size)
|
179
|
-
assert_equal('tail', ele4['type'])
|
179
|
+
assert_equal('tail', ele4['@type'])
|
180
180
|
assert_equal("/var/log/httpd/access.part4.log", ele4['path'])
|
181
181
|
end
|
182
182
|
|
@@ -185,11 +185,11 @@ module Fluent::Config
|
|
185
185
|
|
186
186
|
assert_equal('filter', filter0.name)
|
187
187
|
assert_equal('bar.**', filter0.arg)
|
188
|
-
assert_equal('hoge', filter0['type'])
|
188
|
+
assert_equal('hoge', filter0['@type'])
|
189
189
|
assert_equal('moge', filter0['val1'])
|
190
190
|
assert_equal(JSON.dump(['foo', 'bar', 'baz']), filter0['val2'])
|
191
191
|
assert_equal('10', filter0['val3'])
|
192
|
-
assert_equal('hoge', filter0['id'])
|
192
|
+
assert_equal('hoge', filter0['@id'])
|
193
193
|
|
194
194
|
assert_equal(2, filter0.elements.size)
|
195
195
|
assert_equal('subsection', filter0.elements[0].name)
|
@@ -203,7 +203,7 @@ module Fluent::Config
|
|
203
203
|
|
204
204
|
assert_equal('match', match0.name)
|
205
205
|
assert_equal('{foo,bar}.**', match0.arg)
|
206
|
-
assert_equal('file', match0['type'])
|
206
|
+
assert_equal('file', match0['@type'])
|
207
207
|
assert_equal('/var/log/httpd/access.myhostname.4.log', match0['path'])
|
208
208
|
end
|
209
209
|
end
|
@@ -262,7 +262,7 @@ module Fluent::Config
|
|
262
262
|
elem2 = @root.elements.find { |e| e.name == 'elem2' }
|
263
263
|
assert(elem2)
|
264
264
|
assert_equal('name', elem2.arg)
|
265
|
-
assert_equal('
|
265
|
+
assert_equal('embedded', elem2['k9'])
|
266
266
|
assert_not_include(elem2, 'include')
|
267
267
|
|
268
268
|
elem3 = elem2.elements.find { |e| e.name == 'elem3' }
|
@@ -302,7 +302,7 @@ module Fluent::Config
|
|
302
302
|
assert_equal('source', ele4.name)
|
303
303
|
assert_predicate(ele4.arg, :empty?)
|
304
304
|
assert_equal(2, ele4.keys.size)
|
305
|
-
assert_equal('tail', ele4['type'])
|
305
|
+
assert_equal('tail', ele4['@type'])
|
306
306
|
assert_equal("/var/log/httpd/access.part4.log", ele4['path'])
|
307
307
|
end
|
308
308
|
|
@@ -311,11 +311,11 @@ module Fluent::Config
|
|
311
311
|
|
312
312
|
assert_equal('filter', filter0.name)
|
313
313
|
assert_equal('bar.**', filter0.arg)
|
314
|
-
assert_equal('hoge', filter0['type'])
|
314
|
+
assert_equal('hoge', filter0['@type'])
|
315
315
|
assert_equal('moge', filter0['val1'])
|
316
316
|
assert_equal(JSON.dump(['foo', 'bar', 'baz']), filter0['val2'])
|
317
317
|
assert_equal('10', filter0['val3'])
|
318
|
-
assert_equal('hoge', filter0['id'])
|
318
|
+
assert_equal('hoge', filter0['@id'])
|
319
319
|
|
320
320
|
assert_equal(2, filter0.elements.size)
|
321
321
|
assert_equal('subsection', filter0.elements[0].name)
|
@@ -329,7 +329,7 @@ module Fluent::Config
|
|
329
329
|
|
330
330
|
assert_equal('match', match0.name)
|
331
331
|
assert_equal('{foo,bar}.**', match0.arg)
|
332
|
-
assert_equal('file', match0['type'])
|
332
|
+
assert_equal('file', match0['@type'])
|
333
333
|
assert_equal('/var/log/httpd/access.myhostname.4.log', match0['path'])
|
334
334
|
end
|
335
335
|
end
|
@@ -338,7 +338,7 @@ module Fluent::Config
|
|
338
338
|
sub_test_case 'with configuration that returns non element on top' do
|
339
339
|
sub_test_case '.parse' do
|
340
340
|
test 'does not crash' do
|
341
|
-
|
341
|
+
Fluent::Config::DSL::Parser.parse(DSL_CONFIG_RETURNS_NON_ELEMENT, 'dsl_config_returns_non_element.rb')
|
342
342
|
end
|
343
343
|
end
|
344
344
|
end
|
@@ -0,0 +1,500 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/config/element'
|
3
|
+
require 'fluent/config/configure_proxy'
|
4
|
+
require 'fluent/configurable'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
class TestConfigElement < ::Test::Unit::TestCase
|
8
|
+
def element(name = 'ROOT', arg = '', attrs = {}, elements = [], unused = nil)
|
9
|
+
Fluent::Config::Element.new(name, arg, attrs, elements, unused)
|
10
|
+
end
|
11
|
+
|
12
|
+
sub_test_case '#elements=' do
|
13
|
+
test 'elements can be set by others' do
|
14
|
+
e = element()
|
15
|
+
assert_equal [], e.elements
|
16
|
+
|
17
|
+
e1 = element('e1')
|
18
|
+
e2 = element('e2')
|
19
|
+
e.elements = [e1, e2]
|
20
|
+
assert_equal [e1, e2], e.elements
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
sub_test_case '#elements' do
|
25
|
+
setup do
|
26
|
+
@c1 = element('source')
|
27
|
+
@c2 = element('source', 'yay')
|
28
|
+
@c3 = element('match', 'test.**')
|
29
|
+
@c4 = element('label', '@mytest', {}, [ element('filter', '**'), element('match', '**') ])
|
30
|
+
children = [@c1, @c2, @c3, @c4]
|
31
|
+
@e = Fluent::Config::Element.new('ROOT', '', {}, children)
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'returns all elements without arguments' do
|
35
|
+
assert_equal [@c1, @c2, @c3, @c4], @e.elements
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'returns elements with specified names' do
|
39
|
+
assert_equal [@c1, @c2, @c3], @e.elements('source', 'match')
|
40
|
+
assert_equal [@c3, @c4], @e.elements('match', 'label')
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'returns elements with specified name, and arg if specified' do
|
44
|
+
assert_equal [@c1, @c2], @e.elements(name: 'source')
|
45
|
+
assert_equal [@c2], @e.elements(name: 'source', arg: 'yay')
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'keyword argument name/arg and names are exclusive' do
|
49
|
+
assert_raise ArgumentError do
|
50
|
+
@e.elements('source', name: 'match')
|
51
|
+
end
|
52
|
+
assert_raise ArgumentError do
|
53
|
+
@e.elements('source', 'match', name: 'label', arg: '@mytest')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'specifying only arg without name is invalid' do
|
58
|
+
assert_raise ArgumentError do
|
59
|
+
@e.elements(arg: '@mytest')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
sub_test_case '#initialize' do
|
65
|
+
test 'creates object with blank attrs and elements' do
|
66
|
+
e = element('ROOT', '', {}, [])
|
67
|
+
assert_equal([], e.elements)
|
68
|
+
end
|
69
|
+
|
70
|
+
test 'creates object which contains attrs and elements' do
|
71
|
+
e = element('ROOT', '', {"k1" => "v1", "k2" => "v2"}, [
|
72
|
+
element('test', 'mydata', {'k3' => 'v3'}, [])
|
73
|
+
])
|
74
|
+
assert_equal('ROOT', e.name)
|
75
|
+
assert_equal('', e.arg)
|
76
|
+
assert_equal('v1', e["k1"])
|
77
|
+
assert_equal('v2', e["k2"])
|
78
|
+
assert_equal(1, e.elements.size)
|
79
|
+
e.each_element('test') do |el|
|
80
|
+
assert_equal('test', el.name)
|
81
|
+
assert_equal('mydata', el.arg)
|
82
|
+
assert_equal('v3', el["k3"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
test 'creates object which contains attrs, elements and unused' do
|
87
|
+
e = element('ROOT', '', {"k1" => "v1", "k2" => "v2", "k4" => "v4"}, [
|
88
|
+
element('test', 'mydata', {'k3' => 'v3'}, [])
|
89
|
+
], "k3")
|
90
|
+
assert_equal("k3", e.unused)
|
91
|
+
assert_equal('ROOT', e.name)
|
92
|
+
assert_equal('', e.arg)
|
93
|
+
assert_equal('v1', e["k1"])
|
94
|
+
assert_equal('v2', e["k2"])
|
95
|
+
assert_equal('v4', e["k4"])
|
96
|
+
assert_equal(1, e.elements.size)
|
97
|
+
e.each_element('test') do |el|
|
98
|
+
assert_equal('test', el.name)
|
99
|
+
assert_equal('mydata', el.arg)
|
100
|
+
assert_equal('v3', el["k3"])
|
101
|
+
end
|
102
|
+
assert_equal("k3", e.unused)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
sub_test_case "@unused" do
|
107
|
+
sub_test_case '#[] has side effect for @unused' do
|
108
|
+
test 'without unused argument' do
|
109
|
+
e = element('ROOT', '', {"k1" => "v1", "k2" => "v2", "k4" => "v4"}, [
|
110
|
+
element('test', 'mydata', {'k3' => 'v3'}, [])
|
111
|
+
])
|
112
|
+
assert_equal(["k1", "k2", "k4"], e.unused)
|
113
|
+
assert_equal('v1', e["k1"])
|
114
|
+
assert_equal(["k2", "k4"], e.unused)
|
115
|
+
assert_equal('v2', e["k2"])
|
116
|
+
assert_equal(["k4"], e.unused)
|
117
|
+
assert_equal('v4', e["k4"])
|
118
|
+
assert_equal([], e.unused)
|
119
|
+
end
|
120
|
+
|
121
|
+
test 'with unused argument' do
|
122
|
+
e = element('ROOT', '', {"k1" => "v1", "k2" => "v2", "k4" => "v4"}, [
|
123
|
+
element('test', 'mydata', {'k3' => 'v3'}, [])
|
124
|
+
], ["k4"])
|
125
|
+
assert_equal(["k4"], e.unused)
|
126
|
+
assert_equal('v1', e["k1"])
|
127
|
+
assert_equal(["k4"], e.unused)
|
128
|
+
assert_equal('v2', e["k2"])
|
129
|
+
assert_equal(["k4"], e.unused)
|
130
|
+
assert_equal('v4', e["k4"])
|
131
|
+
# only consume for "k4"
|
132
|
+
assert_equal([], e.unused)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
sub_test_case '#add_element' do
|
138
|
+
test 'elements can be set by #add_element' do
|
139
|
+
e = element()
|
140
|
+
assert_equal [], e.elements
|
141
|
+
|
142
|
+
e.add_element('e1', '')
|
143
|
+
e.add_element('e2', '')
|
144
|
+
assert_equal [element('e1', ''), element('e2', '')], e.elements
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
sub_test_case '#==' do
|
149
|
+
sub_test_case 'compare with two element objects' do
|
150
|
+
test 'equal' do
|
151
|
+
e1 = element('ROOT', '', {}, [])
|
152
|
+
e2 = element('ROOT', '', {}, [])
|
153
|
+
assert_true(e1 == e2)
|
154
|
+
end
|
155
|
+
|
156
|
+
data("differ args" => [Fluent::Config::Element.new('ROOT', '', {}, []),
|
157
|
+
Fluent::Config::Element.new('ROOT', 'mydata', {}, [])],
|
158
|
+
"differ keys" => [Fluent::Config::Element.new('ROOT', 'mydata', {}, []),
|
159
|
+
Fluent::Config::Element.new('ROOT', 'mydata', {"k1" => "v1"}, [])],
|
160
|
+
"differ elements" =>
|
161
|
+
[Fluent::Config::Element.new('ROOT', 'mydata', {"k1" => "v1"}, []),
|
162
|
+
Fluent::Config::Element.new('ROOT', 'mydata', {"k1" => "v1"}, [
|
163
|
+
Fluent::Config::Element.new('test', 'mydata', {'k3' => 'v3'}, [])
|
164
|
+
])])
|
165
|
+
test 'not equal' do |data|
|
166
|
+
e1, e2 = data
|
167
|
+
assert_false(e1 == e2)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
sub_test_case '#+' do
|
173
|
+
test 'can merge 2 elements: object side is primary' do
|
174
|
+
e1 = element('ROOT', 'mydata', {"k1" => "v1"}, [])
|
175
|
+
e2 = element('ROOT', 'mydata2', {"k1" => "ignored", "k2" => "v2"}, [
|
176
|
+
element('test', 'ext', {'k3' => 'v3'}, [])
|
177
|
+
])
|
178
|
+
e = e1 + e2
|
179
|
+
|
180
|
+
assert_equal('ROOT', e.name)
|
181
|
+
assert_equal('mydata', e.arg)
|
182
|
+
assert_equal('v1', e['k1'])
|
183
|
+
assert_equal('v2', e['k2'])
|
184
|
+
assert_equal(1, e.elements.size)
|
185
|
+
e.each_element('test') do |el|
|
186
|
+
assert_equal('test', el.name)
|
187
|
+
assert_equal('ext', el.arg)
|
188
|
+
assert_equal('v3', el["k3"])
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
sub_test_case '#check_not_fetched' do
|
194
|
+
sub_test_case 'without unused' do
|
195
|
+
test 'can get attribute keys and original Config::Element' do
|
196
|
+
e = element('ROOT', 'mydata', {"k1" => "v1"}, [])
|
197
|
+
e.check_not_fetched { |key, elem|
|
198
|
+
assert_equal("k1", key)
|
199
|
+
assert_equal(e, elem)
|
200
|
+
}
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
sub_test_case 'with unused' do
|
205
|
+
test 'can get unused marked attribute keys and original Config::Element' do
|
206
|
+
e = element('ROOT', 'mydata', {"k1" => "v1", "k2" => "unused", "k3" => "k3"})
|
207
|
+
e.unused = "k2"
|
208
|
+
e.check_not_fetched { |key, elem|
|
209
|
+
assert_equal("k2", key)
|
210
|
+
assert_equal(e, elem)
|
211
|
+
}
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
sub_test_case '#has_key?' do
|
217
|
+
test 'can get boolean with key name' do
|
218
|
+
e = element('ROOT', 'mydata', {"k1" => "v1"}, [])
|
219
|
+
assert_true(e.has_key?("k1"))
|
220
|
+
assert_false(e.has_key?("noexistent"))
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
sub_test_case '#to_s' do
|
226
|
+
data("without v1_config" => [false, <<-CONF
|
227
|
+
<ROOT>
|
228
|
+
k1 v1
|
229
|
+
k2 "stringVal"
|
230
|
+
<test ext>
|
231
|
+
k2 v2
|
232
|
+
</test>
|
233
|
+
</ROOT>
|
234
|
+
CONF
|
235
|
+
],
|
236
|
+
"with v1_config" => [true, <<-CONF
|
237
|
+
<ROOT>
|
238
|
+
k1 v1
|
239
|
+
k2 "stringVal"
|
240
|
+
<test ext>
|
241
|
+
k2 v2
|
242
|
+
</test>
|
243
|
+
</ROOT>
|
244
|
+
CONF
|
245
|
+
],
|
246
|
+
)
|
247
|
+
test 'dump config element with #to_s' do |data|
|
248
|
+
v1_config, expected = data
|
249
|
+
e = element('ROOT', '', {'k1' => 'v1', "k2" =>"\"stringVal\""}, [
|
250
|
+
element('test', 'ext', {'k2' => 'v2'}, [])
|
251
|
+
])
|
252
|
+
e.v1_config = v1_config
|
253
|
+
dump = expected
|
254
|
+
assert_not_equal(e.inspect, e.to_s)
|
255
|
+
assert_equal(dump, e.to_s)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
sub_test_case '#inspect' do
|
260
|
+
test 'dump config element with #inspect' do
|
261
|
+
e = element('ROOT', '', {'k1' => 'v1'}, [
|
262
|
+
element('test', 'ext', {'k2' => 'v2'}, [])
|
263
|
+
])
|
264
|
+
dump = <<-CONF
|
265
|
+
name:ROOT, arg:, {\"k1\"=>\"v1\"}, [name:test, arg:ext, {\"k2\"=>\"v2\"}, []]
|
266
|
+
CONF
|
267
|
+
assert_not_equal(e.to_s, e.inspect)
|
268
|
+
assert_equal(dump.chomp, e.inspect)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
sub_test_case 'for sections which has secret parameter' do
|
273
|
+
setup do
|
274
|
+
@type_lookup = ->(type){ Fluent::Configurable.lookup_type(type) }
|
275
|
+
p1 = Fluent::Config::ConfigureProxy.new(:match, type_lookup: @type_lookup)
|
276
|
+
p1.config_param :str1, :string
|
277
|
+
p1.config_param :str2, :string, secret: true
|
278
|
+
p1.config_param :enum1, :enum, list: [:a, :b, :c]
|
279
|
+
p1.config_param :enum2, :enum, list: [:a, :b, :c], secret: true
|
280
|
+
p1.config_param :bool1, :bool
|
281
|
+
p1.config_param :bool2, :bool, secret: true
|
282
|
+
p1.config_param :int1, :integer
|
283
|
+
p1.config_param :int2, :integer, secret: true
|
284
|
+
p1.config_param :float1, :float
|
285
|
+
p1.config_param :float2, :float, secret: true
|
286
|
+
p2 = Fluent::Config::ConfigureProxy.new(:match, type_lookup: @type_lookup)
|
287
|
+
p2.config_param :size1, :size
|
288
|
+
p2.config_param :size2, :size, secret: true
|
289
|
+
p2.config_param :time1, :time
|
290
|
+
p2.config_param :time2, :time, secret: true
|
291
|
+
p2.config_param :array1, :array
|
292
|
+
p2.config_param :array2, :array, secret: true
|
293
|
+
p2.config_param :hash1, :hash
|
294
|
+
p2.config_param :hash2, :hash, secret: true
|
295
|
+
p1.config_section :mysection do
|
296
|
+
config_param :str1, :string
|
297
|
+
config_param :str2, :string, secret: true
|
298
|
+
config_param :enum1, :enum, list: [:a, :b, :c]
|
299
|
+
config_param :enum2, :enum, list: [:a, :b, :c], secret: true
|
300
|
+
config_param :bool1, :bool
|
301
|
+
config_param :bool2, :bool, secret: true
|
302
|
+
config_param :int1, :integer
|
303
|
+
config_param :int2, :integer, secret: true
|
304
|
+
config_param :float1, :float
|
305
|
+
config_param :float2, :float, secret: true
|
306
|
+
config_param :size1, :size
|
307
|
+
config_param :size2, :size, secret: true
|
308
|
+
config_param :time1, :time
|
309
|
+
config_param :time2, :time, secret: true
|
310
|
+
config_param :array1, :array
|
311
|
+
config_param :array2, :array, secret: true
|
312
|
+
config_param :hash1, :hash
|
313
|
+
config_param :hash2, :hash, secret: true
|
314
|
+
end
|
315
|
+
params = {
|
316
|
+
'str1' => 'aaa', 'str2' => 'bbb', 'enum1' => 'a', 'enum2' => 'b', 'bool1' => 'true', 'bool2' => 'yes',
|
317
|
+
'int1' => '1', 'int2' => '2', 'float1' => '1.0', 'float2' => '0.5', 'size1' => '1k', 'size2' => '1m',
|
318
|
+
'time1' => '5m', 'time2' => '3h', 'array1' => 'a,b,c', 'array2' => 'd,e,f',
|
319
|
+
'hash1' => 'a:1,b:2', 'hash2' => 'a:2,b:4',
|
320
|
+
'unknown1' => 'yay', 'unknown2' => 'boo',
|
321
|
+
}
|
322
|
+
e2 = Fluent::Config::Element.new('mysection', '', params.dup, [])
|
323
|
+
e2.corresponding_proxies << p1.sections.values.first
|
324
|
+
@e = Fluent::Config::Element.new('match', '**', params, [e2])
|
325
|
+
@e.corresponding_proxies << p1
|
326
|
+
@e.corresponding_proxies << p2
|
327
|
+
end
|
328
|
+
|
329
|
+
sub_test_case '#to_masked_element' do
|
330
|
+
test 'returns a new element object which has masked values for secret parameters and elements' do
|
331
|
+
e = @e.to_masked_element
|
332
|
+
assert_equal 'aaa', e['str1']
|
333
|
+
assert_equal 'xxxxxx', e['str2']
|
334
|
+
assert_equal 'a', e['enum1']
|
335
|
+
assert_equal 'xxxxxx', e['enum2']
|
336
|
+
assert_equal 'true', e['bool1']
|
337
|
+
assert_equal 'xxxxxx', e['bool2']
|
338
|
+
assert_equal '1', e['int1']
|
339
|
+
assert_equal 'xxxxxx', e['int2']
|
340
|
+
assert_equal '1.0', e['float1']
|
341
|
+
assert_equal 'xxxxxx', e['float2']
|
342
|
+
assert_equal '1k', e['size1']
|
343
|
+
assert_equal 'xxxxxx', e['size2']
|
344
|
+
assert_equal '5m', e['time1']
|
345
|
+
assert_equal 'xxxxxx', e['time2']
|
346
|
+
assert_equal 'a,b,c', e['array1']
|
347
|
+
assert_equal 'xxxxxx', e['array2']
|
348
|
+
assert_equal 'a:1,b:2', e['hash1']
|
349
|
+
assert_equal 'xxxxxx', e['hash2']
|
350
|
+
assert_equal 'yay', e['unknown1']
|
351
|
+
assert_equal 'boo', e['unknown2']
|
352
|
+
e2 = e.elements.first
|
353
|
+
assert_equal 'aaa', e2['str1']
|
354
|
+
assert_equal 'xxxxxx', e2['str2']
|
355
|
+
assert_equal 'a', e2['enum1']
|
356
|
+
assert_equal 'xxxxxx', e2['enum2']
|
357
|
+
assert_equal 'true', e2['bool1']
|
358
|
+
assert_equal 'xxxxxx', e2['bool2']
|
359
|
+
assert_equal '1', e2['int1']
|
360
|
+
assert_equal 'xxxxxx', e2['int2']
|
361
|
+
assert_equal '1.0', e2['float1']
|
362
|
+
assert_equal 'xxxxxx', e2['float2']
|
363
|
+
assert_equal '1k', e2['size1']
|
364
|
+
assert_equal 'xxxxxx', e2['size2']
|
365
|
+
assert_equal '5m', e2['time1']
|
366
|
+
assert_equal 'xxxxxx', e2['time2']
|
367
|
+
assert_equal 'a,b,c', e2['array1']
|
368
|
+
assert_equal 'xxxxxx', e2['array2']
|
369
|
+
assert_equal 'a:1,b:2', e2['hash1']
|
370
|
+
assert_equal 'xxxxxx', e2['hash2']
|
371
|
+
assert_equal 'yay', e2['unknown1']
|
372
|
+
assert_equal 'boo', e2['unknown2']
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
sub_test_case '#secret_param?' do
|
377
|
+
test 'returns boolean which shows values of given key will be masked' do
|
378
|
+
assert !@e.secret_param?('str1')
|
379
|
+
assert @e.secret_param?('str2')
|
380
|
+
assert !@e.elements.first.secret_param?('str1')
|
381
|
+
assert @e.elements.first.secret_param?('str2')
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
sub_test_case '#param_type' do
|
386
|
+
test 'returns parameter type which are registered in corresponding proxy' do
|
387
|
+
assert_equal :string, @e.param_type('str1')
|
388
|
+
assert_equal :string, @e.param_type('str2')
|
389
|
+
assert_equal :enum, @e.param_type('enum1')
|
390
|
+
assert_equal :enum, @e.param_type('enum2')
|
391
|
+
assert_nil @e.param_type('unknown1')
|
392
|
+
assert_nil @e.param_type('unknown2')
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
# sub_test_case '#dump_value'
|
397
|
+
sub_test_case '#dump_value' do
|
398
|
+
test 'dumps parameter_name and values with leading indentation' do
|
399
|
+
assert_equal "str1 aaa\n", @e.dump_value("str1", @e["str1"], "")
|
400
|
+
assert_equal "str2 xxxxxx\n", @e.dump_value("str2", @e["str2"], "")
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
sub_test_case '#set_target_worker' do
|
406
|
+
test 'set target_worker_id recursively' do
|
407
|
+
e = element('label', '@mytest', {}, [ element('filter', '**'), element('match', '**', {}, [ element('store'), element('store') ]) ])
|
408
|
+
e.set_target_worker_id(1)
|
409
|
+
assert_equal [1], e.target_worker_ids
|
410
|
+
assert_equal [1], e.elements[0].target_worker_ids
|
411
|
+
assert_equal [1], e.elements[1].target_worker_ids
|
412
|
+
assert_equal [1], e.elements[1].elements[0].target_worker_ids
|
413
|
+
assert_equal [1], e.elements[1].elements[1].target_worker_ids
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
sub_test_case '#for_every_workers?' do
|
418
|
+
test 'has target_worker_id' do
|
419
|
+
e = element()
|
420
|
+
e.set_target_worker_id(1)
|
421
|
+
assert_false e.for_every_workers?
|
422
|
+
end
|
423
|
+
|
424
|
+
test "doesn't have target_worker_id" do
|
425
|
+
e = element()
|
426
|
+
assert e.for_every_workers?
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
sub_test_case '#for_this_workers?' do
|
431
|
+
test 'target_worker_id == current worker_id' do
|
432
|
+
e = element()
|
433
|
+
e.set_target_worker_id(0)
|
434
|
+
assert e.for_this_worker?
|
435
|
+
end
|
436
|
+
|
437
|
+
test 'target_worker_ids includes current worker_id' do
|
438
|
+
e = element()
|
439
|
+
e.set_target_worker_ids([0])
|
440
|
+
assert e.for_this_worker?
|
441
|
+
end
|
442
|
+
|
443
|
+
test 'target_worker_id != current worker_id' do
|
444
|
+
e = element()
|
445
|
+
e.set_target_worker_id(1)
|
446
|
+
assert_false e.for_this_worker?
|
447
|
+
end
|
448
|
+
|
449
|
+
test 'target_worker_ids does not includes current worker_id' do
|
450
|
+
e = element()
|
451
|
+
e.set_target_worker_ids([1, 2])
|
452
|
+
assert_false e.for_this_worker?
|
453
|
+
end
|
454
|
+
|
455
|
+
test "doesn't have target_worker_id" do
|
456
|
+
e = element()
|
457
|
+
assert_false e.for_this_worker?
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
sub_test_case '#for_another_worker?' do
|
462
|
+
test 'target_worker_id == current worker_id' do
|
463
|
+
e = element()
|
464
|
+
e.set_target_worker_id(0)
|
465
|
+
assert_false e.for_another_worker?
|
466
|
+
end
|
467
|
+
|
468
|
+
test 'target_worker_ids contains current worker_id' do
|
469
|
+
e = element()
|
470
|
+
e.set_target_worker_ids([0, 1])
|
471
|
+
assert_false e.for_another_worker?
|
472
|
+
end
|
473
|
+
|
474
|
+
test 'target_worker_id != current worker_id' do
|
475
|
+
e = element()
|
476
|
+
e.set_target_worker_id(1)
|
477
|
+
assert e.for_another_worker?
|
478
|
+
end
|
479
|
+
|
480
|
+
test 'target_worker_ids does not contains current worker_id' do
|
481
|
+
e = element()
|
482
|
+
e.set_target_worker_ids([1, 2])
|
483
|
+
assert e.for_another_worker?
|
484
|
+
end
|
485
|
+
|
486
|
+
test "doesn't have target_worker_id" do
|
487
|
+
e = element()
|
488
|
+
assert_false e.for_another_worker?
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
sub_test_case '#pretty_print' do
|
493
|
+
test 'prints inspect to pp object' do
|
494
|
+
q = PP.new
|
495
|
+
e = element()
|
496
|
+
e.pretty_print(q)
|
497
|
+
assert_equal e.inspect, q.output
|
498
|
+
end
|
499
|
+
end
|
500
|
+
end
|
@@ -232,6 +232,14 @@ module Fluent::Config
|
|
232
232
|
test("\"\#{\n=begin\n}\"") { assert_parse_error("\"\#{\n=begin\n}\"") } # error in embedded ruby code
|
233
233
|
test('"#{v1}foo#{v2}"') { assert_text_parsed_as("#{v1}foo#{v2}", '"#{v1}foo#{v2}"') }
|
234
234
|
test('"#{1+1}foo#{2+2}bar"') { assert_text_parsed_as("#{1+1}foo#{2+2}bar", '"#{1+1}foo#{2+2}bar"') }
|
235
|
+
test('"foo#{hostname}"') { assert_text_parsed_as("foo#{Socket.gethostname}", '"foo#{hostname}"') }
|
236
|
+
test('"foo#{worker_id}"') {
|
237
|
+
ENV.delete('SERVERENGINE_WORKER_ID')
|
238
|
+
assert_text_parsed_as("foo", '"foo#{worker_id}"')
|
239
|
+
ENV['SERVERENGINE_WORKER_ID'] = '1'
|
240
|
+
assert_text_parsed_as("foo1", '"foo#{worker_id}"')
|
241
|
+
ENV.delete('SERVERENGINE_WORKER_ID')
|
242
|
+
}
|
235
243
|
end
|
236
244
|
|
237
245
|
sub_test_case 'array parsing' do
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/plugin/input'
|
3
|
+
require 'fluent/test/driver/input'
|
4
|
+
|
5
|
+
module ConfigurationForPlugins
|
6
|
+
class AllBooleanParams < Fluent::Plugin::Input
|
7
|
+
config_param :flag1, :bool, default: true
|
8
|
+
config_param :flag2, :bool, default: true
|
9
|
+
config_param :flag3, :bool, default: false
|
10
|
+
config_param :flag4, :bool, default: false
|
11
|
+
|
12
|
+
config_section :child, param_name: :children, multi: true, required: true do
|
13
|
+
config_param :flag1, :bool, default: true
|
14
|
+
config_param :flag2, :bool, default: true
|
15
|
+
config_param :flag3, :bool, default: false
|
16
|
+
config_param :flag4, :bool, default: false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class BooleanParamsWithoutValue < ::Test::Unit::TestCase
|
21
|
+
CONFIG = <<CONFIG
|
22
|
+
flag1
|
23
|
+
flag2 # yaaaaaaaaaay
|
24
|
+
flag3
|
25
|
+
flag4 # yaaaaaaaaaay
|
26
|
+
<child>
|
27
|
+
flag1
|
28
|
+
flag2 # yaaaaaaaaaay
|
29
|
+
flag3
|
30
|
+
flag4 # yaaaaaaaaaay
|
31
|
+
</child>
|
32
|
+
<child>
|
33
|
+
flag1 # yaaaaaaaaaay
|
34
|
+
flag2
|
35
|
+
flag3 # yaaaaaaaaaay
|
36
|
+
flag4
|
37
|
+
</child>
|
38
|
+
# with following whitespace
|
39
|
+
<child>
|
40
|
+
flag1
|
41
|
+
flag2
|
42
|
+
flag3
|
43
|
+
flag4
|
44
|
+
</child>
|
45
|
+
CONFIG
|
46
|
+
|
47
|
+
test 'create plugin via driver' do
|
48
|
+
d = Fluent::Test::Driver::Input.new(AllBooleanParams)
|
49
|
+
d.configure(CONFIG)
|
50
|
+
assert_equal([true] * 4, [d.instance.flag1, d.instance.flag2, d.instance.flag3, d.instance.flag4])
|
51
|
+
num_of_sections = 3
|
52
|
+
assert_equal num_of_sections, d.instance.children.size
|
53
|
+
assert_equal([true] * (num_of_sections * 4), d.instance.children.map{|c| [c.flag1, c.flag2, c.flag3, c.flag4]}.flatten)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|