Skip to content

Use Local Webdriver for UI Tests in CI#65064

Merged
Hamms merged 62 commits into
stagingfrom
elijah/always-use-local-selenium-in-drone
Apr 14, 2025
Merged

Use Local Webdriver for UI Tests in CI#65064
Hamms merged 62 commits into
stagingfrom
elijah/always-use-local-selenium-in-drone

Conversation

@Hamms

@Hamms Hamms commented Apr 4, 2025

Copy link
Copy Markdown
Contributor

Specifically, I added a new --first-run-local flag to runner.rb, which tells it to use the local Selenium webdriver for the first run of a given test, and only use the configured webdriver (ie, Saucelabs) for reruns.

We can then use this flag in our CI tests to be a bit more efficient with our Saucelabs credits. We expect most tests to pass just fine with the local webdriver, but Saucelabs is more consistent and provides a better experience for debugging legitimate failures.

Also did a little miscellaneous cleanup while I was in the area:

  • Replaced a handful of instances of ENV['TEST_LOCAL'] == 'true' with a new helper method
  • Replaced a couple instances of ENV['CI'] with an existing helper method
  • Fixed some bugs in our SeleniumBrowser options
  • Bumped a version number that should have been updated as part of Use Latest Stable Chromedriver in CI #64444

Links

Related work:

Alternative to:

Testing story

Relying on CI tests to validate this CI-test-focused change. Note that running the local selenium webdriver alongside the puma server processes does result in slightly slower responses, which increases test flakiness slightly even for the reruns happening in Saucelabs. I deflaked a few tests in response and have been consistently getting green checkmarks since, despite multiple reruns; I think it is reasonably stable. We should be prepared to invest a bit more time in further deflaking if other engineers run into issues, though.

Also verified on Drone that this change does not noticeably impact total runtime of UI tests; see for example this run with the new logic disabled versus this run with it enabled.

Deployment strategy

We should plan to notify developers when this gets merged; warn them about the potential for increased flakiness, and ask them to speak up if they notice anything. If this change does cause issues, we can easily gate it behind a commit message flag while we resolve them.

Follow-up work

I'd like to add some kind of logging or metrics for tracking local runs vs saucelabs runs. In particular, I'd like for there to be a way for us to identify any tests that are consistently failing locally but consistently passing remotely.

Hamms added 30 commits March 10, 2025 13:25
…e do locally doesn't result in fewer total attempts against sauce
@Hamms Hamms changed the title Always use local selenium in drone Use Local Webdriver for UI Tests in CI Apr 8, 2025
@Hamms Hamms requested a review from a team April 8, 2025 23:40
@Hamms Hamms marked this pull request as ready for review April 9, 2025 18:34
@Hamms Hamms requested a review from a team as a code owner April 9, 2025 18:34

@cat5inthecradle cat5inthecradle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. I like the helper function renames. Excited to make this change!

@snickell snickell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yayyy! LGTM, its gonna be wild how much impact this should have on our saucelabs usage. I love resource usage efficiency fixes, I don't know why, but so satisfying.

Comment thread .drone.yml Outdated
from_secret: SAUCE_USERNAME
SAUCE_ACCESS_KEY:
from_secret: SAUCE_ACCESS_KEY
shm_size: '2gb' # necessary to avoid page crashes in Selenium

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wouldn't mind a comment (or a link back to a GH comment on this PR!) showing what these look like, in case somebody in the future needs to re-evaluate and say bump it up to 3gb or whatever.

Comment thread dashboard/test/ui/features/support/connect.rb
options.add_argument('window-size=1280,1024') if [:chrome, :firefox].include?(browser)
options.add_argument('headless') if headless
options.add_argument('--window-size=1280,1024') if [:chrome, :firefox].include?(browser)
options.add_argument('--headless') if headless

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not part of the review, just me being curious: were these not taking effect before without the -- being added?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They were working for Chrome, which I think is what most people use for manual local testing, but not for Firefox

@Hamms Hamms merged commit e1d1cfc into staging Apr 14, 2025
@Hamms Hamms deleted the elijah/always-use-local-selenium-in-drone branch April 14, 2025 23:44
Hamms added a commit that referenced this pull request Aug 1, 2025
Follow-up to #65064, which added logic to use a local webdriver for the first run of all UI and Eyes tests, only falling back to SauceLabs for any tests which fail that first run.

This PR adds a commit flag which can be used to selectively override that behavior if a developer has a specific reason to want even passing tests to run in SauceLabs (for example, if they want to share a video of a newly-added UI test running successfully).

[Slack thread](https://codedotorg.slack.com/archives/C08AMQ869QX/p1753933950644269)
Hamms added a commit that referenced this pull request Aug 11, 2025
* Allow Overriding Local Webdriver Tests

Follow-up to #65064, which added logic to use a local webdriver for the first run of all UI and Eyes tests, only falling back to SauceLabs for any tests which fail that first run.

This PR adds a commit flag which can be used to selectively override that behavior if a developer has a specific reason to want even passing tests to run in SauceLabs (for example, if they want to share a video of a newly-added UI test running successfully).

[Slack thread](https://codedotorg.slack.com/archives/C08AMQ869QX/p1753933950644269)

* restore accidentally-removed whitespace

* [skip local webdriver] empty commit to test new commit flag
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.

3 participants