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

Avoid Net::ReadTimeout errors in tests #3683

Merged
merged 1 commit into from
Sep 10, 2019
Merged

Avoid Net::ReadTimeout errors in tests #3683

merged 1 commit into from
Sep 10, 2019

Conversation

javierm
Copy link
Member

@javierm javierm commented Sep 5, 2019

Background

Since August the 7th, 2019, we're experiencing Net::ReadTimeout errors on almost every Travis build.

Debugging shows most (maybe all) of these errors come from requesting images to OpenStreetMap. Sometimes, due to an unreliable internet connection, the images take too long to load. The issue can be reproduced locally by limiting the bandwidth of the development machine with tools like wondershaper.

Objectives

Mock HTTP requests to fetch OpenStreetMap images, so we don't get any timeout errors, and tests work properly on machines with slow internet connections.

Notes

Here are the builds which have failed with the Net::ReadTimeout exception. Most (if not all) of these failures take place on pages loading the map.

Travis build 31262, job 1 and Travis build 31303, job 5

  1) Admin settings Should redirect to same tab after update setting map configuration On #tab-map-configuration
     Failure/Error: visit admin_settings_path
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/admin/settings_spec.rb:232:in `block (4 levels) in <top (required)>'

Travis build 31293, job 3

 1) Proposals behaves like mappable At edit_proposal_path Should edit default values from map on proposal edit page
     Failure/Error: visit send(mappable_edit_path, id: mappable.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     Shared Example Group: "mappable" called from ./spec/features/proposals_spec.rb:1657
     # ./spec/shared/features/mappable.rb:130:in `block (3 levels) in <top (required)>'
  1) Budget Investments behaves like mappable At new_management_budget_investment_path Toggle map
     Failure/Error: visit send(mappable_new_path, arguments)
     Net::ReadTimeout:
       Net::ReadTimeout
     Shared Example Group: "mappable" called from ./spec/features/management/budget_investments_spec.rb:12
     # ./spec/shared/features/mappable.rb:105:in `block (3 levels) in <top (required)>'

Travis build 31299, job 2

  1) Proposals behaves like mappable At proposal_path Should display map on proposal show page
     Failure/Error: visit send(mappable_show_path, arguments)
     Net::ReadTimeout:
       Net::ReadTimeout
     Shared Example Group: "mappable" called from ./spec/features/proposals_spec.rb:1657
     # ./spec/shared/features/mappable.rb:214:in `block (3 levels) in <top (required)>'

Travis build 31299, job 2 and Travis build 31320, job 3

  2) Budget Investments Balloting Phase Confirm
     Failure/Error: click_link "Global Group"
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/budgets/investments_spec.rb:1615:in `block (3 levels) in <top (required)>'

Travis build 31300, job 4, Travis build 31306, job 1, Travis build 31309, job 1 and Travis build 31320, job 3

  1) Budget Investments Index should show a map if heading has coordinates defined
     Failure/Error: visit budget_investments_path(budget, heading_id: heading.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/budgets/investments_spec.rb:158:in `block (2 levels) in <top (required)>'

Travis build 31309, job 1 and Travis build 31326, job 1

  1) Proposals behaves like mappable At edit_proposal_path Can not display map on proposal edit when remove map marker
     Failure/Error: visit send(mappable_edit_path, id: mappable.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     Shared Example Group: "mappable" called from ./spec/features/proposals_spec.rb:1657
     # ./spec/shared/features/mappable.rb:156:in `block (3 levels) in <top (required)>'

Travis build 31306, job 1

  2) Budget Investments Selecting Phase Popup alert to vote only in one heading per group When supporting in the first heading group
     Failure/Error: visit budget_investments_path(budget, heading_id: carabanchel.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/budgets/investments_spec.rb:1391:in `block (4 levels) in <top (required)>'

Travis build 31303, job 1 and Travis build 31322, job 3

  1) Budgets Index map Skip invalid map markers
     Failure/Error: visit budgets_path
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/budgets/budgets_spec.rb:367:in `block (3 levels) in <top (required)>'

Travis build 31303, job 4

  1) Budget Investments behaves like mappable At management_budget_investment_path Should display map on budget_investment show page
     Failure/Error: visit send(mappable_show_path, arguments)
     Net::ReadTimeout:
       Net::ReadTimeout
     Shared Example Group: "mappable" called from ./spec/features/management/budget_investments_spec.rb:12
     # ./spec/shared/features/mappable.rb:214:in `block (3 levels) in <top (required)>'

