fluentd 0.14.17-x86-mingw32 → 1.3.1-x86-mingw32

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.

Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +16 -5
  3. data/ADOPTERS.md +5 -0
  4. data/{ChangeLog → CHANGELOG.md} +495 -6
  5. data/CONTRIBUTING.md +5 -2
  6. data/GOVERNANCE.md +55 -0
  7. data/LICENSE +202 -0
  8. data/MAINTAINERS.md +7 -5
  9. data/README.md +17 -10
  10. data/bin/fluent-ca-generate +6 -0
  11. data/example/counter.conf +18 -0
  12. data/example/secondary_file.conf +3 -2
  13. data/fluentd.gemspec +3 -3
  14. data/lib/fluent/agent.rb +1 -1
  15. data/lib/fluent/command/binlog_reader.rb +11 -2
  16. data/lib/fluent/command/ca_generate.rb +181 -0
  17. data/lib/fluent/command/cat.rb +28 -15
  18. data/lib/fluent/command/debug.rb +4 -4
  19. data/lib/fluent/command/fluentd.rb +2 -2
  20. data/lib/fluent/command/plugin_config_formatter.rb +24 -2
  21. data/lib/fluent/command/plugin_generator.rb +26 -8
  22. data/lib/fluent/config/configure_proxy.rb +7 -1
  23. data/lib/fluent/config/dsl.rb +8 -5
  24. data/lib/fluent/config/element.rb +5 -0
  25. data/lib/fluent/config/literal_parser.rb +7 -1
  26. data/lib/fluent/config/types.rb +28 -2
  27. data/lib/fluent/config/v1_parser.rb +1 -2
  28. data/lib/fluent/configurable.rb +1 -0
  29. data/lib/fluent/counter.rb +23 -0
  30. data/lib/fluent/counter/base_socket.rb +46 -0
  31. data/lib/fluent/counter/client.rb +297 -0
  32. data/lib/fluent/counter/error.rb +86 -0
  33. data/lib/fluent/counter/mutex_hash.rb +163 -0
  34. data/lib/fluent/counter/server.rb +273 -0
  35. data/lib/fluent/counter/store.rb +205 -0
  36. data/lib/fluent/counter/validator.rb +145 -0
  37. data/lib/fluent/env.rb +1 -0
  38. data/lib/fluent/event_router.rb +1 -1
  39. data/lib/fluent/log.rb +119 -29
  40. data/lib/fluent/plugin/base.rb +12 -0
  41. data/lib/fluent/plugin/buf_file.rb +20 -16
  42. data/lib/fluent/plugin/buffer.rb +130 -32
  43. data/lib/fluent/plugin/buffer/file_chunk.rb +23 -4
  44. data/lib/fluent/plugin/compressable.rb +1 -1
  45. data/lib/fluent/plugin/filter_grep.rb +135 -21
  46. data/lib/fluent/plugin/filter_parser.rb +13 -2
  47. data/lib/fluent/plugin/filter_record_transformer.rb +16 -14
  48. data/lib/fluent/plugin/formatter_stdout.rb +3 -2
  49. data/lib/fluent/plugin/formatter_tsv.rb +5 -1
  50. data/lib/fluent/plugin/in_debug_agent.rb +8 -1
  51. data/lib/fluent/plugin/in_forward.rb +1 -1
  52. data/lib/fluent/plugin/in_http.rb +84 -3
  53. data/lib/fluent/plugin/in_monitor_agent.rb +7 -1
  54. data/lib/fluent/plugin/in_syslog.rb +31 -10
  55. data/lib/fluent/plugin/in_tail.rb +142 -53
  56. data/lib/fluent/plugin/in_tcp.rb +5 -6
  57. data/lib/fluent/plugin/in_udp.rb +6 -2
  58. data/lib/fluent/plugin/in_unix.rb +1 -1
  59. data/lib/fluent/plugin/multi_output.rb +1 -0
  60. data/lib/fluent/plugin/out_copy.rb +25 -2
  61. data/lib/fluent/plugin/out_file.rb +26 -7
  62. data/lib/fluent/plugin/out_forward.rb +81 -42
  63. data/lib/fluent/plugin/out_secondary_file.rb +2 -2
  64. data/lib/fluent/plugin/out_stdout.rb +0 -1
  65. data/lib/fluent/plugin/out_stream.rb +1 -1
  66. data/lib/fluent/plugin/output.rb +221 -57
  67. data/lib/fluent/plugin/parser_apache.rb +1 -1
  68. data/lib/fluent/plugin/parser_apache2.rb +5 -1
  69. data/lib/fluent/plugin/parser_apache_error.rb +1 -1
  70. data/lib/fluent/plugin/parser_json.rb +10 -3
  71. data/lib/fluent/plugin/parser_ltsv.rb +7 -0
  72. data/lib/fluent/plugin/parser_multiline.rb +2 -1
  73. data/lib/fluent/plugin/parser_nginx.rb +1 -1
  74. data/lib/fluent/plugin/parser_none.rb +1 -0
  75. data/lib/fluent/plugin/parser_regexp.rb +15 -14
  76. data/lib/fluent/plugin/parser_syslog.rb +9 -5
  77. data/lib/fluent/plugin_helper.rb +2 -0
  78. data/lib/fluent/plugin_helper/cert_option.rb +28 -9
  79. data/lib/fluent/plugin_helper/compat_parameters.rb +3 -1
  80. data/lib/fluent/plugin_helper/counter.rb +51 -0
  81. data/lib/fluent/plugin_helper/event_loop.rb +9 -0
  82. data/lib/fluent/plugin_helper/record_accessor.rb +210 -0
  83. data/lib/fluent/plugin_helper/retry_state.rb +15 -7
  84. data/lib/fluent/plugin_helper/server.rb +87 -25
  85. data/lib/fluent/plugin_helper/socket_option.rb +5 -2
  86. data/lib/fluent/plugin_helper/timer.rb +8 -7
  87. data/lib/fluent/root_agent.rb +18 -9
  88. data/lib/fluent/supervisor.rb +63 -23
  89. data/lib/fluent/system_config.rb +30 -2
  90. data/lib/fluent/test/helpers.rb +1 -1
  91. data/lib/fluent/time.rb +15 -7
  92. data/lib/fluent/timezone.rb +26 -2
  93. data/lib/fluent/version.rb +1 -1
  94. data/templates/new_gem/README.md.erb +2 -2
  95. data/templates/new_gem/lib/fluent/plugin/filter.rb.erb +1 -1
  96. data/templates/new_gem/lib/fluent/plugin/input.rb.erb +1 -1
  97. data/templates/new_gem/lib/fluent/plugin/output.rb.erb +1 -1
  98. data/templates/new_gem/lib/fluent/plugin/parser.rb.erb +4 -4
  99. data/test/command/test_ca_generate.rb +70 -0
  100. data/test/command/test_fluentd.rb +2 -2
  101. data/test/command/test_plugin_config_formatter.rb +8 -7
  102. data/test/command/test_plugin_generator.rb +65 -39
  103. data/test/config/test_config_parser.rb +7 -2
  104. data/test/config/test_configurable.rb +7 -2
  105. data/test/config/test_configure_proxy.rb +41 -3
  106. data/test/config/test_dsl.rb +10 -10
  107. data/test/config/test_element.rb +10 -0
  108. data/test/config/test_literal_parser.rb +8 -0
  109. data/test/config/test_plugin_configuration.rb +56 -0
  110. data/test/config/test_system_config.rb +19 -1
  111. data/test/config/test_types.rb +37 -0
  112. data/test/counter/test_client.rb +559 -0
  113. data/test/counter/test_error.rb +44 -0
  114. data/test/counter/test_mutex_hash.rb +179 -0
  115. data/test/counter/test_server.rb +589 -0
  116. data/test/counter/test_store.rb +258 -0
  117. data/test/counter/test_validator.rb +137 -0
  118. data/test/plugin/test_buf_file.rb +124 -0
  119. data/test/plugin/test_buffer.rb +3 -2
  120. data/test/plugin/test_filter_grep.rb +580 -2
  121. data/test/plugin/test_filter_parser.rb +33 -2
  122. data/test/plugin/test_filter_record_transformer.rb +22 -1
  123. data/test/plugin/test_formatter_ltsv.rb +3 -0
  124. data/test/plugin/test_formatter_tsv.rb +68 -0
  125. data/test/plugin/test_in_debug_agent.rb +21 -0
  126. data/test/plugin/test_in_exec.rb +3 -5
  127. data/test/plugin/test_in_http.rb +178 -0
  128. data/test/plugin/test_in_monitor_agent.rb +1 -1
  129. data/test/plugin/test_in_syslog.rb +64 -0
  130. data/test/plugin/test_in_tail.rb +116 -6
  131. data/test/plugin/test_in_tcp.rb +21 -0
  132. data/test/plugin/test_in_udp.rb +78 -0
  133. data/test/plugin/test_metadata.rb +89 -0
  134. data/test/plugin/test_out_copy.rb +31 -0
  135. data/test/plugin/test_out_file.rb +108 -2
  136. data/test/plugin/test_out_forward.rb +195 -2
  137. data/test/plugin/test_out_secondary_file.rb +14 -0
  138. data/test/plugin/test_output.rb +159 -45
  139. data/test/plugin/test_output_as_buffered.rb +19 -0
  140. data/test/plugin/test_output_as_buffered_backup.rb +307 -0
  141. data/test/plugin/test_output_as_buffered_retries.rb +70 -0
  142. data/test/plugin/test_output_as_buffered_secondary.rb +1 -1
  143. data/test/plugin/test_parser_apache2.rb +1 -0
  144. data/test/plugin/test_parser_labeled_tsv.rb +17 -0
  145. data/test/plugin/test_parser_nginx.rb +40 -0
  146. data/test/plugin/test_parser_regexp.rb +6 -7
  147. data/test/plugin/test_parser_syslog.rb +155 -5
  148. data/test/plugin_helper/test_child_process.rb +4 -4
  149. data/test/plugin_helper/test_compat_parameters.rb +22 -0
  150. data/test/plugin_helper/test_record_accessor.rb +197 -0
  151. data/test/plugin_helper/test_retry_state.rb +20 -0
  152. data/test/plugin_helper/test_server.rb +30 -2
  153. data/test/test_config.rb +3 -3
  154. data/test/test_configdsl.rb +2 -2
  155. data/test/test_log.rb +51 -1
  156. data/test/test_root_agent.rb +33 -0
  157. data/test/test_supervisor.rb +105 -0
  158. metadata +68 -8
  159. data/COPYING +0 -14
