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

Set process title of parallelized test workers #36443

Merged
merged 1 commit into from
Jul 6, 2019

Conversation

jhawthorn
Copy link
Member

@jhawthorn jhawthorn commented Jun 7, 2019

This sets the process title of the forked test workers in ActiveSupport::Testing::Parallelization.

This could help users to debug slow or hanging tests and provides a way to observe the running and progress of tests. But mostly, I think it's cool to watch inside top ⚡.

$ ps -o cmd= f
/bin/zsh
 \_ /home/jhawthorn/.gem/ruby/2.6.3/bin/rake test:template
     \_ /home/jhawthorn/github/github/vendor/ruby/300089b723cc69420cdbb406d27f5a2b8c4aef96/bin/ruby -w -Ilib:test -I/home/jhawthorn/.rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib /home/jhawthorn/.rubies/ruby-2.6.3/lib/ruby/gem
         \_ Rails test worker 0 - FormTagHelperTest#test_submit_tag_with_symbol_value
         \_ Rails test worker 1 - CachedViewRenderTest#test_render_partial_with_errors
         \_ Rails test worker 2 - (idle)
         \_ Rails test worker 3 - OptimizedFileSystemResolverTest#test_doesnt_find_template_with_wrong_details
         \_ Rails test worker 4 - FormTagHelperTest#test_time_field_tag
         \_ Rails test worker 5 - FormTagHelperTest#test_field_set_tag_in_erb

I don't think Rails has previously used setproctitle anywhere. For web requests the web server will do this for us (puma and unicorn do at least). However, I think it makes sense here. Rails has forked these process and runs this loop for its entire lifetime.

@jhawthorn jhawthorn force-pushed the as_parallelization_process_name branch from 40eca23 to 289c19f Compare June 7, 2019 22:29
@matthewd
Copy link
Member

matthewd commented Jun 8, 2019

Is "Rails test worker" more verbose than we want to be? setproctitle only has the number of characters in the original commandline to play with, and not everyone's ruby path is quite that long. 😄

I'm also slightly torn between using the test class + method as you have (which is probably nicer to read at a glance), and suggesting we might use the filename:lineno instead, which you might want to copy to a new runner if you see a child process get stuck, say.

@jhawthorn
Copy link
Member Author

setproctitle only has the number of characters in the original commandline to play with

Is this still a limitation on modern systems? Linux/BSDs implement setproctitle(3). AFAICT MacOS Mojave still relies on overwriting ARGV, but in my testing (Mojave/Ruby 2.6) I was able to set long titles using ruby -e '$0 = "a"*1000; sleep 4' 🤷‍♂. I'm open to making it shorter of course.

I'm also slightly torn between using the test class + method as you have (which is probably nicer to read at a glance), and suggesting we might use the filename:lineno instead, which you might want to copy to a new runner if you see a child process get stuck, say.

I chose "Class#method" to mirror running tests with --verbose, which is how I would previously (without parallelism) have detected which test would hang. Hopefully it's not a common enough problem to need to optimize developer experience for 😅

@jhawthorn jhawthorn merged commit 74ef67b into rails:master Jul 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants