Problem/Motivation
Drupal\locale\Tests\LocaleUpdateTest->testUpdateImportSourceRemote() at line 150 with assertion message "Updates for Contrib module one".
The test asserts using the wrong timestamp. If the timestamps timestampNow and timestampNew set in \Drupal\locale\Tests\LocaleUpdateBase::setUp() the assert will fail. To reproduce the fail change your system clock to whatever time it would be exactly midnight in UTC+10 (for me that was 14:00:00). This is because in WebTestBase::setup() we do...
// Set an explicit time zone to not rely on the system one, which may vary
// from setup to setup. The Australia/Sydney time zone is chosen so all
// tests are run using an edge case scenario (UTC+10 and DST). This choice
// is made to prevent time zone related regressions and reduce the
// fragility of the testing system in general. This is also set in config in
// \Drupal\simpletest\WebTestBase::initConfig().
date_default_timezone_set('Australia/Sydney');
Proposed resolution
Use correct timestamp in assert.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #1
jhodgdonThis is one example if no one clicks retest:
https://qa.drupal.org/pifr/test/690123
Comment #2
star-szrJust combing through the majors, can this be closed now?
Comment #3
star-szrActually I found #2223459: Segmentation fault, Out of memory in LocaleUpdateTest and others so tentatively closing this as a duplicate.
Comment #4
tim.plunkettReopening since this failed today: https://www.drupal.org/pift-ci-job/517457
The issue this was marked duplicate of is now marked "cannot reproduce".
Comment #5
xjmThe fail can also be seen here:
https://www.drupal.org/pift-ci-job/521026
Comment #6
xjmA different random fail in the same test: https://www.drupal.org/pift-ci-job/526406
Comment #7
xjmComment #8
mpdonadioI am seeing lots of random fails in tests right now related to updates (eg, https://www.drupal.org/node/2627512#comment-11728075).
Wild thought. We have tests running in parallel. Patches with schema / container changes have empty update hooks to trigger a container rebuild. Are we getting fails because test A happens to be running while test B is doing a container rebuild in an update hook.
?
Comment #9
xjm#2828045: Tests failing with unrelated „Translation: The French translation is not available” is not the same issue, but also related to l.d.o.
Comment #10
xjmComment #11
xjmComment #12
xjmComment #13
xjm@catch, @alexpott, @effulgentsia, @Cottser, and I agreed that this is critical as a random test failure under normal circumstances in HEAD.
Comment #14
tacituseu commentedAnother case https://www.drupal.org/pift-ci-job/567927, from #2828559-117: UpdatePathTestBase tests randomly failing.
Comment #15
alexpottSo I'm pretty sure that this fail occurs when in \Drupal\locale\Tests\LocaleUpdateBase::setUp()...
and the $this->timestampNow and $this->timestampNew and on different days - i.e the test runs at 00:00:01 in whatever timezone the testbot PHP is configured to run in.
Comment #16
alexpottin
\Drupal\locale\Tests\LocaleUpdateBase::setTranslationFilesthe remote file is written with a timestamp based on$this->timestampNewwhereas the test is testing asserting on line 139 based on$this->timestampNow. Once the translation from the remote is downloaded the timestamp on the translation passes this assert...so that's perhaps how this fail occurred.
format_date($this->timestampNew, 'html_date')returns YEAR-MONTH-DAY so most of the time this test will pass.Comment #17
alexpottYep by playing with my system clock I managed to prove this... test on 8.2.x fails when my system clock is 14:00:00 and passes on the branch. yay.
Comment #18
alexpottComment #19
dawehnerGiven this bugfix, can we add some line of documentation why this value is preferred over the other?
Comment #20
mpdonadio[Possible crosspost]
I think that is an accurate assessment.
A few notes, though.
1. After lines 139-140 in testUpdateImportSourceRemote, there should be a negative assertions for the modules that shouldn't get updated. Prob OOS here?
2. Does line 156 also need to be adjusted
Seems like it should really be
so that it explicitly make sure the local version is chosen over the remote one. In scope?
3. It looks like lines 210-215 in testUpdateImportSourceLocal should also be adjusted to be more precise, but that may be OOS?
Comment #21
alexpottRe #20
1. Yep out-of-scope - nothing to do with the random error
2. Nope this does not need adjusting that assert is about the timestamp of the new local file that has been downloaded from the remote. The assertion is correct.
3. Yep out-of-scope.
In my mind this patch is complete and verified fix to the random fail.
Re #19 - it is not that is is preferred it is the correct value since it is the value used by the remote source as it's timestamp. The assertion in HEAD is just wrong.
Comment #22
mpdonadioI think the assessment of what is wrong is correct, and the patch in #15 is a good fix. I am also OK with the answers in #21.
Comment #24
alexpottRandom test fail fix subject to an unrelated random test fail :( #2844509: Random fails in BrowserTestBase tests with Operation timed out after 30001 milliseconds with 0 bytes
Comment #27
catchCommitted/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!
Comment #30
xjm