Problem/Motivation

Have seen this one pop up several times https://git.drupalcode.org/issue/drupal-3183509/-/jobs/4777988

Steps to reproduce

https://git.drupalcode.org/issue/drupal-3515404/-/jobs/4787495
https://git.drupalcode.org/issue/drupal-3515404/-/jobs/4787584
https://git.drupalcode.org/issue/drupal-3515404/-/jobs/4787672

Proposed resolution

Use WaitTerminateTestTrait

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3515404

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

acbramley created an issue. See original summary.

acbramley’s picture

Issue summary: View changes
mstrelan’s picture

// Test that logged in user does not get logged out in maintenance mode
// when hitting jsonapi route.
$this->container->get('state')->set('system.maintenance_mode', FALSE);
$this->drupalLogin($this->userCanViewProfiles);
$this->container->get('state')->set('system.maintenance_mode', TRUE);
$this->drupalGet('/jsonapi/taxonomy_term/tags');
$this->assertSession()->statusCodeEquals(503);

Sounds like state cache race condition. Probably needs WaitTerminateTestTrait.

mstrelan’s picture

Status: Active » Needs work

Repeat 1000 times:

Run 1 - 7/1000 fails
Run 2 - 14/1000 fails
Run 3 - 10/1000 fails

With WaitTerminateTestTrait:

Run 1 - 2/1000 fails
Run 2 (after moving setWaitForTerminate) - 0/1000 fails
Run 3 - 0/1000 fails

mstrelan changed the visibility of the branch 3515404-repeat to hidden.

mstrelan changed the visibility of the branch 3515404-repeat-fix to hidden.

mstrelan’s picture

Issue summary: View changes
Status: Needs work » Needs review

I forgot to actually commit the code for Run 1 with WaitTerminateTestTrait, which is why it had 2 fails. I've moved the setWaitForTerminate call where I intended it to be the first time and ran it again:

Run 4 - 0 fails

I've hidden the 2 test branches and opened a new branch (MR !11640) with only the fix. This is ready for review.

acbramley’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense, test is specifically testing maint mode which requires state and that requires the wait trait.

I wonder if there's an easy way to find tests using state that aren't using the wait trait yet 🤔

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed to 11.x

  • larowlan committed fc8a2834 on 11.x
    Issue #3515404 by mstrelan, acbramley: [random test failure]...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.