fluentd 1.15.3-x86-mingw32 → 1.16.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.yaml +1 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.yaml +1 -0
  4. data/.github/workflows/linux-test.yaml +2 -2
  5. data/.github/workflows/macos-test.yaml +2 -2
  6. data/.github/workflows/stale-actions.yml +24 -0
  7. data/.github/workflows/windows-test.yaml +2 -2
  8. data/CHANGELOG.md +114 -0
  9. data/CONTRIBUTING.md +1 -1
  10. data/MAINTAINERS.md +5 -3
  11. data/README.md +0 -1
  12. data/SECURITY.md +5 -9
  13. data/fluentd.gemspec +2 -2
  14. data/lib/fluent/command/fluentd.rb +55 -53
  15. data/lib/fluent/daemon.rb +2 -4
  16. data/lib/fluent/event.rb +2 -2
  17. data/lib/fluent/log/console_adapter.rb +66 -0
  18. data/lib/fluent/log.rb +35 -5
  19. data/lib/fluent/plugin/base.rb +5 -7
  20. data/lib/fluent/plugin/buf_file.rb +32 -3
  21. data/lib/fluent/plugin/buf_file_single.rb +32 -3
  22. data/lib/fluent/plugin/buffer/file_chunk.rb +1 -1
  23. data/lib/fluent/plugin/buffer.rb +21 -0
  24. data/lib/fluent/plugin/in_tcp.rb +47 -2
  25. data/lib/fluent/plugin/out_forward/ack_handler.rb +19 -4
  26. data/lib/fluent/plugin/out_forward.rb +2 -2
  27. data/lib/fluent/plugin/out_secondary_file.rb +39 -22
  28. data/lib/fluent/plugin/output.rb +49 -12
  29. data/lib/fluent/plugin_helper/http_server/server.rb +2 -1
  30. data/lib/fluent/plugin_helper/server.rb +8 -0
  31. data/lib/fluent/supervisor.rb +157 -251
  32. data/lib/fluent/test/driver/base.rb +11 -5
  33. data/lib/fluent/test/driver/filter.rb +4 -0
  34. data/lib/fluent/test/startup_shutdown.rb +6 -8
  35. data/lib/fluent/version.rb +1 -1
  36. data/templates/new_gem/test/helper.rb.erb +0 -1
  37. data/test/command/test_ctl.rb +1 -1
  38. data/test/command/test_fluentd.rb +137 -6
  39. data/test/command/test_plugin_config_formatter.rb +0 -1
  40. data/test/compat/test_parser.rb +5 -5
  41. data/test/config/test_system_config.rb +0 -8
  42. data/test/log/test_console_adapter.rb +110 -0
  43. data/test/plugin/out_forward/test_ack_handler.rb +39 -0
  44. data/test/plugin/test_base.rb +98 -0
  45. data/test/plugin/test_buf_file.rb +62 -23
  46. data/test/plugin/test_buf_file_single.rb +65 -0
  47. data/test/plugin/test_in_http.rb +2 -3
  48. data/test/plugin/test_in_monitor_agent.rb +2 -3
  49. data/test/plugin/test_in_tcp.rb +87 -2
  50. data/test/plugin/test_in_udp.rb +28 -0
  51. data/test/plugin/test_out_forward.rb +14 -18
  52. data/test/plugin/test_out_http.rb +1 -0
  53. data/test/plugin/test_output.rb +269 -0
  54. data/test/plugin/test_output_as_buffered_compress.rb +32 -18
  55. data/test/plugin/test_parser_regexp.rb +1 -6
  56. data/test/plugin_helper/test_http_server_helper.rb +1 -1
  57. data/test/plugin_helper/test_server.rb +59 -5
  58. data/test/test_config.rb +0 -21
  59. data/test/test_formatter.rb +23 -20
  60. data/test/test_log.rb +71 -36
  61. data/test/test_supervisor.rb +277 -282
  62. metadata +13 -19
  63. data/.drone.yml +0 -35
  64. data/.gitlab-ci.yml +0 -103
  65. data/test/test_logger_initializer.rb +0 -46
data/test/test_log.rb CHANGED
@@ -5,6 +5,7 @@ require 'fluent/log'
5
5
  require 'timecop'
6
6
  require 'logger'
7
7
  require 'securerandom'
8
+ require 'pathname'
8
9
 
9
10
  class LogTest < Test::Unit::TestCase
10
11
  def tmp_dir
@@ -33,6 +34,14 @@ class LogTest < Test::Unit::TestCase
33
34
  end
34
35
  end
35
36
 
