Page MenuHomePhabricator

Run browser tests in parallel
Open, Needs TriagePublic

Description

(Apologies if this is a duplicate, I know there's been some discussion already but couldn't find it in Phabricator.)

Browser tests are slow, and there are a few opportunities for parallelization. The easiest step would be to run our QUnit and node-selenium tests in separate threads. After T199116 we could also run selenium tests for each repo in parallel, but this introduces the additional challenge of potential interaction between tests.

However, there are some questions to work through first:

  • Can our test webserver handle multiple clients? (See also T225218.)
  • Is it reasonable to run multiple chromedrivers on one machine? How much more memory will this require?
  • How many of our tests will become fragile, for example because they depend on a constant rather than randomly-generated title?

Details

Related Changes in Gerrit:
SubjectRepoBranchLines +/-
mediawiki/extensions/Wikibasemaster+2 -0
mediawiki/extensions/ProofreadPagemaster+2 -1
mediawiki/extensions/CampaignEventsmaster+3 -2
mediawiki/extensions/GrowthExperimentsmaster+1 -0
mediawiki/extensions/Wikibasemaster+3 -3
mediawiki/extensions/PageTriagemaster+1 -0
integration/quibblemaster+46 -72
mediawiki/extensions/WikibaseLexememaster+2 -0
integration/quibblemaster+17 -0
mediawiki/extensions/CheckUsermaster+96 -9
mediawiki/extensions/VisualEditormaster+3 -1
mediawiki/extensions/Echomaster+3 -1
mediawiki/extensions/CheckUsermaster+3 -1
mediawiki/extensions/GrowthExperimentsmaster+1 -0
integration/quibblemaster+38 -3
mediawiki/coremaster+1 -1
mediawiki/extensions/AbuseFiltermaster+2 -1
mediawiki/skins/MinervaNeuemaster+3 -1
mediawiki/coremaster+2 -0
integration/quibblemaster+55 -7
integration/quibblemaster+145 -64
Show related patches Customize query in gerrit

Related Objects

StatusSubtypeAssignedTask
OpenNone
ResolvedFeaturekostajh
OpenNone
OpenNone
DeclinedNone
ResolvedNone
ResolvedNone
Resolvedawight
Resolvedkostajh
OpenNone
Resolvedcscott
Resolvedkostajh
Resolvedkostajh
Resolvedkostajh
Resolvedhashar
OpenNone
ResolvedPRODUCTION ERRORhoo
ResolvedLucas_Werkmeister_WMDE
ResolvedNone
ResolvedDreamy_Jazz
ResolvedKrinkle
Resolvedhashar
ResolvedNone
OpenPeter
OpenNone
ResolvedSpikezeljkofilipin
OpenSpikezeljkofilipin

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Change 751940 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/AbuseFilter@master] selenium: Run tests in each suite concurrently

https://gerrit.wikimedia.org/r/751940

Change 751942 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/WikibaseLexeme@master] selenium: Run tests in each suite concurrently

https://gerrit.wikimedia.org/r/751942

Change 751957 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/GrowthExperiments@master] selenium: Run test suites concurrently

https://gerrit.wikimedia.org/r/751957

Change 751959 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/core@master] selenium: Run test suites concurrently

https://gerrit.wikimedia.org/r/751959

Change 751961 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/core@master] api-testing: Run tests in parallel

https://gerrit.wikimedia.org/r/751961

Change 751940 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] selenium: Run test suites concurrently

https://gerrit.wikimedia.org/r/751940

Change 751959 abandoned by Kosta Harlan:

[mediawiki/core@master] selenium: Run test suites concurrently

Reason:

https://gerrit.wikimedia.org/r/751959

Change 754524 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/quibble@master] Release Quibble 1.3.0

https://gerrit.wikimedia.org/r/754524

Change 754524 merged by jenkins-bot:

[integration/quibble@master] Release Quibble 1.3.0

https://gerrit.wikimedia.org/r/754524

Change 768354 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[integration/quibble@master] [WIP] Run Selenium tests for each project in parallel

https://gerrit.wikimedia.org/r/768354

Change 768354 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[integration/quibble@master] [WIP] Run Selenium tests for each project in parallel

https://gerrit.wikimedia.org/r/768354

This is not a million miles off. Some observations:

  1. The Apache config needs tuning, as the "Server unavailable" error shows up a couple of times:

image.png (360×1 px, 103 KB)

  1. Some tests fail on first attempt due to interference of other tests (or due to the 503s noted above), but then they succeed due to the automatic retries in wdio. Not ideal, but it mostly seems to work out.
  2. Some tests need to be reworked slightly to be more robust. E.g. one of the Echo tests assumes the account isn't logged-in, but it is.
  3. Some tests simulate blocking a user and then other tests which use the same user fail, because the user is blocked (https://integration.wikimedia.org/ci/job/integration-quibble-fullrun-extensions/75/artifact/log/Lexeme%253AForms-can-edit-statements-on-a-new-Form-2022-03-06T21-57-01-255Z.mp4)

@zeljkofilipin I was wondering if we could consider using a single wdio.conf.js in mediawiki core that each extension references. That way, we'd get WDIO's parallelization for free, as it already supports concurrent test running, if it knows about all the tests that need to be run.

Core's wdio.conf.js file would need to be adjusted to look in extensions/skins:

	specs: [
		'./tests/selenium/specs/**/*.js',
                './extensions/**/tests/selenium/specs/**/*.js'
	],

and each extension/skin would have to migrate its wdio.conf.js contents into before/beforeEach methods in specFiles, rather than in wdio.conf.js

Having a single configuration file for MW core + extensions/skins seems more akin to how we do things for PHPUnit.

@zeljkofilipin I was wondering if we could consider using a single wdio.conf.js in mediawiki core that each extension references. That way, we'd get WDIO's parallelization for free, as it already supports concurrent test running, if it knows about all the tests that need to be run.

Core's wdio.conf.js file would need to be adjusted to look in extensions/skins:

	specs: [
		'./tests/selenium/specs/**/*.js',
                './extensions/**/tests/selenium/specs/**/*.js'
	],

and each extension/skin would have to migrate its wdio.conf.js contents into before/beforeEach methods in specFiles, rather than in wdio.conf.js

Having a single configuration file for MW core + extensions/skins seems more akin to how we do things for PHPUnit.

Note that if we do this, some Quibble changes would be necessary (cc @hashar) because Quibble currently assumes a wdio specific config for each extension/skin that contains a list of tests to run for just that extension/skin. And that's how Quibble knows, for example, to first run tests for the extension/skin under test. Although, if we are running everything together in parallel, I guess it's not so important anymore to run the extension/skin browser tests ahead of the other ones.

Although PHPUnit integration tests and QUnit are centrally set in mediawiki/core, webdriver.io tests are split in each repositories. That is the model also used for to the linters (which are run via composer test and npm test) and let us use different versions of webdriver.io. It is too challenging if not impossible to force migrate all repositories at the same time.

From the list of attached patches there are a few repositories for which tests are broken when run concurrently (see patches associated to this task: bug:T226869 is:open. I imagine if we ran tests from different extensions in parallel we would encounter even more issues.

@zeljkofilipin I was wondering if we could consider using a single wdio.conf.js in mediawiki core that each extension references.

Sorry, looks like I didn't reply to your question. 🤦‍♂️

As far as I remember, that's how we started with the webdriver tests. All configuration and dependencies were in core. That simplified some things (like having to update configuration in just one place, core) but vastly complicated some other things (like making a breaking change in core causing a lot of tests in a lot of repositories to fail). I forgot all the details, but I think the consensus was that having to do more work (like updating configuration/dependencies in each repository) was much better long-term than having everything centralized in core.

@hashar and @Krinkle might remember more details.

Change 751957 abandoned by Kosta Harlan:

[mediawiki/extensions/GrowthExperiments@master] selenium: Run test suites concurrently

Reason:

This is not going to be easy to implement, and not worthwhile at the moment given the relatively limited number of tests.

https://gerrit.wikimedia.org/r/751957

Change 934329 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/VisualEditor@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/934329

Change 934331 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Echo@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/934331

Change 934333 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/CheckUser@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/934333

Change 934333 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/934333

Change 934331 merged by jenkins-bot:

[mediawiki/extensions/Echo@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/934331

Change 934329 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/934329

Change 935162 had a related patch set uploaded (by Dreamy Jazz; author: WMDE-Fisch):

[mediawiki/extensions/CheckUser@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/935162

When crafting a small change to Selenium test https://gerrit.wikimedia.org/r/c/mediawiki/core/+/842391 the specs/recentchanges.js fail. It grabs the list of titles from recent change, pick the first title and fail cause another test created some other page so the expected title is no more the first in the entry. When looking at the captured output, I see the browser window creating pages with the title prefix BeforeEach-name-, however that does not come from spec/recentchanges.js but from specs/page.js!

In MediaWiki core I have set maxInstances: 4, what I suspect is that all four browser share the same X display and the video capture for a given test ends up having frame from another test running concurrently! I have no idea how to fix that though :)

Edit: I have filed the above as T344754: Browser tests video capture is shared between tests

Change 935162 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/935162

Change 747904 abandoned by Hashar:

[integration/quibble@master] BrowserTests: Support splitting projects into two groups

Reason:

https://gerrit.wikimedia.org/r/747904

Change 990648 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/PageTriage@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/990648

Change 990646 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/GrowthExperiments@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/990646

Change 990656 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/ProofreadPage@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/990656

Change 751942 abandoned by Kosta Harlan:

[mediawiki/extensions/WikibaseLexeme@master] selenium: Run tests in each suite concurrently

Reason:

https://gerrit.wikimedia.org/r/751942

Change 768354 abandoned by Kosta Harlan:

[integration/quibble@master] [WIP] Run Selenium tests for each project in parallel

Reason:

https://gerrit.wikimedia.org/r/768354

Change #990648 merged by jenkins-bot:

[mediawiki/extensions/PageTriage@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/990648

Change #990646 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/990646

Change #545650 abandoned by Hashar:

[mediawiki/extensions/Wikibase@master] selenium: run tests concurrently

Reason:

In favor of Ie27b50f0553039b81aa08942e19f61b6d4e77364

https://gerrit.wikimedia.org/r/545650

Change #1038401 had a related patch set uploaded (by Hashar; author: WMDE-Fisch):

[mediawiki/extensions/Wikibase@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/1038401

Change #1098569 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/1098569

Change #990656 abandoned by WMDE-Fisch:

[mediawiki/extensions/ProofreadPage@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/990656

Change #1038401 abandoned by WMDE-Fisch:

[mediawiki/extensions/Wikibase@master] selenium: run tests concurrently

https://gerrit.wikimedia.org/r/1038401

I am removing the Quibble tag, the Quibble CI images now use Apache as a frontend (T225218) and the CI jobs got switched to it (T285649).