fluentd 1.17.0 → 1.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/README.md +1 -0
- data/SECURITY.md +2 -2
- data/fluent.conf +14 -14
- data/lib/fluent/command/cap_ctl.rb +4 -4
- data/lib/fluent/compat/call_super_mixin.rb +3 -3
- data/lib/fluent/compat/propagate_default.rb +4 -4
- data/lib/fluent/config/yaml_parser/parser.rb +4 -0
- data/lib/fluent/log/console_adapter.rb +4 -2
- data/lib/fluent/plugin/in_exec.rb +14 -2
- data/lib/fluent/plugin/in_http.rb +1 -1
- data/lib/fluent/plugin/in_sample.rb +13 -7
- data/lib/fluent/plugin/in_tail.rb +65 -23
- data/lib/fluent/plugin/out_copy.rb +1 -1
- data/lib/fluent/plugin/out_file.rb +8 -0
- data/lib/fluent/plugin/out_http.rb +12 -0
- data/lib/fluent/plugin/parser_json.rb +4 -12
- data/lib/fluent/plugin_helper/http_server/server.rb +1 -1
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/fluent-plugin.gemspec.erb +6 -5
- metadata +25 -472
- data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +0 -50
- data/.github/DISCUSSION_TEMPLATE/q-a.yml +0 -47
- data/.github/ISSUE_TEMPLATE/bug_report.yml +0 -71
- data/.github/ISSUE_TEMPLATE/config.yml +0 -5
- data/.github/ISSUE_TEMPLATE/feature_request.yml +0 -39
- data/.github/ISSUE_TEMPLATE.md +0 -17
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- data/.github/workflows/stale-actions.yml +0 -24
- data/.github/workflows/test-ruby-head.yml +0 -31
- data/.github/workflows/test.yml +0 -32
- data/.gitignore +0 -30
- data/Gemfile +0 -9
- data/fluentd.gemspec +0 -62
- data/test/command/test_binlog_reader.rb +0 -362
- data/test/command/test_ca_generate.rb +0 -70
- data/test/command/test_cap_ctl.rb +0 -100
- data/test/command/test_cat.rb +0 -128
- data/test/command/test_ctl.rb +0 -56
- data/test/command/test_fluentd.rb +0 -1291
- data/test/command/test_plugin_config_formatter.rb +0 -397
- data/test/command/test_plugin_generator.rb +0 -109
- data/test/compat/test_calls_super.rb +0 -166
- data/test/compat/test_parser.rb +0 -92
- data/test/config/assertions.rb +0 -42
- data/test/config/test_config_parser.rb +0 -551
- data/test/config/test_configurable.rb +0 -1784
- data/test/config/test_configure_proxy.rb +0 -604
- data/test/config/test_dsl.rb +0 -415
- data/test/config/test_element.rb +0 -518
- data/test/config/test_literal_parser.rb +0 -309
- data/test/config/test_plugin_configuration.rb +0 -56
- data/test/config/test_section.rb +0 -191
- data/test/config/test_system_config.rb +0 -195
- data/test/config/test_types.rb +0 -408
- data/test/counter/test_client.rb +0 -563
- data/test/counter/test_error.rb +0 -44
- data/test/counter/test_mutex_hash.rb +0 -179
- data/test/counter/test_server.rb +0 -589
- data/test/counter/test_store.rb +0 -258
- data/test/counter/test_validator.rb +0 -137
- data/test/helper.rb +0 -155
- data/test/helpers/fuzzy_assert.rb +0 -89
- data/test/helpers/process_extenstion.rb +0 -33
- data/test/log/test_console_adapter.rb +0 -117
- data/test/plugin/data/2010/01/20100102-030405.log +0 -0
- data/test/plugin/data/2010/01/20100102-030406.log +0 -0
- data/test/plugin/data/2010/01/20100102.log +0 -0
- data/test/plugin/data/log/bar +0 -0
- data/test/plugin/data/log/foo/bar.log +0 -0
- data/test/plugin/data/log/foo/bar2 +0 -0
- data/test/plugin/data/log/test.log +0 -0
- data/test/plugin/data/log_numeric/01.log +0 -0
- data/test/plugin/data/log_numeric/02.log +0 -0
- data/test/plugin/data/log_numeric/12.log +0 -0
- data/test/plugin/data/log_numeric/14.log +0 -0
- data/test/plugin/data/sd_file/config +0 -11
- data/test/plugin/data/sd_file/config.json +0 -17
- data/test/plugin/data/sd_file/config.yaml +0 -11
- data/test/plugin/data/sd_file/config.yml +0 -11
- data/test/plugin/data/sd_file/invalid_config.yml +0 -7
- data/test/plugin/in_tail/test_fifo.rb +0 -121
- data/test/plugin/in_tail/test_io_handler.rb +0 -150
- data/test/plugin/in_tail/test_position_file.rb +0 -346
- data/test/plugin/out_forward/test_ack_handler.rb +0 -140
- data/test/plugin/out_forward/test_connection_manager.rb +0 -145
- data/test/plugin/out_forward/test_handshake_protocol.rb +0 -112
- data/test/plugin/out_forward/test_load_balancer.rb +0 -106
- data/test/plugin/out_forward/test_socket_cache.rb +0 -174
- data/test/plugin/test_bare_output.rb +0 -131
- data/test/plugin/test_base.rb +0 -247
- data/test/plugin/test_buf_file.rb +0 -1314
- data/test/plugin/test_buf_file_single.rb +0 -898
- data/test/plugin/test_buf_memory.rb +0 -42
- data/test/plugin/test_buffer.rb +0 -1493
- data/test/plugin/test_buffer_chunk.rb +0 -209
- data/test/plugin/test_buffer_file_chunk.rb +0 -871
- data/test/plugin/test_buffer_file_single_chunk.rb +0 -611
- data/test/plugin/test_buffer_memory_chunk.rb +0 -339
- data/test/plugin/test_compressable.rb +0 -87
- data/test/plugin/test_file_util.rb +0 -96
- data/test/plugin/test_filter.rb +0 -368
- data/test/plugin/test_filter_grep.rb +0 -697
- data/test/plugin/test_filter_parser.rb +0 -731
- data/test/plugin/test_filter_record_transformer.rb +0 -577
- data/test/plugin/test_filter_stdout.rb +0 -207
- data/test/plugin/test_formatter_csv.rb +0 -136
- data/test/plugin/test_formatter_hash.rb +0 -38
- data/test/plugin/test_formatter_json.rb +0 -61
- data/test/plugin/test_formatter_ltsv.rb +0 -70
- data/test/plugin/test_formatter_msgpack.rb +0 -28
- data/test/plugin/test_formatter_out_file.rb +0 -116
- data/test/plugin/test_formatter_single_value.rb +0 -44
- data/test/plugin/test_formatter_tsv.rb +0 -76
- data/test/plugin/test_in_debug_agent.rb +0 -49
- data/test/plugin/test_in_exec.rb +0 -261
- data/test/plugin/test_in_forward.rb +0 -1178
- data/test/plugin/test_in_gc_stat.rb +0 -62
- data/test/plugin/test_in_http.rb +0 -1124
- data/test/plugin/test_in_monitor_agent.rb +0 -922
- data/test/plugin/test_in_object_space.rb +0 -66
- data/test/plugin/test_in_sample.rb +0 -190
- data/test/plugin/test_in_syslog.rb +0 -505
- data/test/plugin/test_in_tail.rb +0 -3429
- data/test/plugin/test_in_tcp.rb +0 -328
- data/test/plugin/test_in_udp.rb +0 -296
- data/test/plugin/test_in_unix.rb +0 -181
- data/test/plugin/test_input.rb +0 -137
- data/test/plugin/test_metadata.rb +0 -89
- data/test/plugin/test_metrics.rb +0 -294
- data/test/plugin/test_metrics_local.rb +0 -96
- data/test/plugin/test_multi_output.rb +0 -204
- data/test/plugin/test_out_copy.rb +0 -308
- data/test/plugin/test_out_exec.rb +0 -312
- data/test/plugin/test_out_exec_filter.rb +0 -606
- data/test/plugin/test_out_file.rb +0 -1038
- data/test/plugin/test_out_forward.rb +0 -1349
- data/test/plugin/test_out_http.rb +0 -557
- data/test/plugin/test_out_null.rb +0 -105
- data/test/plugin/test_out_relabel.rb +0 -28
- data/test/plugin/test_out_roundrobin.rb +0 -146
- data/test/plugin/test_out_secondary_file.rb +0 -458
- data/test/plugin/test_out_stdout.rb +0 -205
- data/test/plugin/test_out_stream.rb +0 -103
- data/test/plugin/test_output.rb +0 -1334
- data/test/plugin/test_output_as_buffered.rb +0 -2024
- data/test/plugin/test_output_as_buffered_backup.rb +0 -363
- data/test/plugin/test_output_as_buffered_compress.rb +0 -179
- data/test/plugin/test_output_as_buffered_overflow.rb +0 -250
- data/test/plugin/test_output_as_buffered_retries.rb +0 -966
- data/test/plugin/test_output_as_buffered_secondary.rb +0 -882
- data/test/plugin/test_output_as_standard.rb +0 -374
- data/test/plugin/test_owned_by.rb +0 -34
- data/test/plugin/test_parser.rb +0 -399
- data/test/plugin/test_parser_apache.rb +0 -42
- data/test/plugin/test_parser_apache2.rb +0 -47
- data/test/plugin/test_parser_apache_error.rb +0 -45
- data/test/plugin/test_parser_csv.rb +0 -200
- data/test/plugin/test_parser_json.rb +0 -244
- data/test/plugin/test_parser_labeled_tsv.rb +0 -160
- data/test/plugin/test_parser_msgpack.rb +0 -127
- data/test/plugin/test_parser_multiline.rb +0 -111
- data/test/plugin/test_parser_nginx.rb +0 -88
- data/test/plugin/test_parser_none.rb +0 -52
- data/test/plugin/test_parser_regexp.rb +0 -284
- data/test/plugin/test_parser_syslog.rb +0 -650
- data/test/plugin/test_parser_tsv.rb +0 -122
- data/test/plugin/test_sd_file.rb +0 -228
- data/test/plugin/test_sd_srv.rb +0 -230
- data/test/plugin/test_storage.rb +0 -166
- data/test/plugin/test_storage_local.rb +0 -335
- data/test/plugin/test_string_util.rb +0 -26
- data/test/plugin_helper/data/cert/cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/cert-with-CRLF.pem +0 -19
- data/test/plugin_helper/data/cert/cert-with-no-newline.pem +0 -19
- data/test/plugin_helper/data/cert/cert.pem +0 -19
- data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +0 -20
- data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/cert_chains/cert.pem +0 -40
- data/test/plugin_helper/data/cert/empty.pem +0 -0
- data/test/plugin_helper/data/cert/generate_cert.rb +0 -125
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +0 -30
- data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +0 -20
- data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +0 -20
- data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +0 -30
- data/test/plugin_helper/data/cert/with_ca/cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +0 -21
- data/test/plugin_helper/data/cert/with_ca/cert.pem +0 -21
- data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +0 -30
- data/test/plugin_helper/data/cert/without_ca/cert-key.pem +0 -27
- data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +0 -20
- data/test/plugin_helper/data/cert/without_ca/cert.pem +0 -20
- data/test/plugin_helper/http_server/test_app.rb +0 -65
- data/test/plugin_helper/http_server/test_route.rb +0 -32
- data/test/plugin_helper/service_discovery/test_manager.rb +0 -93
- data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +0 -21
- data/test/plugin_helper/test_cert_option.rb +0 -25
- data/test/plugin_helper/test_child_process.rb +0 -862
- data/test/plugin_helper/test_compat_parameters.rb +0 -358
- data/test/plugin_helper/test_event_emitter.rb +0 -80
- data/test/plugin_helper/test_event_loop.rb +0 -52
- data/test/plugin_helper/test_extract.rb +0 -194
- data/test/plugin_helper/test_formatter.rb +0 -255
- data/test/plugin_helper/test_http_server_helper.rb +0 -372
- data/test/plugin_helper/test_inject.rb +0 -561
- data/test/plugin_helper/test_metrics.rb +0 -137
- data/test/plugin_helper/test_parser.rb +0 -264
- data/test/plugin_helper/test_record_accessor.rb +0 -238
- data/test/plugin_helper/test_retry_state.rb +0 -1006
- data/test/plugin_helper/test_server.rb +0 -1895
- data/test/plugin_helper/test_service_discovery.rb +0 -165
- data/test/plugin_helper/test_socket.rb +0 -146
- data/test/plugin_helper/test_storage.rb +0 -542
- data/test/plugin_helper/test_thread.rb +0 -164
- data/test/plugin_helper/test_timer.rb +0 -130
- data/test/scripts/exec_script.rb +0 -32
- data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +0 -7
- data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +0 -7
- data/test/scripts/fluent/plugin/formatter_known.rb +0 -8
- data/test/scripts/fluent/plugin/out_test.rb +0 -81
- data/test/scripts/fluent/plugin/out_test2.rb +0 -80
- data/test/scripts/fluent/plugin/parser_known.rb +0 -4
- data/test/test_capability.rb +0 -74
- data/test/test_clock.rb +0 -164
- data/test/test_config.rb +0 -369
- data/test/test_configdsl.rb +0 -148
- data/test/test_daemonizer.rb +0 -91
- data/test/test_engine.rb +0 -203
- data/test/test_event.rb +0 -531
- data/test/test_event_router.rb +0 -348
- data/test/test_event_time.rb +0 -199
- data/test/test_file_wrapper.rb +0 -53
- data/test/test_filter.rb +0 -121
- data/test/test_fluent_log_event_router.rb +0 -99
- data/test/test_formatter.rb +0 -369
- data/test/test_input.rb +0 -31
- data/test/test_log.rb +0 -1076
- data/test/test_match.rb +0 -148
- data/test/test_mixin.rb +0 -351
- data/test/test_msgpack_factory.rb +0 -50
- data/test/test_oj_options.rb +0 -55
- data/test/test_output.rb +0 -278
- data/test/test_plugin.rb +0 -251
- data/test/test_plugin_classes.rb +0 -370
- data/test/test_plugin_helper.rb +0 -81
- data/test/test_plugin_id.rb +0 -119
- data/test/test_process.rb +0 -14
- data/test/test_root_agent.rb +0 -951
- data/test/test_static_config_analysis.rb +0 -177
- data/test/test_supervisor.rb +0 -821
- data/test/test_test_drivers.rb +0 -136
- data/test/test_time_formatter.rb +0 -301
- data/test/test_time_parser.rb +0 -362
- data/test/test_tls.rb +0 -65
- data/test/test_unique_id.rb +0 -47
- data/test/test_variable_store.rb +0 -65
@@ -1,697 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
require 'fluent/plugin/filter_grep'
|
3
|
-
require 'fluent/test/driver/filter'
|
4
|
-
|
5
|
-
class GrepFilterTest < Test::Unit::TestCase
|
6
|
-
include Fluent
|
7
|
-
|
8
|
-
setup do
|
9
|
-
Fluent::Test.setup
|
10
|
-
@time = event_time
|
11
|
-
end
|
12
|
-
|
13
|
-
def create_driver(conf = '')
|
14
|
-
Fluent::Test::Driver::Filter.new(Fluent::Plugin::GrepFilter).configure(conf)
|
15
|
-
end
|
16
|
-
|
17
|
-
sub_test_case 'configure' do
|
18
|
-
test 'check default' do
|
19
|
-
d = create_driver
|
20
|
-
assert_empty(d.instance.regexps)
|
21
|
-
assert_empty(d.instance.excludes)
|
22
|
-
end
|
23
|
-
|
24
|
-
test "regexpN can contain a space" do
|
25
|
-
d = create_driver(%[regexp1 message foo])
|
26
|
-
d.instance._regexp_and_conditions.each { |value|
|
27
|
-
assert_equal(Regexp.compile(/ foo/), value.pattern)
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
test "excludeN can contain a space" do
|
32
|
-
d = create_driver(%[exclude1 message foo])
|
33
|
-
d.instance._exclude_or_conditions.each { |value|
|
34
|
-
assert_equal(Regexp.compile(/ foo/), value.pattern)
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
sub_test_case "duplicate key" do
|
39
|
-
test "flat" do
|
40
|
-
conf = %[
|
41
|
-
regexp1 message test
|
42
|
-
regexp2 message test2
|
43
|
-
]
|
44
|
-
assert_raise(Fluent::ConfigError) do
|
45
|
-
create_driver(conf)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
test "section" do
|
49
|
-
conf = %[
|
50
|
-
<regexp>
|
51
|
-
key message
|
52
|
-
pattern test
|
53
|
-
</regexp>
|
54
|
-
<regexp>
|
55
|
-
key message
|
56
|
-
pattern test2
|
57
|
-
</regexp>
|
58
|
-
]
|
59
|
-
assert_raise(Fluent::ConfigError) do
|
60
|
-
create_driver(conf)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
test "mix" do
|
64
|
-
conf = %[
|
65
|
-
regexp1 message test
|
66
|
-
<regexp>
|
67
|
-
key message
|
68
|
-
pattern test
|
69
|
-
</regexp>
|
70
|
-
]
|
71
|
-
assert_raise(Fluent::ConfigError) do
|
72
|
-
create_driver(conf)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
test "and/regexp" do
|
77
|
-
conf = %[
|
78
|
-
<and>
|
79
|
-
<regexp>
|
80
|
-
key message
|
81
|
-
pattern test
|
82
|
-
</regexp>
|
83
|
-
<regexp>
|
84
|
-
key message
|
85
|
-
pattern test
|
86
|
-
</regexp>
|
87
|
-
</and>
|
88
|
-
]
|
89
|
-
assert_raise(Fluent::ConfigError) do
|
90
|
-
create_driver(conf)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
test "and/regexp, and/regexp" do
|
95
|
-
conf = %[
|
96
|
-
<and>
|
97
|
-
<regexp>
|
98
|
-
key message
|
99
|
-
pattern test
|
100
|
-
</regexp>
|
101
|
-
</and>
|
102
|
-
<and>
|
103
|
-
<regexp>
|
104
|
-
key message
|
105
|
-
pattern test
|
106
|
-
</regexp>
|
107
|
-
</and>
|
108
|
-
]
|
109
|
-
assert_raise(Fluent::ConfigError) do
|
110
|
-
create_driver(conf)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
test "regexp, and/regexp" do
|
115
|
-
conf = %[
|
116
|
-
<regexp>
|
117
|
-
key message
|
118
|
-
pattern test
|
119
|
-
</regexp>
|
120
|
-
<and>
|
121
|
-
<regexp>
|
122
|
-
key message
|
123
|
-
pattern test
|
124
|
-
</regexp>
|
125
|
-
</and>
|
126
|
-
]
|
127
|
-
assert_raise(Fluent::ConfigError) do
|
128
|
-
create_driver(conf)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
test "and/exclude" do
|
133
|
-
conf = %[
|
134
|
-
<and>
|
135
|
-
<exclude>
|
136
|
-
key message
|
137
|
-
pattern test
|
138
|
-
</exclude>
|
139
|
-
<exclude>
|
140
|
-
key message
|
141
|
-
pattern test
|
142
|
-
</exclude>
|
143
|
-
</and>
|
144
|
-
]
|
145
|
-
assert_raise(Fluent::ConfigError) do
|
146
|
-
create_driver(conf)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
test "and/exclude, and/exclude" do
|
151
|
-
conf = %[
|
152
|
-
<and>
|
153
|
-
<exclude>
|
154
|
-
key message
|
155
|
-
pattern test
|
156
|
-
</exclude>
|
157
|
-
</and>
|
158
|
-
<and>
|
159
|
-
<exclude>
|
160
|
-
key message
|
161
|
-
pattern test
|
162
|
-
</exclude>
|
163
|
-
</and>
|
164
|
-
]
|
165
|
-
assert_raise(Fluent::ConfigError) do
|
166
|
-
create_driver(conf)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
test "exclude, or/exclude" do
|
171
|
-
conf = %[
|
172
|
-
<exclude>
|
173
|
-
key message
|
174
|
-
pattern test
|
175
|
-
</exclude>
|
176
|
-
<or>
|
177
|
-
<exclude>
|
178
|
-
key message
|
179
|
-
pattern test
|
180
|
-
</exclude>
|
181
|
-
</or>
|
182
|
-
]
|
183
|
-
assert_raise(Fluent::ConfigError) do
|
184
|
-
create_driver(conf)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
sub_test_case "pattern with slashes" do
|
190
|
-
test "start with character classes" do
|
191
|
-
conf = %[
|
192
|
-
<regexp>
|
193
|
-
key message
|
194
|
-
pattern /[a-z]test/
|
195
|
-
</regexp>
|
196
|
-
<exclude>
|
197
|
-
key message
|
198
|
-
pattern /[A-Z]test/
|
199
|
-
</exclude>
|
200
|
-
]
|
201
|
-
d = create_driver(conf)
|
202
|
-
assert_equal(/[a-z]test/, d.instance.regexps.first.pattern)
|
203
|
-
assert_equal(/[A-Z]test/, d.instance.excludes.first.pattern)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
sub_test_case "and/or section" do
|
208
|
-
test "<and> section cannot include both <regexp> and <exclude>" do
|
209
|
-
conf = %[
|
210
|
-
<and>
|
211
|
-
<regexp>
|
212
|
-
key message
|
213
|
-
pattern /test/
|
214
|
-
</regexp>
|
215
|
-
<exclude>
|
216
|
-
key level
|
217
|
-
pattern /debug/
|
218
|
-
</exclude>
|
219
|
-
</and>
|
220
|
-
]
|
221
|
-
assert_raise(Fluent::ConfigError) do
|
222
|
-
create_driver(conf)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
test "<or> section cannot include both <regexp> and <exclude>" do
|
227
|
-
conf = %[
|
228
|
-
<or>
|
229
|
-
<regexp>
|
230
|
-
key message
|
231
|
-
pattern /test/
|
232
|
-
</regexp>
|
233
|
-
<exclude>
|
234
|
-
key level
|
235
|
-
pattern /debug/
|
236
|
-
</exclude>
|
237
|
-
</or>
|
238
|
-
]
|
239
|
-
assert_raise(Fluent::ConfigError) do
|
240
|
-
create_driver(conf)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
sub_test_case 'filter_stream' do
|
247
|
-
def messages
|
248
|
-
[
|
249
|
-
"2013/01/13T07:02:11.124202 INFO GET /ping",
|
250
|
-
"2013/01/13T07:02:13.232645 WARN POST /auth",
|
251
|
-
"2013/01/13T07:02:21.542145 WARN GET /favicon.ico",
|
252
|
-
"2013/01/13T07:02:43.632145 WARN POST /login",
|
253
|
-
]
|
254
|
-
end
|
255
|
-
|
256
|
-
def filter(config, msgs)
|
257
|
-
d = create_driver(config)
|
258
|
-
d.run {
|
259
|
-
msgs.each { |msg|
|
260
|
-
d.feed("filter.test", @time, {'foo' => 'bar', 'message' => msg})
|
261
|
-
}
|
262
|
-
}
|
263
|
-
d.filtered_records
|
264
|
-
end
|
265
|
-
|
266
|
-
test 'empty config' do
|
267
|
-
filtered_records = filter('', messages)
|
268
|
-
assert_equal(4, filtered_records.size)
|
269
|
-
end
|
270
|
-
|
271
|
-
test 'regexpN' do
|
272
|
-
filtered_records = filter('regexp1 message WARN', messages)
|
273
|
-
assert_equal(3, filtered_records.size)
|
274
|
-
assert_block('only WARN logs') do
|
275
|
-
filtered_records.all? { |r|
|
276
|
-
!r['message'].include?('INFO')
|
277
|
-
}
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
test 'excludeN' do
|
282
|
-
filtered_records = filter('exclude1 message favicon', messages)
|
283
|
-
assert_equal(3, filtered_records.size)
|
284
|
-
assert_block('remove favicon logs') do
|
285
|
-
filtered_records.all? { |r|
|
286
|
-
!r['message'].include?('favicon')
|
287
|
-
}
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
test 'regexps' do
|
292
|
-
conf = %[
|
293
|
-
<regexp>
|
294
|
-
key message
|
295
|
-
pattern WARN
|
296
|
-
</regexp>
|
297
|
-
]
|
298
|
-
filtered_records = filter(conf, messages)
|
299
|
-
assert_equal(3, filtered_records.size)
|
300
|
-
assert_block('only WARN logs') do
|
301
|
-
filtered_records.all? { |r|
|
302
|
-
!r['message'].include?('INFO')
|
303
|
-
}
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
test 'excludes' do
|
308
|
-
conf = %[
|
309
|
-
<exclude>
|
310
|
-
key message
|
311
|
-
pattern favicon
|
312
|
-
</exclude>
|
313
|
-
]
|
314
|
-
filtered_records = filter(conf, messages)
|
315
|
-
assert_equal(3, filtered_records.size)
|
316
|
-
assert_block('remove favicon logs') do
|
317
|
-
filtered_records.all? { |r|
|
318
|
-
!r['message'].include?('favicon')
|
319
|
-
}
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
sub_test_case 'with invalid sequence' do
|
324
|
-
def messages
|
325
|
-
[
|
326
|
-
"\xff".force_encoding('UTF-8'),
|
327
|
-
]
|
328
|
-
end
|
329
|
-
|
330
|
-
test "don't raise an exception" do
|
331
|
-
assert_nothing_raised {
|
332
|
-
filter(%[regexp1 message WARN], ["\xff".force_encoding('UTF-8')])
|
333
|
-
}
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
sub_test_case "and/or section" do
|
338
|
-
def records
|
339
|
-
[
|
340
|
-
{ "time" => "2013/01/13T07:02:11.124202", "level" => "INFO", "method" => "GET", "path" => "/ping" },
|
341
|
-
{ "time" => "2013/01/13T07:02:13.232645", "level" => "WARN", "method" => "POST", "path" => "/auth" },
|
342
|
-
{ "time" => "2013/01/13T07:02:21.542145", "level" => "WARN", "method" => "GET", "path" => "/favicon.ico" },
|
343
|
-
{ "time" => "2013/01/13T07:02:43.632145", "level" => "WARN", "method" => "POST", "path" => "/login" },
|
344
|
-
]
|
345
|
-
end
|
346
|
-
|
347
|
-
def filter(conf, records)
|
348
|
-
d = create_driver(conf)
|
349
|
-
d.run do
|
350
|
-
records.each do |record|
|
351
|
-
d.feed("filter.test", @time, record)
|
352
|
-
end
|
353
|
-
end
|
354
|
-
d.filtered_records
|
355
|
-
end
|
356
|
-
|
357
|
-
test "basic and/regexp" do
|
358
|
-
conf = %[
|
359
|
-
<and>
|
360
|
-
<regexp>
|
361
|
-
key level
|
362
|
-
pattern ^INFO$
|
363
|
-
</regexp>
|
364
|
-
<regexp>
|
365
|
-
key method
|
366
|
-
pattern ^GET$
|
367
|
-
</regexp>
|
368
|
-
</and>
|
369
|
-
]
|
370
|
-
filtered_records = filter(conf, records)
|
371
|
-
assert_equal(records.values_at(0), filtered_records)
|
372
|
-
end
|
373
|
-
|
374
|
-
test "basic or/exclude" do
|
375
|
-
conf = %[
|
376
|
-
<or>
|
377
|
-
<exclude>
|
378
|
-
key level
|
379
|
-
pattern ^INFO$
|
380
|
-
</exclude>
|
381
|
-
<exclude>
|
382
|
-
key method
|
383
|
-
pattern ^GET$
|
384
|
-
</exclude>
|
385
|
-
</or>
|
386
|
-
]
|
387
|
-
filtered_records = filter(conf, records)
|
388
|
-
assert_equal(records.values_at(1, 3), filtered_records)
|
389
|
-
end
|
390
|
-
|
391
|
-
test "basic or/regexp" do
|
392
|
-
conf = %[
|
393
|
-
<or>
|
394
|
-
<regexp>
|
395
|
-
key level
|
396
|
-
pattern ^INFO$
|
397
|
-
</regexp>
|
398
|
-
<regexp>
|
399
|
-
key method
|
400
|
-
pattern ^GET$
|
401
|
-
</regexp>
|
402
|
-
</or>
|
403
|
-
]
|
404
|
-
filtered_records = filter(conf, records)
|
405
|
-
assert_equal(records.values_at(0, 2), filtered_records)
|
406
|
-
end
|
407
|
-
|
408
|
-
test "basic and/exclude" do
|
409
|
-
conf = %[
|
410
|
-
<and>
|
411
|
-
<exclude>
|
412
|
-
key level
|
413
|
-
pattern ^INFO$
|
414
|
-
</exclude>
|
415
|
-
<exclude>
|
416
|
-
key method
|
417
|
-
pattern ^GET$
|
418
|
-
</exclude>
|
419
|
-
</and>
|
420
|
-
]
|
421
|
-
filtered_records = filter(conf, records)
|
422
|
-
assert_equal(records.values_at(1, 2, 3), filtered_records)
|
423
|
-
end
|
424
|
-
|
425
|
-
sub_test_case "and/or combo" do
|
426
|
-
def records
|
427
|
-
[
|
428
|
-
{ "time" => "2013/01/13T07:02:11.124202", "level" => "INFO", "method" => "GET", "path" => "/ping" },
|
429
|
-
{ "time" => "2013/01/13T07:02:13.232645", "level" => "WARN", "method" => "POST", "path" => "/auth" },
|
430
|
-
{ "time" => "2013/01/13T07:02:21.542145", "level" => "WARN", "method" => "GET", "path" => "/favicon.ico" },
|
431
|
-
{ "time" => "2013/01/13T07:02:43.632145", "level" => "WARN", "method" => "POST", "path" => "/login" },
|
432
|
-
{ "time" => "2013/01/13T07:02:44.959307", "level" => "ERROR", "method" => "POST", "path" => "/login" },
|
433
|
-
{ "time" => "2013/01/13T07:02:45.444992", "level" => "ERROR", "method" => "GET", "path" => "/ping" },
|
434
|
-
{ "time" => "2013/01/13T07:02:51.247941", "level" => "WARN", "method" => "GET", "path" => "/info" },
|
435
|
-
{ "time" => "2013/01/13T07:02:53.108366", "level" => "WARN", "method" => "POST", "path" => "/ban" },
|
436
|
-
]
|
437
|
-
end
|
438
|
-
|
439
|
-
test "and/regexp, or/exclude" do
|
440
|
-
conf = %[
|
441
|
-
<and>
|
442
|
-
<regexp>
|
443
|
-
key level
|
444
|
-
pattern ^ERROR|WARN$
|
445
|
-
</regexp>
|
446
|
-
<regexp>
|
447
|
-
key method
|
448
|
-
pattern ^GET|POST$
|
449
|
-
</regexp>
|
450
|
-
</and>
|
451
|
-
<or>
|
452
|
-
<exclude>
|
453
|
-
key level
|
454
|
-
pattern ^WARN$
|
455
|
-
</exclude>
|
456
|
-
<exclude>
|
457
|
-
key method
|
458
|
-
pattern ^GET$
|
459
|
-
</exclude>
|
460
|
-
</or>
|
461
|
-
]
|
462
|
-
filtered_records = filter(conf, records)
|
463
|
-
assert_equal(records.values_at(4), filtered_records)
|
464
|
-
end
|
465
|
-
|
466
|
-
test "and/regexp, and/exclude" do
|
467
|
-
conf = %[
|
468
|
-
<and>
|
469
|
-
<regexp>
|
470
|
-
key level
|
471
|
-
pattern ^ERROR|WARN$
|
472
|
-
</regexp>
|
473
|
-
<regexp>
|
474
|
-
key method
|
475
|
-
pattern ^GET|POST$
|
476
|
-
</regexp>
|
477
|
-
</and>
|
478
|
-
<and>
|
479
|
-
<exclude>
|
480
|
-
key level
|
481
|
-
pattern ^WARN$
|
482
|
-
</exclude>
|
483
|
-
<exclude>
|
484
|
-
key method
|
485
|
-
pattern ^GET$
|
486
|
-
</exclude>
|
487
|
-
</and>
|
488
|
-
]
|
489
|
-
filtered_records = filter(conf, records)
|
490
|
-
assert_equal(records.values_at(1, 3, 4, 5, 7), filtered_records)
|
491
|
-
end
|
492
|
-
|
493
|
-
test "or/regexp, and/exclude" do
|
494
|
-
conf = %[
|
495
|
-
<or>
|
496
|
-
<regexp>
|
497
|
-
key level
|
498
|
-
pattern ^ERROR|WARN$
|
499
|
-
</regexp>
|
500
|
-
<regexp>
|
501
|
-
key method
|
502
|
-
pattern ^GET|POST$
|
503
|
-
</regexp>
|
504
|
-
</or>
|
505
|
-
<and>
|
506
|
-
<exclude>
|
507
|
-
key level
|
508
|
-
pattern ^WARN$
|
509
|
-
</exclude>
|
510
|
-
<exclude>
|
511
|
-
key method
|
512
|
-
pattern ^GET$
|
513
|
-
</exclude>
|
514
|
-
</and>
|
515
|
-
]
|
516
|
-
filtered_records = filter(conf, records)
|
517
|
-
assert_equal(records.values_at(0, 1, 3, 4, 5, 7), filtered_records)
|
518
|
-
end
|
519
|
-
|
520
|
-
test "or/regexp, or/exclude" do
|
521
|
-
conf = %[
|
522
|
-
<or>
|
523
|
-
<regexp>
|
524
|
-
key level
|
525
|
-
pattern ^ERROR|WARN$
|
526
|
-
</regexp>
|
527
|
-
<regexp>
|
528
|
-
key method
|
529
|
-
pattern ^GET|POST$
|
530
|
-
</regexp>
|
531
|
-
</or>
|
532
|
-
<or>
|
533
|
-
<exclude>
|
534
|
-
key level
|
535
|
-
pattern ^WARN$
|
536
|
-
</exclude>
|
537
|
-
<exclude>
|
538
|
-
key method
|
539
|
-
pattern ^GET$
|
540
|
-
</exclude>
|
541
|
-
</or>
|
542
|
-
]
|
543
|
-
filtered_records = filter(conf, records)
|
544
|
-
assert_equal(records.values_at(4), filtered_records)
|
545
|
-
end
|
546
|
-
|
547
|
-
test "regexp, and/regexp" do
|
548
|
-
conf = %[
|
549
|
-
<and>
|
550
|
-
<regexp>
|
551
|
-
key level
|
552
|
-
pattern ^ERROR|WARN$
|
553
|
-
</regexp>
|
554
|
-
<regexp>
|
555
|
-
key method
|
556
|
-
pattern ^GET|POST$
|
557
|
-
</regexp>
|
558
|
-
</and>
|
559
|
-
<regexp>
|
560
|
-
key path
|
561
|
-
pattern ^/login$
|
562
|
-
</regexp>
|
563
|
-
]
|
564
|
-
filtered_records = filter(conf, records)
|
565
|
-
assert_equal(records.values_at(3, 4), filtered_records)
|
566
|
-
end
|
567
|
-
|
568
|
-
test "regexp, or/exclude" do
|
569
|
-
conf = %[
|
570
|
-
<regexp>
|
571
|
-
key level
|
572
|
-
pattern ^ERROR|WARN$
|
573
|
-
</regexp>
|
574
|
-
<regexp>
|
575
|
-
key method
|
576
|
-
pattern ^GET|POST$
|
577
|
-
</regexp>
|
578
|
-
<or>
|
579
|
-
<exclude>
|
580
|
-
key level
|
581
|
-
pattern ^WARN$
|
582
|
-
</exclude>
|
583
|
-
<exclude>
|
584
|
-
key method
|
585
|
-
pattern ^GET$
|
586
|
-
</exclude>
|
587
|
-
</or>
|
588
|
-
]
|
589
|
-
filtered_records = filter(conf, records)
|
590
|
-
assert_equal(records.values_at(4), filtered_records)
|
591
|
-
end
|
592
|
-
|
593
|
-
test "regexp, and/exclude" do
|
594
|
-
conf = %[
|
595
|
-
<regexp>
|
596
|
-
key level
|
597
|
-
pattern ^ERROR|WARN$
|
598
|
-
</regexp>
|
599
|
-
<regexp>
|
600
|
-
key method
|
601
|
-
pattern ^GET|POST$
|
602
|
-
</regexp>
|
603
|
-
<and>
|
604
|
-
<exclude>
|
605
|
-
key level
|
606
|
-
pattern ^WARN$
|
607
|
-
</exclude>
|
608
|
-
<exclude>
|
609
|
-
key method
|
610
|
-
pattern ^GET$
|
611
|
-
</exclude>
|
612
|
-
</and>
|
613
|
-
]
|
614
|
-
filtered_records = filter(conf, records)
|
615
|
-
assert_equal(records.values_at(1, 3, 4, 5, 7), filtered_records)
|
616
|
-
end
|
617
|
-
end
|
618
|
-
end
|
619
|
-
end
|
620
|
-
|
621
|
-
sub_test_case 'nested keys' do
|
622
|
-
def messages
|
623
|
-
[
|
624
|
-
{"nest1" => {"nest2" => "INFO"}},
|
625
|
-
{"nest1" => {"nest2" => "WARN"}},
|
626
|
-
{"nest1" => {"nest2" => "WARN"}}
|
627
|
-
]
|
628
|
-
end
|
629
|
-
|
630
|
-
def filter(config, msgs)
|
631
|
-
d = create_driver(config)
|
632
|
-
d.run {
|
633
|
-
msgs.each { |msg|
|
634
|
-
d.feed("filter.test", @time, {'foo' => 'bar', 'message' => msg})
|
635
|
-
}
|
636
|
-
}
|
637
|
-
d.filtered_records
|
638
|
-
end
|
639
|
-
|
640
|
-
test 'regexps' do
|
641
|
-
conf = %[
|
642
|
-
<regexp>
|
643
|
-
key $.message.nest1.nest2
|
644
|
-
pattern WARN
|
645
|
-
</regexp>
|
646
|
-
]
|
647
|
-
filtered_records = filter(conf, messages)
|
648
|
-
assert_equal(2, filtered_records.size)
|
649
|
-
assert_block('only 2 nested logs') do
|
650
|
-
filtered_records.all? { |r|
|
651
|
-
r['message']['nest1']['nest2'] == 'WARN'
|
652
|
-
}
|
653
|
-
end
|
654
|
-
end
|
655
|
-
|
656
|
-
test 'excludes' do
|
657
|
-
conf = %[
|
658
|
-
<exclude>
|
659
|
-
key $.message.nest1.nest2
|
660
|
-
pattern WARN
|
661
|
-
</exclude>
|
662
|
-
]
|
663
|
-
filtered_records = filter(conf, messages)
|
664
|
-
assert_equal(1, filtered_records.size)
|
665
|
-
assert_block('only 2 nested logs') do
|
666
|
-
filtered_records.all? { |r|
|
667
|
-
r['message']['nest1']['nest2'] == 'INFO'
|
668
|
-
}
|
669
|
-
end
|
670
|
-
end
|
671
|
-
end
|
672
|
-
|
673
|
-
sub_test_case 'grep non-string jsonable values' do
|
674
|
-
def filter(msg, config = 'regexp1 message 0')
|
675
|
-
d = create_driver(config)
|
676
|
-
d.run do
|
677
|
-
d.feed("filter.test", @time, {'foo' => 'bar', 'message' => msg})
|
678
|
-
end
|
679
|
-
d.filtered_records
|
680
|
-
end
|
681
|
-
|
682
|
-
data(
|
683
|
-
'array' => ["0"],
|
684
|
-
'hash' => ["0" => "0"],
|
685
|
-
'integer' => 0,
|
686
|
-
'float' => 0.1)
|
687
|
-
test "value" do |data|
|
688
|
-
filtered_records = filter(data)
|
689
|
-
assert_equal(1, filtered_records.size)
|
690
|
-
end
|
691
|
-
|
692
|
-
test "value boolean" do
|
693
|
-
filtered_records = filter(true, %[regexp1 message true])
|
694
|
-
assert_equal(1, filtered_records.size)
|
695
|
-
end
|
696
|
-
end
|
697
|
-
end
|