37
+ def test_per_process_path
38
+ path = Fluent::Log.per_process_path("C:/tmp/test.log", :supervisor, 0)
39
+ assert_equal(path, "C:/tmp/test-supervisor-0.log")
40
+
41
+ path = Fluent::Log.per_process_path("C:/tmp/test.log", :worker, 1)
42
+ assert_equal(path, "C:/tmp/test-1.log")
43
+ end
44
+
36
45
  sub_test_case "log level" do
37
46
  data(
38
47
  trace: [Fluent::Log::LEVEL_TRACE, 0],
@@ -593,45 +602,71 @@ class LogTest < Test::Unit::TestCase
593
602
 
594
603
  def test_log_rotates_specified_size_with_logdevio
595
604
  with_timezone('utc') do
596
- rotate_age = 2
597
- rotate_size = 100
598
- path = "#{@tmp_dir}/log-dev-io-#{rotate_size}-#{rotate_age}"
599
- path0 = path + '.0'
600
- path1 = path + '.1'
605
+ begin
606
+ rotate_age = 2
607
+ rotate_size = 100
608
+ path = "#{@tmp_dir}/log-dev-io-#{rotate_size}-#{rotate_age}"
609
+ path0 = path + '.0'
610
+ path1 = path + '.1'
611
+
612
+ logdev = Fluent::LogDeviceIO.new(path, shift_age: rotate_age, shift_size: rotate_size)
613
+ logger = ServerEngine::DaemonLogger.new(logdev)
614
+ log = Fluent::Log.new(logger)
615
+
616
+ msg = 'a' * 101
617
+ log.info msg
618
+ assert_match msg, File.read(path)
619
+ assert_true File.exist?(path)
620
+ assert_true !File.exist?(path0)
621
+ assert_true !File.exist?(path1)
622
+
623
+ # create log.0
624
+ msg2 = 'b' * 101
625
+ log.info msg2
626
+ c = File.read(path)
627
+ c0 = File.read(path0)
628
+ assert_match msg2, c
629
+ assert_match msg, c0
630
+ assert_true File.exist?(path)
631
+ assert_true File.exist?(path0)
632
+ assert_true !File.exist?(path1)
633
+
634
+ # rotate
635
+ msg3 = 'c' * 101
636
+ log.info msg3
637
+ c = File.read(path)
638
+ c0 = File.read(path0)
639
+ assert_match msg3, c
640
+ assert_match msg2, c0
641
+ assert_true File.exist?(path)
642
+ assert_true File.exist?(path0)
643
+ assert_true !File.exist?(path1)
644
+ ensure
645
+ logdev&.close
646
+ end
647
+ end
648
+ end
601
649
 
602
- logdev = Fluent::LogDeviceIO.new(path, shift_age: rotate_age, shift_size: rotate_size)
603
- logger = ServerEngine::DaemonLogger.new(logdev)
604
- log = Fluent::Log.new(logger)
650
+ def test_reopen
651
+ path = Pathname(@tmp_dir) + "fluent.log"
605
652
 
606
- msg = 'a' * 101
607
- log.info msg
608
- assert_match msg, File.read(path)
609
- assert_true File.exist?(path)
610
- assert_true !File.exist?(path0)
611
- assert_true !File.exist?(path1)
653
+ logdev = Fluent::LogDeviceIO.new(path.to_s)
654
+ logger = ServerEngine::DaemonLogger.new(logdev)
655
+ log = Fluent::Log.new(logger, path: path)
612
656
 
613
- # create log.0
614
- msg2 = 'b' * 101
615
- log.info msg2
616
- c = File.read(path)
617
- c0 = File.read(path0)
618
- assert_match msg2, c
619
- assert_match msg, c0
620
- assert_true File.exist?(path)
621
- assert_true File.exist?(path0)
622
- assert_true !File.exist?(path1)
623
-
624
- # rotate
625
- msg3 = 'c' * 101
626
- log.info msg3
627
- c = File.read(path)
628
- c0 = File.read(path0)
629
- assert_match msg3, c
630
- assert_match msg2, c0
631
- assert_true File.exist?(path)
632
- assert_true File.exist?(path0)
633
- assert_true !File.exist?(path1)
634
- end
657
+ message = "This is test message."
658
+
659
+ log.info message
660
+ log.reopen!
661
+ log.info message
662
+
663
+ assert { path.read.lines.select{ |line| line.include?(message) }.size == 2 }
664
+ # Assert reopening the same file.
665
+ # Especially, on Windows, the filepath is fixed for each process with rotate,
666
+ # so we need to care about this.
667
+ assert { path.parent.entries.size == 3 } # [".", "..", "fluent.log"]
668
+ ensure
669
+ logdev&.close
635
670
  end
636
671
  end
637
672