Travis build 31311, job 2

 1) Proposals behaves like mappable At edit_proposal_path Should edit map on proposal and contain default values
     Failure/Error: visit send(mappable_edit_path, id: mappable.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     Shared Example Group: "mappable" called from ./spec/features/proposals_spec.rb:1657
     # ./spec/shared/features/mappable.rb:127:in `block (3 levels) in <top (required)>'

Travis build 31264, job 5, Travis build 31298, job 5, Travis build 31308, job 3, Travis build 31319, job 3, Travis build 31321, job 5, Travis build 31323, job 2, Travis build 31324, job 3 and Travis build 31325, job 1

 1) Admin budget phases Edit behaves like edit_translatable Manage translations Should show first available fallback when current locale translation does not exist For Budget::Phase
     Failure/Error: visit budgets_path
     Net::ReadTimeout:
       Net::ReadTimeout
     Shared Example Group: "edit_translatable" called from ./spec/features/admin/budget_phases_spec.rb:13
     # ./spec/shared/features/edit_translatable.rb:99:in `block (4 levels) in <top (required)>'

Travis build 31296, job 2, Travis build 31313, job 5 and Travis build 31319, job 2

  1) Ballots Back link after removing an investment from Ballot
     Failure/Error: visit budget_investments_path(budget, heading_id: new_york.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/budgets/ballots_spec.rb:508:in `block (2 levels) in <top (required)>'

Travis build 31313, job 5

1) Ballots Removing investments from ballot (sidebar)
     Got 0 failures and 2 other errors:
     1.1) Failure/Error: visit budget_investments_path(budget, heading_id: new_york.id)
          Net::ReadTimeout:
            Net::ReadTimeout
          # ./spec/features/budgets/ballots_spec.rb:475:in `block (2 levels) in <top (required)>'
     1.2) Failure/Error: @io.to_io.wait_readable(@read_timeout) or raise Net::ReadTimeout
          Net::ReadTimeout:
            Net::ReadTimeout

Travis build 31296, job 4

  1) Votes Investments Disable voting on investments
     Failure/Error: visit budget_investments_path(budget, heading_id: heading.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/budgets/votes_spec.rb:96:in `block (3 levels) in <top (required)>'

Travis build 31302, job 5 and Travis build 31311, job 5

  1) Moderate budget investments Hiding an investment's author
     Failure/Error: visit budget_investments_path(budget.id, heading_id: heading.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/moderation/budget_investments_spec.rb:42:in `block (2 levels) in <top (required)>'

Travis build 31306, job 5 and Travis build 31310, job 5

  1) Tags Turbolinks sanity check from budget heading's show
     Failure/Error: visit budget_investments_path(budget, heading_id: heading.id)
     Net::ReadTimeout:
       Net::ReadTimeout
     # ./spec/features/tags/budget_investments_spec.rb:135:in `block (2 levels) in <top (required)>'

@javierm javierm self-assigned this Sep 5, 2019
@javierm javierm changed the title Use capybara-webmock to avoid external requests Use capybara-webmock to avoid timeout errors Sep 5, 2019
@javierm javierm changed the title Use capybara-webmock to avoid timeout errors Avoid timeout errors in tests Sep 5, 2019
@javierm javierm changed the title Avoid timeout errors in tests Avoid Net::ReadTimeout errors in tests Sep 5, 2019
@@ -33,7 +33,9 @@

Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless no-sandbox window-size=1200,600) }
chromeOptions: {
args: %W[headless no-sandbox window-size=1200,600 proxy-server=127.0.0.1:#{Capybara::Webmock.port_number}]

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [112/110] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

@javierm javierm changed the base branch from master to inline_ckeditor September 6, 2019 20:30
@javierm javierm force-pushed the capybara_webmock branch 2 times, most recently from 89a68e9 to a784261 Compare September 7, 2019 10:56
The images from OpenStreetMap take a while to load, sometimes even
causing Net::ReadTimeout errors if the internet connection is slow. It's
happened a lot recently on Travis builds.

Using capybara-webmock we guarantee the test suite doesn't fail due to
network issues.
@javierm javierm changed the base branch from inline_ckeditor to master September 7, 2019 11:34
@javierm javierm merged commit 698b3dc into master Sep 10, 2019
@javierm javierm added this to Release 1.1.0 in Roadmap Sep 10, 2019
@javierm javierm deleted the capybara_webmock branch September 10, 2019 17:13
smarques pushed a commit to venetochevogliamo/consul that referenced this pull request Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Roadmap
  
Release 1.1.0
Development

Successfully merging this pull request may close these issues.

None yet

2 participants