Page MenuHomePhabricator

Improve e2e test flakiness
Closed, ResolvedPublic

Description

As we add more REST endpoints, the authorization e2e tests seem to become increasingly flaky.

Example (failures on two consecutive rechecks on https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/965682 PS2):

12:44:54   1) Auth
12:44:54        Authorization
12:44:54          Protected entity page
12:44:54            Permission denied - PATCH /entities/items/{item_id}/descriptions:
12:44:54 
12:44:54       AssertionError: 
12:44:54 7Response body: { en: 'random-test-description-LR5rdLQSeH' }8
12:44:54 Invalid status: expected 200 to equal 403      
12:44:54       actual expected
12:44:54       
12:44:54       200    403

This is likely due to a race condition between the API call protecting the entity under test and the following request that's expected to result in the permission error.

Possible solution: Check the entity protection status prior to making the second request and wait a few milliseconds if it's not protected yet.

Event Timeline

Change 966583 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: Add timeout if entity isn't protected yet in e2e Auth test

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

Change 966583 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add timeout and retry to flaky e2e test

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

@Physikerwelt if I see correctly in https://integration.wikimedia.org/ci/job/wmf-quibble-selenium-php81-docker/13968/console, the failed end to end test was not Wikibase REST API's but mediawiki one

21:32:37 [0-1] Error in "Wikitext Editor.Closing editor (browser button)"

OK, sorry @WMDE-leszek, there seem to be several problems, lately.
What about this one?
From https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/969510 (this evening) ->
https://integration.wikimedia.org/ci/job/mediawiki-quibble-apitests-vendor-php74-docker/45726/console

00:07:57.622   1 failing
00:07:57.622 
00:07:57.622   1) Auth
00:07:57.626        Authorization
00:07:57.626          Blocked user
00:07:57.626            cannot edit if blocked:
00:07:57.627 
00:07:57.627       AssertionError: 
00:07:57.627 7Response body: {
00:07:57.627   message: 'Error: exception of type Wikibase\\Repo\\RestApi\\Infrastructure\\DataAccess\\Exceptions\\EntityUpdateFailed: <Error, collected 2 message(s) on the way, array value set>\n' +
00:07:57.627     '+----------+---------------------------+--------------------------------------+\n' +
00:07:57.627     '| error    | blockedtext               | [[User:Mindyx5bvjoTilT|‪Mindyx5bvjoT |\n' +
00:07:57.627     '|          |                           | ilT‬]] | testing | 127.0.0.1 | ‪Mind |\n' +
00:07:57.627     '|          |                           | yx5bvjoTilT‬ | 24 | infinite | ‪Mind |\n' +
00:07:57.627     '|          |                           | yx5bvjoTilT‬ | 15:59, 29 October 202 |\n' +
00:07:57.627     '|          |                           | 3                                    |\n' +
00:07:57.628     '| error    | permissionserrors         |                                      |\n' +
00:07:57.628     '+----------+---------------------------+--------------------------------------+\n',

Change 969750 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/extensions/Wikibase@master] REST: Enable retries for flaky blocked user e2e test

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

Change 969750 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Enable retries for flaky blocked user e2e test

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