Skip to content

Commit

Permalink
test: try to get GVL tests to pass on macos and windows in CI
Browse files Browse the repository at this point in the history
- add one more sync to avoid deadlock on macos/windows in CI
- lower the expected loop count, it's much lower on macos and windows
  than on linux for some reason.
  • Loading branch information
flavorjones committed Apr 26, 2024
1 parent c71f8da commit a05da3c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/test_integration_pending.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ def test_busy_timeout
end

[
# 10 is the theoretical max if timeout is 100ms and active thread sleeps 10ms
# in practice this number is almost always 9, but let's leave a bit of room for randomness
{name: "test_busy_handler_timeout_releases_gvl", busy_handler_timeout: 100, expected_count: [:>=, 8]},
# 20 is the theoretical max if timeout is 100ms and active thread sleeps 10ms
# in CI, macos and windows systems seem to really not thread very well, so let's set a low non-zero bar
{name: "test_busy_handler_timeout_releases_gvl", busy_handler_timeout: 100, expected_count: [:>=, 3]},

# in practive this number is almost always 0, but it might squeak in 1 if the timing is juuuust right
{name: "test_busy_timeout_does_not_release_gvl", busy_timeout: 100, expected_count: [:<=, 1]}
].each do |test_case|
define_method test_case[:name] do
if test_case[:busy_handler_timeout]
@db.busy_handler_timeout = 100
@db.busy_handler_timeout = 200
end
if test_case[:busy_timeout]
@db.busy_timeout = test_case[:busy_timeout]
Expand Down Expand Up @@ -160,6 +160,7 @@ def test_busy_timeout
sync.send_to_main :ready
busy.lock
end
sync.send_to_main :done
ensure
db2&.close
end
Expand All @@ -173,9 +174,10 @@ def test_busy_timeout
end
t1sync.send_to_thread :end

assert_operator(count, *test_case[:expected_count])

busy.unlock
t2sync.wait_for_thread :done

assert_operator(count, *test_case[:expected_count])
ensure
active_thread&.join
blocking_thread&.join
Expand Down

0 comments on commit a05da3c

Please sign in to comment.