@@ -5,11 +5,11 @@ require "fluent/plugin/parser"
5
5
  module Fluent
6
6
  module Plugin
7
7
  class <%= class_name %> < Fluent::Plugin::Parser
8
- Fluent::Plugin.register_parser("<%= name %>", self)
9
- end
8
+ Fluent::Plugin.register_parser("<%= plugin_name %>", self)
10
9
 
11
- def parse(text)
12
- yield time, record
10
+ def parse(text)
11
+ yield time, record
12
+ end
13
13
  end
14
14
  end
15
15
  end
@@ -0,0 +1,70 @@
1
+ require_relative '../helper'
2
+
3
+ require 'yajl'
4
+ require 'flexmock/test_unit'
5
+ require 'tmpdir'
6
+
7
+ require 'fluent/command/ca_generate'
8
+ require 'fluent/event'
9
+
10
+ class TestFluentCaGenerate < ::Test::Unit::TestCase
11
+ def test_generate_ca_pair
12
+ cert, key = Fluent::CaGenerate.generate_ca_pair(Fluent::CaGenerate::DEFAULT_OPTIONS)
13
+ assert_equal(OpenSSL::X509::Certificate, cert.class)
14
+ assert_true(key.private?)
15
+ end
16
+
17
+ def test_ca_generate
18
+ dumped_output = capture_stdout do
19
+ Dir.mktmpdir do |dir|
20
+ Fluent::CaGenerate.new([dir, "fluentd"]).call
21
+ assert_true(File.exist?(File.join(dir, "ca_key.pem")))
22
+ assert_true(File.exist?(File.join(dir, "ca_cert.pem")))
23
+ end
24
+ end
25
+ expected = <<TEXT
26
+ successfully generated: ca_key.pem, ca_cert.pem
27
+ copy and use ca_cert.pem to client(out_forward)
28
+ TEXT
29
+ assert_equal(expected, dumped_output)
30
+ end
31
+
32
+ sub_test_case "configure options" do
33
+ test "should respond multiple options" do
34
+ dumped_output = capture_stdout do
35
+ Dir.mktmpdir do |dir|
36
+ Fluent::CaGenerate.new([dir, "fluentd",
37
+ "--country", "JP", "--key-length", "4096",
38
+ "--state", "Tokyo", "--locality", "Chiyoda-ku",
39
+ "--common-name", "Forward CA"]).call
40
+ assert_true(File.exist?(File.join(dir, "ca_key.pem")))
41
+ assert_true(File.exist?(File.join(dir, "ca_cert.pem")))
42
+ end
43
+ end
44
+ expected = <<TEXT
45
+ successfully generated: ca_key.pem, ca_cert.pem
46
+ copy and use ca_cert.pem to client(out_forward)
47
+ TEXT
48
+ assert_equal(expected, dumped_output)
49
+ end
50
+
51
+ test "invalid options" do
52
+ Dir.mktmpdir do |dir|
53
+ assert_raise(OptionParser::InvalidOption) do
54
+ Fluent::CaGenerate.new([dir, "fluentd",
55
+ "--invalid"]).call
56
+ end
57
+ assert_false(File.exist?(File.join(dir, "ca_key.pem")))
58
+ assert_false(File.exist?(File.join(dir, "ca_cert.pem")))
59
+ end
60
+ end
61
+
62
+ test "empty options" do
63
+ assert_raise(SystemExit) do
64
+ capture_stdout do
65
+ Fluent::CaGenerate.new([]).call
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -494,14 +494,14 @@ CONF
494
494
  end
