Skip to content

test in_tail: relax timeout limitation to receive events#2

Merged
kenhys merged 1 commit into
masterfrom
relax-timeout-waiting-event
Nov 20, 2020
Merged

test in_tail: relax timeout limitation to receive events#2
kenhys merged 1 commit into
masterfrom
relax-timeout-waiting-event

Conversation

@kenhys

@kenhys kenhys commented Nov 11, 2020

Copy link
Copy Markdown
Owner

It will fix the following error on windows.

Failure: test_emit_with_read_lines_limitflat 10
C:/projects/fluentd/test/plugin/test_in_tail.rb:243:in `test_emit_with_read_lines_limit'
240: end
241:
242: events = d.events
=> 243: assert_equal(true, events.length > 0)
244: assert_equal({"message" => msg}, events[0][2])
245: assert_equal({"message" => msg}, events[1][2])
246: assert num_events <= d.emit_count
expected but was

Which issue(s) this PR fixes:
Fixes #

What this PR does / why we need it:

Docs Changes:

Release Note:

Closes: fluent#3166

It will fix the following error on windows.

  Failure: test_emit_with_read_lines_limit[flat 10](TailInputTest::singleline)
  C:/projects/fluentd/test/plugin/test_in_tail.rb:243:in `test_emit_with_read_lines_limit'
       240:       end
       241:
       242:       events = d.events
    => 243:       assert_equal(true, events.length > 0)
       244:       assert_equal({"message" => msg}, events[0][2])
       245:       assert_equal({"message" => msg}, events[1][2])
       246:       assert num_events <= d.emit_count
  <true> expected but was
  <false>

Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
@kenhys kenhys force-pushed the relax-timeout-waiting-event branch from 871e06e to 6a7c8a6 Compare November 12, 2020 04:57
@kenhys kenhys merged commit 644ac50 into master Nov 20, 2020
@kenhys kenhys deleted the relax-timeout-waiting-event branch February 17, 2021 04:37
kenhys pushed a commit that referenced this pull request Apr 22, 2021
WindowsFile calls GetLastError via win32-api to retrieve win32 error
code but the error code may be already reset by Ruby's internal code
so that it can't retrive a correct error code. Sometimes it causes
random unrecoverable errors when in_tail plugin tries to read a
non-existent file like the following:

  2021-04-14 03:15:45 +0000 [error]: #2 Fluent::Win32Error code: 158, The segment is already unlocked.: C:/path/to/log.txt

Fiddle or FFI has a method to avoid this issue:

  * Fiddle.win32_last_error
    https://ruby-doc.org/stdlib-3.0.0/libdoc/fiddle/rdoc/Fiddle.html#method-c-win32_last_error
  * FFI::LastError.winapi_error
    https://www.rubydoc.info/github/ffi/ffi/FFI/LastError#winapi_error-instance_method

We've added an equivalent method for win32-api:

  cosmo0920/win32-api#55

This commit replaces the retrieving the error code with this method.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
kenhys pushed a commit that referenced this pull request Apr 22, 2021
WindowsFile calls GetLastError via win32-api to retrieve win32 error
code but the error code may be already reset by Ruby's internal code
so that it can't retrive a correct error code. Sometimes it causes
random unrecoverable errors when in_tail plugin tries to read a
non-existent file like the following:

  2021-04-14 03:15:45 +0000 [error]: #2 Fluent::Win32Error code: 158, The segment is already unlocked.: C:/path/to/log.txt

Fiddle or FFI has a method to avoid this issue:

  * Fiddle.win32_last_error
    https://ruby-doc.org/stdlib-3.0.0/libdoc/fiddle/rdoc/Fiddle.html#method-c-win32_last_error
  * FFI::LastError.winapi_error
    https://www.rubydoc.info/github/ffi/ffi/FFI/LastError#winapi_error-instance_method

We've added an equivalent method for win32-api:

  cosmo0920/win32-api#55

This commit replaces the retrieving the error code with this method.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant