- Issue created by @tstoeckler
- Merge request !12961Wait for cron to complete at the end of functional tests → (Open) created by tstoeckler
If a functional test installs the Automated Cron module and then performs some requests against those test sites, any of those requests may lead to cron being run. Since this happens outside of the actual test flow, cron may still not be completed when the test has completed and the test site is being torn down. This will then lead to database exceptions of the cron jobs because database tables they expect to exist no longer do.
Create a test that installs Umami (as that includes Automated Cron and Search) and only performs a single request and then finishes. Run that test on SQLite (not sure why that is required to reproduce this, but it seems to be) and be surprised that you will get, for example, the following exception:
Failed to log error: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1 no such table: test66738342.watchdog: INSERT INTO "test66738342"."watchdog" ("uid", "type", "message", "variables", "severity", "link", "location", "referer", "hostname", "timestamp") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?); Array
(
[0] => 0
[1] => cron
[2] => %type: @message in %function (line %line of %file).
[3] => a:6:{s:5:"%type";s:44:"Drupal\search\Exception\SearchIndexException";s:8:"@message";s:40:"Failed to update totals for index words.";s:9:"%function";s:46:"Drupal\search\SearchIndex->updateWordWeights()";s:5:"%file";s:74:".../core/modules/search/src/SearchIndex.php";s:5:"%line";i:292;s:17:"@backtrace_string";s:2705:"#0 .../core/modules/help/src/Plugin/Search/HelpSearch.php(372): Drupal\search\SearchIndex->updateWordWeights(Array)
Note that I was not able to reproduce this locally, thus far, but this Config Overlay CI job shows the problem.
Explicitly wait for cron to finish before tearing down the test site. (If you have any more elegant solutions for this, please share, I couldn't come up with anything...)
-
-
-
-
-
Active
11.0 🔥
phpunit