495
495
 
496
496
  test 'success to start the number of workers specified in configuration' do
497
- conf = <<CONF
497
+ conf = <<'CONF'
498
498
  <system>
499
499
  workers 2
500
500
  root_dir #{@root_path}
501
501
  </system>
502
502
  <source>
503
503
  @type dummy
504
- @id dummy
504
+ @id "dummy#{worker_id}" # check worker_id works or not with actual command
505
505
  @label @dummydata
506
506
  tag dummy
507
507
  dummy {"message": "yay!"}
@@ -132,6 +132,7 @@ helpers: inject,compat_parameters
132
132
  time_as_integer: bool: (false)
133
133
  slow_flush_log_threshold: float: (20.0)
134
134
  <buffer>: optional, single
135
+ chunk_keys: array: ([])
135
136
  @type: string: ("memory")
136
137
  timekey: time: (nil)
137
138
  timekey_wait: time: (600)
@@ -154,7 +155,7 @@ slow_flush_log_threshold: float: (20.0)
154
155
  retry_exponential_backoff_base: float: (2)
155
156
  retry_max_interval: time: (nil)
156
157
  retry_randomize: bool: (true)
157
- chunk_keys: : ([])
158
+ disable_chunk_backup: bool: (false)
158
159
  <secondary>: optional, single
159
160
  @type: string: (nil)
160
161
  <buffer>: optional, single
@@ -179,10 +180,10 @@ TEXT
179
180
  expected = <<TEXT
180
181
  ## Plugin helpers
181
182
 
182
- * inject
183
- * compat_parameters
183
+ * [inject](https://docs.fluentd.org/v1.0/articles/api-plugin-helper-inject)
184
+ * [compat_parameters](https://docs.fluentd.org/v1.0/articles/api-plugin-helper-compat_parameters)
184
185
 
185
- * See also: Fluent::Plugin::Input
186
+ * See also: [Input Plugin Overview](https://docs.fluentd.org/v1.0/articles/input-plugin-overview)
186
187
 
187
188
  ## TestFluentPluginConfigFormatter::SimpleInput
188
189
 
@@ -202,10 +203,10 @@ TEXT
202
203
  expected = <<TEXT
203
204
  ## Plugin helpers
204
205
 
205
- * inject
206
- * compat_parameters
206
+ * [inject](https://docs.fluentd.org/v1.0/articles/api-plugin-helper-inject)
207
+ * [compat_parameters](https://docs.fluentd.org/v1.0/articles/api-plugin-helper-compat_parameters)
207
208
 
208
- * See also: Fluent::Plugin::Output
209
+ * See also: [Output Plugin Overview](https://docs.fluentd.org/v1.0/articles/output-plugin-overview)
209
210
 
210
211
  ## TestFluentPluginConfigFormatter::ComplexOutput
211
212
 
@@ -16,51 +16,77 @@ class TestFluentPluginGenerator < Test::Unit::TestCase
16
16
  FileUtils.rm_rf(TEMP_DIR)
17
17
  end
18
18
 
19
- data(input: ["input", "in"],
20
- output: ["output", "out"],
21
- filter: ["filter", "filter"],
22
- parser: ["parser", "parser"],
23
- formatter: ["formatter", "formatter"])
24
- test "generate plugin" do |(type, part)|
25
- capture_stdout do
26
- FluentPluginGenerator.new([type, "fake"]).call
19
+ sub_test_case "generate plugin" do
20
+ data(input: ["input", "in"],
21
+ output: ["output", "out"],
22
+ filter: ["filter", "filter"],
23
+ parser: ["parser", "parser"],
24
+ formatter: ["formatter", "formatter"])
25
+ test "generate plugin" do |(type, part)|
26
+ capture_stdout do
27
+ FluentPluginGenerator.new([type, "fake"]).call
28
+ end
29
+ plugin_base_dir = Pathname("fluent-plugin-fake")
30
+ assert { plugin_base_dir.directory? }
31
+ expected = [
32
+ "fluent-plugin-fake",
33
+ "fluent-plugin-fake/Gemfile",
34
+ "fluent-plugin-fake/LICENSE",
35
+ "fluent-plugin-fake/README.md",
36
+ "fluent-plugin-fake/Rakefile",
37
+ "fluent-plugin-fake/fluent-plugin-fake.gemspec",
38
+ "fluent-plugin-fake/lib",
39
+ "fluent-plugin-fake/lib/fluent",
40
+ "fluent-plugin-fake/lib/fluent/plugin",
41
+ "fluent-plugin-fake/lib/fluent/plugin/#{part}_fake.rb",
42
+ "fluent-plugin-fake/test",
43
+ "fluent-plugin-fake/test/helper.rb",
44
+ "fluent-plugin-fake/test/plugin",
45
+ "fluent-plugin-fake/test/plugin/test_#{part}_fake.rb",
46
+ ]
47
+ actual = plugin_base_dir.find.reject {|f| f.fnmatch("*/.git*") }.map(&:to_s).sort
48
+ assert_equal(expected, actual)
27
49
  end
28
- plugin_base_dir = Pathname("fluent-plugin-fake")
29
- assert { plugin_base_dir.directory? }
30
- expected = [
31
- "fluent-plugin-fake",
32
- "fluent-plugin-fake/Gemfile",
33
- "fluent-plugin-fake/LICENSE",
34
- "fluent-plugin-fake/README.md",
35
- "fluent-plugin-fake/Rakefile",
36
- "fluent-plugin-fake/fluent-plugin-fake.gemspec",
37
- "fluent-plugin-fake/lib",
38
- "fluent-plugin-fake/lib/fluent",
39
- "fluent-plugin-fake/lib/fluent/plugin",
40
- "fluent-plugin-fake/lib/fluent/plugin/#{part}_fake.rb",
41
- "fluent-plugin-fake/test",
42
- "fluent-plugin-fake/test/helper.rb",
43
- "fluent-plugin-fake/test/plugin",
44
- "fluent-plugin-fake/test/plugin/test_#{part}_fake.rb",
45
- ]
46
- actual = plugin_base_dir.find.reject {|f| f.fnmatch("*/.git*") }.map(&:to_s).sort
47
- assert_equal(expected, actual)
48
- end
49
50
 
50
- test "no license" do
51
- capture_stdout do
52
- FluentPluginGenerator.new(["--no-license", "filter", "fake"]).call
51
+ test "no license" do
52
+ capture_stdout do
53
+ FluentPluginGenerator.new(["--no-license", "filter", "fake"]).call
54
+ end
55
+ assert { !Pathname("fluent-plugin-fake/LICENSE").exist? }
56
+ assert { Pathname("fluent-plugin-fake/Gemfile").exist? }
57
+ end
58
+
59
+ test "unknown license" do
60
+ out = capture_stdout do
61
+ assert_raise(SystemExit) do
62
+ FluentPluginGenerator.new(["--license=unknown", "filter", "fake"]).call
63
+ end
64
+ end
65
+ assert { out.lines.include?("License: unknown\n") }
53
66
  end
54
- assert { !Pathname("fluent-plugin-fake/LICENSE").exist? }
55
- assert { Pathname("fluent-plugin-fake/Gemfile").exist? }
56
67
  end
57
68
 
58
- test "unknown license" do
59
- out = capture_stdout do
60
- assert_raise(SystemExit) do
61
- FluentPluginGenerator.new(["--license=unknown", "filter", "fake"]).call
69
+ sub_test_case "unify plugin name" do
70
+ data("word" => ["fake", "fake"],
71
+ "underscore" => ["rewrite_tag_filter", "rewrite_tag_filter"],
72
+ "dash" => ["rewrite-tag-filter", "rewrite_tag_filter"])
73
+ test "plugin_name" do |(name, plugin_name)|
74
+ generator = FluentPluginGenerator.new(["filter", name])
75
+ capture_stdout do
76
+ generator.call
77
+ end
78
+ assert_equal(plugin_name, generator.__send__(:plugin_name))
79
+ end
80
+
81
+ data("word" => ["fake", "fluent-plugin-fake"],
82
+ "underscore" => ["rewrite_tag_filter", "fluent-plugin-rewrite-tag-filter"],
83
+ "dash" => ["rewrite-tag-filter", "fluent-plugin-rewrite-tag-filter"])
84
+ test "gem_name" do |(name, gem_name)|
85
+ generator = FluentPluginGenerator.new(["output", name])
86
+ capture_stdout do
87
+ generator.call
62
88
  end
89
+ assert_equal(gem_name, generator.__send__(:gem_name))
63
90
  end
64
- assert { out.lines.include?("License: unknown\n") }
65
91
  end
66
92
  end
@@ -35,6 +35,7 @@ module Fluent::Config
35
35
  config_param :param_time, :time
36
36
  config_param :param_hash, :hash
37
37
  config_param :param_array, :array
38
+ config_param :param_regexp, :regexp
38
39
  end
39
40
 
40
41
  class TestV1Parser < ::Test::Unit::TestCase
@@ -373,7 +374,7 @@ module Fluent::Config
373
374
  </elem2>
374
375
  ]
375
376
  write_config "#{TMP_DIR}/dir/config_test_9.conf", %[
376
- k9 embeded
377
+ k9 embedded
377
378
  <elem3 name>
378
379
  nested nested_value
379
380
  include hoge
@@ -417,7 +418,7 @@ module Fluent::Config
417
418
  elem2 = c.elements.find { |e| e.name == 'elem2' }
418
419
  assert(elem2)
419
420
  assert_equal('name', elem2.arg)
420
- assert_equal('embeded', elem2['k9'])
421
+ assert_equal('embedded', elem2['k9'])
421
422
  assert_not_include(elem2, 'include')
422
423
 
423
424
  elem3 = elem2.elements.find { |e| e.name == 'elem3' }
@@ -451,6 +452,7 @@ module Fluent::Config
451
452
  param_time 10m
452
453
  param_hash { "key1": "value1", "key2": 2 }
453
454
  param_array ["value1", "value2", 100]
455
+ param_regexp /pattern/
454
456
  ])
455
457
  target = AllTypes.new.configure(conf)
456
458
  assert_equal(conf.to_s, target.config.to_s)
@@ -465,6 +467,7 @@ module Fluent::Config
465
467
  param_time 10m
466
468
  param_hash {"key1":"value1","key2":2}
467
469
  param_array ["value1","value2",100]
470
+ param_regexp /pattern/
468
471
  </ROOT>
469
472
  DUMP
470
473
  assert_equal(expected, conf.to_s)
@@ -490,6 +493,7 @@ DUMP
490
493
  param_time 10m
491
494
  param_hash { "key1": "value1", "key2": 2 }
492
495
  param_array ["value1", "value2", 100]
496
+ param_regexp /pattern/
493
497
  ])
494
498
  target = AllTypes.new.configure(conf)
495
499
  assert_equal(conf.to_s, target.config.to_s)
@@ -504,6 +508,7 @@ DUMP
504
508
  param_time 10m
505
509
  param_hash { "key1": "value1", "key2": 2 }
506
510
  param_array ["value1", "value2", 100]
511
+ param_regexp /pattern/
507
512
  </ROOT>
508
513
  DUMP
509
514
  assert_equal(expected, conf.to_s)
@@ -508,6 +508,11 @@ module Fluent::Config
508
508
  assert_instance_of(ConfigurableSpec::Base2, b2.configure(config_element("", "", {"name1" => "t1", "name5" => "t5", "opt3" => "a"})))
509
509
  end
510
510
 
511
+ test 'can accept frozen string' do
512
+ b2 = ConfigurableSpec::Base2.new
513
+ assert_instance_of(ConfigurableSpec::Base2, b2.configure(config_element("", "", {"name1" => "t1".freeze, "name5" => "t5", "opt3" => "a"})))
514
+ end
515
+
511
516
  test 'raise errors without any specifications for param without defaults' do
512
517
  b2 = ConfigurableSpec::Base2.new
513
518
  assert_raise(Fluent::ConfigError) { b2.configure(config_element("", "", {})) }
@@ -1027,12 +1032,12 @@ module Fluent::Config
1027
1032
  detail_base = base.class.merged_configure_proxy.sections[:detail]
1028
1033
  detail_sub = sub.class.merged_configure_proxy.sections[:detail]
1029
1034
  detail_base_attributes = {
1030
- requried: detail_base.required,
1035
+ required: detail_base.required,
1031
1036
  multi: detail_base.multi,
1032
1037
  alias: detail_base.alias,
1033
1038
  }
1034
1039
  detail_sub_attributes = {
1035
- requried: detail_sub.required,
1040
+ required: detail_sub.required,
1036
1041
  multi: detail_sub.multi,
1037
1042
  alias: detail_sub.alias,
1038
1043
  }
@@ -193,9 +193,10 @@ module Fluent::Config
193
193
  assert_nothing_raised{ @proxy.config_param(:p7, :time, **opt) }
194
194
  assert_nothing_raised{ @proxy.config_param(:p8, :hash, **opt) }
195
195
  assert_nothing_raised{ @proxy.config_param(:p9, :array, **opt) }
196
+ assert_nothing_raised{ @proxy.config_param(:pa, :regexp, **opt) }
196
197
  end
197
198
 
198
- data(string: :string, integer: :integer, float: :float, size: :size, bool: :bool, time: :time, hash: :hash, array: :array)
199
+ data(string: :string, integer: :integer, float: :float, size: :size, bool: :bool, time: :time, hash: :hash, array: :array, regexp: :regexp)
199
200
  test 'deny list for non-enum types' do |type|
200
201
  assert_raise ArgumentError.new(":list is valid only for :enum type, but #{type}: arg") do
201
202
  @proxy.config_argument(:arg, type, list: [:a, :b])
@@ -205,7 +206,7 @@ module Fluent::Config
205
206
  end
206
207
  end
207
208
 
208
- data(string: :string, integer: :integer, float: :float, size: :size, bool: :bool, time: :time)
209
+ data(string: :string, integer: :integer, float: :float, size: :size, bool: :bool, time: :time, regexp: :regexp)
209
210
  test 'deny value_type for non-hash/array types' do |type|
210
211
  assert_raise ArgumentError.new(":value_type is valid only for :hash and :array, but #{type}: arg") do
211
212
  @proxy.config_argument(:arg, type, value_type: :string)
@@ -215,7 +216,7 @@ module Fluent::Config
215
216
  end
216
217
  end
217
218
 
218
- data(string: :string, integer: :integer, float: :float, size: :size, bool: :bool, time: :time, array: :array)
219
+ data(string: :string, integer: :integer, float: :float, size: :size, bool: :bool, time: :time, array: :array, regexp: :regexp)
219
220
  test 'deny symbolize_keys for non-hash types' do |type|
220
221
  assert_raise ArgumentError.new(":symbolize_keys is valid only for :hash, but #{type}: arg") do
221
222
  @proxy.config_argument(:arg, type, symbolize_keys: true)
@@ -434,6 +435,43 @@ module Fluent::Config
434
435
  assert_equal(expected, @proxy.dump_config_definition)
435
436
  end
436
437
 
438
+ test 'plain proxy w/ argument' do
439
+ @proxy.instance_eval do
440
+ config_argument(:argname, :string)
441
+ config_param(:name, :string, default: "name1")
442
+ end
443
+ expected = {
444
+ argname: { type: :string, required: true, argument: true },
445
+ name: { type: :string, default: "name1", required: false }
446
+ }
447
+ assert_equal(expected, @proxy.dump_config_definition)
448
+ end
449
+
450
+ test 'plain proxy w/ argument default value' do
451
+ @proxy.instance_eval do
452
+ config_argument(:argname, :string, default: "value")
453
+ config_param(:name, :string, default: "name1")
454
+ end
455
+ expected = {
456
+ argname: { type: :string, default: "value", required: false, argument: true },
457
+ name: { type: :string, default: "name1", required: false }
458
+ }
459
+ assert_equal(expected, @proxy.dump_config_definition)
460
+ end
461
+
462
+ test 'plain proxy w/ argument overwriting default value' do
463
+ @proxy.instance_eval do
464
+ config_argument(:argname, :string)
465
+ config_param(:name, :string, default: "name1")
466
+ config_set_default(:argname, "value1")
467
+ end
468
+ expected = {
469
+ argname: { type: :string, default: "value1", required: false, argument: true },
470
+ name: { type: :string, default: "name1", required: false }
471
+ }
472
+ assert_equal(expected, @proxy.dump_config_definition)
473
+ end
474
+
437
475
  test 'single sub proxy' do
438
476
  @proxy.config_section(:sub) do
439
477
  config_param(:name, :string, default: "name1")
@@ -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 embeded
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('embeded', elem2['k9'])
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