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

[Draft] Various test-suite speed/reliability improvements #2241

Closed
wants to merge 1 commit into from

Conversation

wjordan
Copy link
Contributor

@wjordan wjordan commented Apr 29, 2020

Description

Spike with a bunch of different changes focused on improving the speed and reliability of the test suite. The goal was just to quickly experiment with running tests faster and with fewer flaky failures, and to share some of the high-level ideas for early discussion. Next step would be to break out the most useful fixes/changes into smaller PRs to be merged separately.

Highlights

  • Higher parallelization (increase MT_CPU from default 2 to 10)
  • Reduce duration of various sleeps and timeouts in tests (e.g., sleep 1 to sleep 0.01)
  • Replace UniquePort implementation with port 0 in all tests (UniquePort has a race condition that can cause intermittent port conflicts) (Stabilize CI testing? [changelog skip] #2270)

The following changes have since been broken out into separate smaller PRs:

Performance

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added an entry to History.md if this PR fixes a bug or adds a feature. If it doesn't need an entry to HISTORY.md, I have added [changelog skip] the pull request title.
  • I have added appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.

@@ -9,6 +9,8 @@ jobs:
env:
CI: true
TESTOPTS: -v
MT_CPU: 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiice.

require "timeout"
module TimeoutEveryTestCase
# our own subclass so we never confused different timeouts
class TestTookTooLong < Timeout::Error
end

def run(*)
::Timeout.timeout(RUBY_ENGINE == 'ruby' ? 60 : 120, TestTookTooLong) { super }
::Timeout.timeout(RUBY_ENGINE == 'ruby' ? 10 : 120, TestTookTooLong) { super }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DELICIOUS


require 'openssl'
# Silence warnings on SSLSocket initialization.
module SSLSocketFix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point me to where these warnings happen currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a Ruby 2.2 warning

@@ -10,30 +10,30 @@ class TestIntegration < Minitest::Test
TOKEN = "xxyyzz"
WORKERS = 2

BASE = defined?(Bundler) ? "bundle exec #{Gem.ruby} -Ilib" :
"#{Gem.ruby} -Ilib"
BASE = "#{Gem.ruby} -rrubygems -Ilib"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might break tests for people running locally. In CI it will be fine of course. Not sure if we can do this.

@@ -1,10 +1,16 @@
system "ruby -rrubygems -Ilib bin/puma -p 10102 -C test/shell/t1_conf.rb test/rackup/hello.ru &"
tcp_port = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #2240, I want to just get rid of this folder and replace with normal tests.

@@ -4,6 +4,7 @@

require "puma/app/status"
require "rack"
require "rack/mock"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required but not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this eliminated a 'circular require considered harmful' warning on Ruby 2.2.

@@ -44,22 +36,14 @@ def hit(uris)
end
end

module UniquePort
def self.call
TCPServer.open('127.0.0.1', 0) do |server|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES

@@ -2,15 +2,6 @@
# Copyright (c) 2011 Evan Phoenix
# Copyright (c) 2005 Zed A. Shaw

if %w(2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1).include? RUBY_VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... why though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move to lib I mean.

Copy link
Contributor Author

@wjordan wjordan Apr 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I saw integration tests running Puma in a subprocess still encountering this issue on Ruby2.2. Plus I figured it made sense to warn anyone on relevant Ruby versions possibly affected by this issue that weren't already using the gem.
Hopefully not super important though since 2.2 support probably won't last much longer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're doing a major release next, I'll revisit that policy. Dropping 2.2 especially would really help for SSL maintenance.

@nateberkopec
Copy link
Member

Gut reaction: yes, yes, and hell yes.

Ready to discuss these individually/in 100-line chunks when you are.

@wjordan
Copy link
Contributor Author

wjordan commented Sep 23, 2020

Returning to this draft after being idle for a while - I've updated the original description, crossing out items that have since been broken out into separate smaller PRs (and cross-referencing them). Next up I plan to rebase this PR to remove those parts that have been merged.

After that I plan to break out two final pieces into separate PRs:

After one more rebase, that should leave the test-suite speed improvements in this PR for review.

@nateberkopec
Copy link
Member

Nice to have you back @wjordan :)

@nateberkopec
Copy link
Member

@wjordan will close these for now, let me know if you want to come back to them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance waiting-for-changes Waiting on changes from the requestor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TestCLI#test_control failing with "pool_capacity": 0
2 participants