Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
On Ubuntu 12.04/PHP 5.5 and OS X Yosemite/PHP 5.6, I am currently getting one failing test when running all core phpunit tests with coverage reporting (--coverage-text
or --coverage-html
:
Time: 13.9 minutes, Memory: 246.00Mb
There was 1 failure:
1) Drupal\Tests\Core\Cache\ChainedFastBackendTest::testGetDoesntHitConsistentBackend
Drupal\Core\Cache\CacheBackendInterface::getMultiple(Array (...), false) was not expected to be called.
/var/www/drupal/core/lib/Drupal/Core/Cache/ChainedFastBackend.php:161
/var/www/drupal/core/lib/Drupal/Core/Cache/ChainedFastBackend.php:99
/var/www/drupal/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php:62
If I run the tests without coverage reporting, they complete normally.
Proposed resolution
Fix the failing report.
Remaining tasks
(done) Fix the failing report.
Beta phase evaluation
Issue category | This is a bug because it causes a unit test to fail under certain circumstances. |
---|---|
Issue priority | Issue is normal because the circumstances for failure aren't currently part of the automated test regime. |
Unfrozen changes | Unfrozen because it only changes an automated test, and makes it less fragile. |
Comment | File | Size | Author |
---|---|---|---|
#5 | 2373549-unitest-failure-in-coverage.patch | 1001 bytes | neclimdul |
Comments
Comment #1
geerlingguy CreditAttribution: geerlingguy commentedComment #2
geerlingguy CreditAttribution: geerlingguy commentedComment #3
geerlingguy CreditAttribution: geerlingguy commentedComment #4
geerlingguy CreditAttribution: geerlingguy commentedSee an example of the error in action: https://travis-ci.org/geerlingguy/drupal-travis-ci/builds/40711558#L1137
According to neclimdul, this might be caused by timing-based testing that fails when the test run is slower (running it with coverage reporting slows things down significantly).
Comment #5
neclimdulI was really confused when I started looking at this because running the individual test with coverage didn't cause the failure. Then I found it. Just a patch won't explain this so here's the break down.
In MemoryBackend
$item->created
is set like this:In the test, we set the timestamp data for the last write to this:
Since the tests are running for quite a while before this test gets run there is a large skew between REQUEST_TIME and time() and the comparison in ChainedFastBackend fails and it falls through to the consistent backend.
Comment #6
olli CreditAttribution: olli commented#5 makes sense. There is also #2277465: MemoryBackend cache->created should use millisecond precision.
Comment #7
geerlingguy CreditAttribution: geerlingguy commentedFixes the broken test for me; #2277465: MemoryBackend cache->created should use millisecond precision is somewhat related, but this patch should go in regardless (i.e. this test is broken in the way it's currently set up).
Comment #8
Mile23Added beta evaluation to the issue.
Comment #9
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 264b788 and pushed to 8.0.x. Thanks!