Sha256: 6b7319ab20d1fcc828c256f87929d0995970fd88052f68d740538ac9550ee57f

Contents?: true

Size: 1.57 KB

Versions: 18

Compression:

Stored size: 1.57 KB

Contents

require_relative '../helper'

require 'test-unit'
require 'win32/event' if Fluent.windows?

require 'fluent/command/ctl'

class TestFluentdCtl < ::Test::Unit::TestCase
  def assert_win32_event(event_name, command, pid_or_svcname)
    event = Win32::Event.new(event_name)
    ipc = Win32::Ipc.new(event.handle)
    ret = Win32::Ipc::TIMEOUT

    wait_thread = Thread.new do
      ret = ipc.wait(1)
    end
    Fluent::Ctl.new([command, pid_or_svcname]).call
    wait_thread.join
    assert_equal(Win32::Ipc::SIGNALED, ret)
  end

  data("shutdown" => ["shutdown", "TERM", ""],
       "restart" => ["restart", "HUP", "HUP"],
       "flush" => ["flush", "USR1", "USR1"],
       "reload" => ["reload", "USR2", "USR2"])
  def test_commands(data)
    command, signal, event_suffix = data

    if Fluent.windows?
      event_name = "fluentd_54321"
      event_name << "_#{event_suffix}" unless event_suffix.empty?
      assert_win32_event(event_name, command, "54321")
    else
      got_signal = false
      Signal.trap(signal) do
        got_signal = true
      end
      Fluent::Ctl.new([command, "#{$$}"]).call
      assert_true(got_signal)
    end
  end

  data("shutdown" => ["shutdown", ""],
       "restart" => ["restart", "HUP"],
       "flush" => ["flush", "USR1"],
       "reload" => ["reload", "USR2"])
  def test_commands_with_winsvcname(data)
    omit "Only for Windows" unless Fluent.windows?

    command, event_suffix = data
    event_name = "testfluentdwinsvc"
    event_name << "_#{event_suffix}" unless event_suffix.empty?

    assert_win32_event(event_name, command, "testfluentdwinsvc")
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
fluentd-1.15.3-x86-mingw32 test/command/test_ctl.rb
fluentd-1.15.3-x64-mingw-ucrt test/command/test_ctl.rb
fluentd-1.15.3-x64-mingw32 test/command/test_ctl.rb
fluentd-1.15.3 test/command/test_ctl.rb
fluentd-1.15.2-x86-mingw32 test/command/test_ctl.rb
fluentd-1.15.2-x64-mingw32 test/command/test_ctl.rb
fluentd-1.15.2-x64-mingw-ucrt test/command/test_ctl.rb
fluentd-1.15.2 test/command/test_ctl.rb
fluentd-1.15.1-x86-mingw32 test/command/test_ctl.rb
fluentd-1.15.1-x64-mingw32 test/command/test_ctl.rb
fluentd-1.15.1-x64-mingw-ucrt test/command/test_ctl.rb
fluentd-1.15.1 test/command/test_ctl.rb
fluentd-1.15.0-x86-mingw32 test/command/test_ctl.rb
fluentd-1.15.0-x64-mingw-ucrt test/command/test_ctl.rb
fluentd-1.15.0-x64-mingw32 test/command/test_ctl.rb
fluentd-1.15.0 test/command/test_ctl.rb
dtomasgu-fluentd-1.14.8.pre.dev test/command/test_ctl.rb
dtomasgu-fluentd-1.14.7.pre.dev test/command/test_ctl.rb