Problem/Motivation
Drupal\Tests\system\Functional\System\CronRunTest
fail: [Other] Line 0 of sites/default/files/simpletest/phpunit-1102.xml:
PHPUnit Test failed to complete; Error: PHPUnit 9.6.8 by Sebastian Bergmann and contributors.
Testing Drupal\Tests\system\Functional\System\CronRunTest
.F... 5 / 5 (100%)
Time: 00:24.576, Memory: 4.00 MB
There was 1 failure:
1) Drupal\Tests\system\Functional\System\CronRunTest::testAutomatedCron
Failed asserting that 1691657672 is less than 1691657672.
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:122
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55
/var/www/html/core/modules/system/tests/src/Functional/System/CronRunTest.php:82
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
I've seen it a few more times in the week or so than the two listed below
https://www.drupal.org/pift-ci-job/2737315
https://www.drupal.org/pift-ci-job/2734245
Proposed resolution
I _think_ in #4 I proved there's a race condition between the admin_user login triggering cron and updating its state, and this test doing the same thing.
I'm _sure_ using the \Drupal\Tests\WaitTerminateTestTrait solves whatever was wrong, see #5.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3380433
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:
- 3380433-random-test-failure
changes, plain diff MR !4581
Comments
Comment #2
spokjeLet's first see if this is reproducible with a patch that runs
\Drupal\Tests\system\Functional\System\CronRunTest::testAutomatedCron, and only that, 7500 times.Comment #3
spokjeComment #4
spokjeI think the patch in #3 with output like
proves that, although the config
automated_cron.settings.intervalis set to 100, at the moment of checking it in\Drupal\automated_cron\EventSubscriber\AutomatedCron::onTerminateit sometime is still the default 10800.The only reason I can think of why this would be happening is a race conditionsbetween the admin_user login triggering cron and updating its state, and this test doing the same thing.
Comment #5
spokjeLet's see if using
\Drupal\Tests\WaitTerminateTestTrait::setWaitForTerminatecan help us out here.Patch using that Trait and running
\Drupal\Tests\system\Functional\System\CronRunTest::testAutomatedCron, and only that, 7500 times attached together with the original 7500 patch from #2.Comment #6
spokje6 * 7500 = 45.000 failure free runs vs 7 failures in a non-patched 7500 run is good enough for me.
The actual patch will be in the MR.
Comment #8
spokjeComment #9
smustgrave commentedWooo!
Comment #10
longwaveCommitted eaca861 and pushed to 11.x. Thanks!