Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for resque v1.26.0 #11

Merged
merged 6 commits into from
Feb 10, 2019

Conversation

nevans
Copy link

@nevans nevans commented Feb 7, 2019

This has been tested with all currently supported versions of ruby (2.3, 2.4, 2.5, and 2.6).

Major changes (as documented in 9815ab6):

  • Tests use normal fork and communicate with test runner via IO.pipe.
  • Tests uses a zero interval to exit ASAP without timeout when done.
  • Children need to exit! to avoid running test/unit at_exit hooks.
  • Gemspec depends on a specific minor version of resque.

We must depend on ~> v1.26.0, because these methods are considered
internal, are not a stable API, and can change with every version. I.e.
as written, the tests do not pass with v1.25.0 nor with v1.27.0. Until
Resque::Worker has a stable API we can target, this gem will need to be
tested with each minor release.

@nevans
Copy link
Author

nevans commented Feb 7, 2019

For what it's worth, now that I have working tests I'm going to fix it for v1.27.x and v2.0.x as well. Hopefully I'll send in PRs for those later today. I'd personally recommend three separate gem releases (e.g. v0.4.5 supports "~> v1.26.0", v.0.5.0 supports "~> v1.27.0", and v0.6.0 supports "~> 2.0.0"

@stulentsev
Copy link
Owner

@nevans do all tests pass for you? I get one failure in test_timeout_limit_sequence_of_events.

@jeremy
Copy link

jeremy commented Feb 7, 2019

Wow awesome @nevans. Thank you for tackling this!

@nevans
Copy link
Author

nevans commented Feb 7, 2019

@stulentsev yes, they all pass for me, using bundle exec rake test using Linux (Ubuntu), and ruby 2.3.8, 2.4.5, 2.5.3, and 2.6.0. Can you share your error output? I can try to reproduce in docker if that'd be better for repeatability.

@nevans
Copy link
Author

nevans commented Feb 7, 2019

@stulentsev I didn't see the issues in this branch, but I can get irregular failures for older rubies in the branches for #13 and #14. I think it must be due to race conditions, since the tests rely on sleep in different threads and processes. The tests are less likely to fail for me when run with VERBOSE=true.

One way to lazily avoid the race conditions would be to simply increase the sleep times. I'll try that first.

@nevans
Copy link
Author

nevans commented Feb 8, 2019

It does seem like there might be a bug in earlier ruby versions, where the TSTP signal is being missed or the child isn't shutting down after TermException + TSTP. That results in a SIGKILL (after term_timeout). I'll try to figure it out ASAP.

@nevans
Copy link
Author

nevans commented Feb 8, 2019

I'm still doing some more testing and trying to find some documentation for why this would be the case, but it currently seems to me that this can be fixed by simply changing the child shutdown signal from TSTP (terminal stop, e.g. what usually happens when you press ^Z) to QUIT (which does the same thing in normal resque: a graceful shutdown). TSTP is sometimes simply not seen by the child (and I don't know why). But QUIT always is.

* Tests use normal fork and communicate with test runner via IO.pipe.
* Tests uses a zero interval to exit ASAP without timeout when done.
* Children need to `exit!` to avoid running test/unit at_exit hooks.
* Gemspec depends on a specific minor version of resque.

We must depend on ~> v1.26.0, because these methods are considered
internal, are not a stable API, and can change with every version. I.e.
as written, the tests do not pass with v1.25.0 nor with v1.27.0. Until
Resque::Worker has a stable API we can target, this gem will need to be
tested with each minor release.
There's a lot of unhelpful noise that comes from running `ruby -w`:
https://mislav.net/2011/06/ruby-verbose-mode/
In tests, `SIGTSTP` is often ignored for ruby 2.3-2.5 (usually works in
2.6?). I assume this has something to do with some signals temporarily
being blocked by ruby, but I'm really not sure.  However, in my tests,
`SIGQUIT` always gets through to the handler.  Since `SIGQUIT` is
normally registered to call `shutdown` anyway, I've simply re-registered
it to continue that role in the `term_child` environment.
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.

None yet

3 participants