Problem/Motivation
Followup from #3268010: Restore/Robustify \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest::testCustomBlock(). See approaches there that did not resolve the issue.
Steps to reproduce
Un-skip the method, run it alone 500x, and queue multiple test runs against MySQL/MariaDB environments.

Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
N/A
API changes
TBD
Data model changes
N/A
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | interdiff_36-41.txt | 1.18 KB | spokje |
| #41 | 3268244-41.patch | 1.21 KB | spokje |
| #34 | screen_QuickEditIntegrationTest_PRE_SAVE_PRESS_1652764911.png | 36.39 KB | spokje |
| #21 | screen_QuickEditIntegrationTest_CLUNK_1646747570.png | 36.37 KB | spokje |
Issue fork drupal-3268244
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:
- 3268244-random-test-failure
changes, plain diff MR !1945
Comments
Comment #2
xjmHere's the baseline patch for this test.
Comment #3
xjmComment #4
xjmOopsie.
Comment #5
xjmTest forcing a failure by lowering the timeout artificially (in case it's a race condition).
Comment #6
xjmMeh, newlines.
Comment #7
xjmSo #6 did not work as a way to ensure a fail.
There's this weird
hold_test_response()thing a few lines above the failing assertion; see related issue that added it.Comment #8
xjmMaybe?
Comment #9
xjmComment #10
xjmOK, that definitely does not work (or does work to ensure failure...).
Comment #11
xjmhold_test.moduleis not exactly suffering from an over-abundance of documentation. I am not quite sure how it is supposed to work.Comment #12
xjmJust trying to get the actual result output of that since the one test job I didn't cancel has now been requeued like 3x.
Comment #13
xjmSigh.
Comment #14
spokjeWhat we currently are doing around the point the test fails seems silly to me:
Wait for "state === 'closed'" and then assert that "state === 'closed'"?
I've had some success with the "fix" in the attached patch on a small scale.
Let's see how the fail rate of my approach (hopefully 0), compares to the baseline when we run both 1500x.
Comment #15
spokjeUnsure why this is against 9.3.x-dev, to prevent massive changing of platforms for testing temporarily moving this against 9.4.x-dev
Comment #16
spokjeMeh, that didn't matter at all...
Moving to
10.0.x-devwhere it should be IMHOComment #17
spokjeIf/When this lands into Core, we also have to commit this to the Contrib incarnation of quickedit.
Comment #18
spokjeHow about we do _not_ skip the test in the baseline patch... :/
Comment #19
spokjeSo, AFAICT:
- Saving a node through quickedit in a Test,
- When TestBot is really busy,
takes longer than expected, about 1/2 times every 1500 runs.
Let's see if upping the time-out in the assert where it all falls down helps. If not, I'm out of (my very limited) options.
Comment #20
spokjeUpping the time-out in the assert doesn't seem to do much.
So, what does the page look like when things go wrong?
Comment #21
spokjeSee attached screenshot on failing assert
Comment #22
spokjeComment #24
spokjeSo...
What's roughly going on AFAICT, is that the screenshot in #21 shows that sometimes the "QuickEdit Header" on the body-field stays open.
Everything else is doing it's stuff as it should, but the header means that the
EntityInstanceStateofnode/1[0]remains forever in the'closing'state, and thus preventing theto pass.
I really can't see where this is coming from, our code, backbone or underscore.
I see several options to go from here:
1) We accept that, on heavy load, this tests fails randomly sometimes.
2) We skip the test.
3) We fix the test
4) Something in the middle of the above.
Currently we're doing 2), not a big fan personally.
We tried 1), but with the new ChromeDriver the fails happen too often.
Of course, we _want_ 3), but seeing that we need JS expertise, which is probably currently all needed for the upcoming beta-deadline. Also the fact that quickedit will leave Core and currently has no maintainer doesn't bode well for this option.
The current MR and #22 is my version of 4): We wrap the (sometimes) failing asserts for "waiting on closed-state" and testing for that state in a
try, then have an emptycatchand wrap the last assertions, which, as shown by #22 are still valid, in afinally-block.This way we have no (semi-random) failures and still test that the main functionality of quickedit works without data-loss.
Of course we need a follow-up (and a
@todoreferring to it) to actually fix the issue someday, be it either here or in the Contrib incarnation of quickedit.Comment #25
spokjeChanging to
Needs reviewfor more eyes/thoughts on this.Comment #26
xjm@Spokje, it's filed against 9.3.x because as a critical bug in our test suite it needs to be backported to 9.3.x. That's what the version selector field indicates: which branches should receive the commit. Setting the branch to 10.0.x would mean the change was only allowed in a major version (e.g., a major dependency update or removing a deprecated API). That's not the case here.
Comment #27
xjmEmbedding the SS in the IS; thanks for that.
Comment #28
xjmQuickEditFileTesthas an identical fail and may need the same fix?https://www.drupal.org/pift-ci-job/2337360
Comment #29
spokjeSure looks like
QuickEditFileTesthas the same problem.Before applying the same method to that one as well, I think we should agree on this method (
catching theAssertionFailedErrorand basically hiding it) is an approach that we're OK with, until we (ever) come up with a real fix.So I would suggest before spending time on trying to fix/hide the test-failures in
QuickEditFileTestwe try to land this one first, if that happens we turn the spotlight onQuickEditFileTest.Comment #30
wim leers#14: That's because the first line has a timeout. The second one does not. IOW: the first tries to wait to reach that point, the second then asserts that we actually reached that state. I agree it's not pretty — but this was the best we could with the JS test infra do at the time.
#19 + #20: thanks for ruling that out as a possibility!
It sure is starting to look like this was caused by the recent
chromedriverupdate on DrupalCI? Or maybe that merely exposed this perhaps long-existing problem?#24:
\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditJavascriptTestBase::assertEntityInstanceStates()to know where that's coming from. Perhaps I'm misunderstanding your Q? It's in a Backbone collection that is controlled by Quick Edit's JS.Drupal.quickedit.EntityToolbarView) stays open even after saving is a bug. So either our test infra is more brittle than before or it's a bug in chromedriver or it's a race condition in Quick Edit's JS that didn't happen previously.Comment #31
spokjeComment #32
spokjeTime to try out the approach/solution we've found in #3280614: (Not so) Random test failures QuickEditFileTest, which in TLDR; is: Move the field that is QuickEdit-ed the last to the top of the displayed fields.
(TooShortWantToRead; https://www.drupal.org/project/drupal/issues/3280614#summary-possible-root-cause).
First up a patch that asserts the field states if the
$this->assertJsCondition("Drupal.quickedit.collections.entities.get('node/1[0]').get('state') === 'closed'");fails.It runs
\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest::testArticleNode()(and only that test) 1500 times.Looking at the screenshot I've attached earlier, we seem to have the same situation as #3280614: (Not so) Random test failures QuickEditFileTest , with the body being highlighted after a save on another field. If this is indeed the same we expect the following states after the above failure:
Comment #33
spokjeGrmbl, seems like the failure rate isn't that high (any more?)
Let's see if we can get a fail with a run of 2500 times.
Comment #34
spokjeSo, we (or at least I) learned 2 things here:
1) The failure rate is pretty low at this point in time.
2) We indeed match the expectation that the body field is in a highlighted state:
Looking at the screenshot I've uploaded we also match the criteria of #3280614: (Not so) Random test failures QuickEditFileTest with having the save button of the latest field to be QuickEdited (in this case field_tags) overlapping another QuickEditable field (in this case body). (Screenshot)
Comment #35
spokjeNow let's try a 2500x run of
\Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest::testArticleNode()without any changes and at the same time a 2500x run of the same test but with the field_tags moved above the body field.Also, in the moving-field_tags patch I've removed the
bit since, as mentioned in #14 the assertion above it (
$this->assertJsCondition("Drupal.quickedit.collections.entities.get('node/1[0]').get('state') === 'closed'");), already assures this is the case, and would fail otherwise.Comment #36
spokjeOk, fix seems to work, let's get a decent patch up.
Comment #38
spokjeComment #39
wim leersI understand your reasoning in #17. The intent of the
assertJsConditionis to wait.The intent of the assertion you removed is to show the evolution of this state throughout the phases of the test, using a consistent pattern. Removing this assertion breaks that consistent pattern.
So could you please revert this change? 🙏 Thanks 😊
Once that is reverted, this is RTBC IMO! 🥳
P.S.: nit:
s/QuickEdit/Quick Edit/
Comment #40
wim leersTagging because this fix is needed for #3267258: Remove Quick Edit support from editor.module.
Comment #41
spokjeWaiting for
condition === fooand then testing ifcondition === fooseems "odd" to me, but hey, if it brings this to RTBC, who am I to disagree (,I travelled the world and the seven seas, everybody's looking for something...)Comment #42
spokjeComment #43
wim leers… it also keeps the changes focused to the essence: make tests pass, don't change them.
Sorry, and … thank you 😊
Comment #45
catchThe filename was changed in #3264633: Remove \Drupal\layout_builder\QuickEditIntegration and refactor it so that quickedit contrib provides the integration with layout builder but I went ahead and renamed it in the patch too and it applies cleanly with that to 10.0.x and 9.5.x, then the original patch still applies against 9.4 - committed/pushed to all three branches, thanks!
Comment #48
spokjeTips hat @ catch
Comment #49
dww@catch: Looks like you never pushed a commit for this to 9.5.x, which is complicating progress at #3267258: Remove Quick Edit support from editor.module
Comment #50
dwwSorry, misread. See #44. ;) It's there.
Comment #52
spokjeRemoved the "Needs followup"-tag, since there are numerous issues fixing all test-failures in the contrib reincarnation of Quick Edit, so this one is handled in those.