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
Just noticed this on https://www.drupal.org/pift-ci-job/518115
Migrate.Drupal\Tests\migrate\Kernel\process\CopyFileTest
✗
rupal\Tests\migrate\Kernel\process\CopyFileTe
exception: [Other] Line 0 of sites/default/files/simpletest/phpunit-1153.xml:
PHPunit Test failed to complete; Error: PHPUnit 4.8.27 by Sebastian Bergmann and contributors.
....E
Time: 5.37 seconds, Memory: 3.00Mb
There was 1 error:
1) Drupal\Tests\migrate\Kernel\process\CopyFileTest::testRenameFile
mkdir(): File exists
/var/www/html/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php:67
/var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:274
/var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:233
/var/www/html/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php:39
/var/www/html/core/modules/migrate/tests/src/Kernel/process/CopyFileTest.php:34
FAILURES!
Tests: 5, Assertions: 31, Errors: 1.
Proposed resolution
One option here is to convert to use VFS since this type of clash is totally impossible with that. Doesn't fix the root cause but will fix this fail.
By not using the FileTestBase parent class we use the default VFS of KernelTestBase.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Post #2783075: Add a "download" process plugin, remove remote capability from FileCopy
Comment | File | Size | Author |
---|---|---|---|
#22 | random_fail_in-2823400-21.patch | 2.25 KB | Ada Hernandez |
#22 | interdiff-16-21.txt | 767 bytes | Ada Hernandez |
#11 | interdiff-2823400-2-11.txt | 1.12 KB | hardikpandya |
#2 | 2823400-2.patch | 2.26 KB | alexpott |
Comments
Comment #2
alexpottThis is super amazing since it should be impossible for something to get the same test ID. We've done lots of work on that recently. The only thing I can think is somehow this is about container re-use. One option here is to convert to VFS since this type of clash is totally impossible with that. Doesn't fix the root cause but will fix this fail.
Comment #3
BerdirDid you actually mean to write random *file* or should it be random fail? :)
Comment #4
alexpottlol
Comment #5
catchIs the temp directory definitely different between test runs?
Comment #6
alexpott@catch I don't think it is but that's not the line that has failed. The line that has failed is:
And $this->siteDirectory is definitely unique to this test run since we did all the work with test IDs recently. However I think there might be a problem if a previous test has failed on the same test container and things are not being cleaned up properly.
Comment #7
phenaproximaAssigning to myself for grokking and review.
Comment #8
star-szrDiscussed with @xjm @effulgentsia @cilefen @catch, and we agreed that this is a critical issue because it's a random failure.
Comment #9
phenaproximaI'd rather this were
empty()
instead of isset(), to protect against anything falsy, but that's not a big deal.Ditto.
Why not use assertFileExists()?
Comment #10
phenaproximaTagging for novices -- all I need is my nitpicks in #9 fixed.
Comment #11
hardikpandya CreditAttribution: hardikpandya at Iksula commentedComment #13
Anonymous (not verified) CreditAttribution: Anonymous commented#11: fix typo
t()
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedfix similar places in other files
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedhah!) sorry! fix typo
!empty != !isset
too.Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #18
xjmComment #20
mikeryanYes, FileTestBase is a bit lax in specifying the visibility of its methods - but there's no reason we can't set this protected, is there?
Otherwise, if I'm understanding this correctly (by not extending FileTestBase we get KernelTestBase's VFS root, right?) this looks good. Setting off a bunch of tests just to be sure.
Comment #21
mikeryan8.2.x/PHP 5.5/SQLite got sibling random failure #2806697: Random fail for AlreadyInstalledException, retesting that one.
Comment #22
Ada Hernandez CreditAttribution: Ada Hernandez at MTech, LLC commentedI've updated the function like protected.
Comment #23
Ada Hernandez CreditAttribution: Ada Hernandez at MTech, LLC commentedComment #24
mikeryanThanks!
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commentedWe have a couple of similar places like #9:
We need or not need changes it in this issue too?
Comment #26
klausiI don't understand this patch. The exact same method exists on FileTestBase and FileTestBase is a kernel test already? Why should the issue be fixed by just copying a method? Can you explain the solution in the issue summary?
Comment #27
alexpottAdded explanation of how this fixes this to issue summary.
Comment #28
alexpottThis is how we switch to vfs...
Comment #29
klausiAh, sorry.
Comment #30
xjmSo this fixes the problem by working around a problem with
FileTestBase
, but what about all the other tests usingFileTestBase
? How do we ensure we don't introduce another fail like this in the future when someone else extends that class?Comment #31
xjmIt's not a small number; there are like 15 tests that extend
FileTestBase
. So if it has the potential to cause random fails because of how it interacts with the file system, I really think we should discuss it at least.Comment #32
catch@xjm we should discuss that but probably in a new issue? We might have more test cases to convert, we might end up deprecating the base class, but this specific change seems fine and removes one of 19 critical issues.
Comment #33
mikeryan@xjm - if catch's response makes sense to you, can you move back to RTBC?
Thanks.
Comment #34
alexpottWell only \Drupal\KernelTests\Core\File\DirectoryTest and \Drupal\KernelTests\Core\File\StreamWrapperTest fail if we remove FileTestBase::setUpFilesystem(). DirectoryTest fails because drupal_realpath() struggles with VFS here for some reason. The other test fails because of:
Comment #35
xjmI think we at least need a followup maybe?
Comment #36
heddnOpened follow-up #2845122: mkdir(): File exists in BrowserHtmlDebugTrait.php:141 during BrowserTestBase. Back to RTBC now we have the follow-up opened.
Comment #39
catchThanks for opening the follow-up.
Committed/pushed to 8.3.x and cherry-picked to 8.2.x, thanks!
Comment #42
xjmComment #44
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedIs this happening again? I have two recent examples, but decided to post the details on the open issue #2845122-5: mkdir(): File exists in BrowserHtmlDebugTrait.php:141 during BrowserTestBase