Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Assigned: Unassigned » phenaproxima

Self-assigning.

phenaproxima’s picture

Status: Active » Needs review
StatusFileSize
new2.3 KB

Here's a patch to run the test 500 times.

phenaproxima’s picture

StatusFileSize
new2.33 KB

Here's one where I actually run the test 500 times.

phenaproxima’s picture

StatusFileSize
new2.61 KB

Let's see if I can get this one to run...

phenaproxima’s picture

StatusFileSize
new2.59 KB

Okay; guess we'll just run the entire class 500 times.

Status: Needs review » Needs work

The last submitted patch, 6: 3268680-6-fail-500x.patch, failed testing. View results

phenaproxima’s picture

StatusFileSize
new3.1 KB

OK, definitely a random failure. Definitely still happening. Always failing on the same assertion.

My first suspicion here is that there is more than one Close button to be clicked. So this patch adds an assertion that there is only one Close button to press. Let's see if it fails.

phenaproxima’s picture

StatusFileSize
new3.16 KB

Let's try generically waiting for an AJAX request before clicking the Close button. My theory is that maybe, in some cases, it becomes visible and is clicked before its JavaScript behavior -- i.e., close the off-canvas area -- has loaded. That sort of race condition could certainly cause the kind of random failures we're seeing here.

phenaproxima’s picture

StatusFileSize
new3.13 KB

@bnjmnm directed me to #3268368-4: Robustify and restore \Drupal\Tests\ckeditor5\FunctionalJavascript\MediaLibraryTest::testButton, which offers a reasonable theory of what might be happening here. Therefore, this patch waits for the off-canvas area to be visible before trying to close it. Let's see if this helps stabilize the test.

xjm’s picture

Nice, thanks @phenaproxima. I think we have a winner.

We should re-run that with the baseline, but #10's results look pretty solid.

xjm credited bnjmmn.

xjm’s picture

Adding credit for Ben per #10.

xjm’s picture

StatusFileSize
new2.59 KB

Baseline patch and requeuing it with the above during the higher random fail window that seems to happen at night.

spokje’s picture

Status: Needs work » Needs review
StatusFileSize
new1.37 KB

So we have a baseline test failing (#14) and running at the same time, a non-failing fix patch (#10).

Also we have a PDGE(=Pretty Damn Good Explanation) on _why_ the fix patch works in (#10).

I've attached a patch from #10 _without_ the changes in core/drupalci.yml, so only containing the fix.

I'm unsure against which Drupal Core version this patch should be against, according to here 9.3.x-dev seems the way to go and then port upwards.
Personally I would aim at 10.0.x-dev for downwards porting.

Let's just keep the middle ground that is 9.4.x-dev and conveniently is already the version of this issue.

Seeing that this is a _random_ failure that occurs (seemingly) only when TestBot is really busy, this patch is very likely to NOT-fail.
There's no proof in that to conclude it is fixing the issue.
(At least for me) The proof is in the test runs mentioned above.

spokje’s picture

Assigned: phenaproxima » Unassigned
phenaproxima’s picture

Status: Needs review » Needs work

One thing I'd like to add before this is good to go is a comment above the line that fixes the test, so that we know why we're doing that and don't accidentally revert it, which is a big risk since the failure is random.

spokje’s picture

Status: Needs work » Needs review
StatusFileSize
new1.7 KB
new2.24 KB

Sense = made in #17.

Added new patch with comment.

phenaproxima’s picture

Thanks, Spokje; looks good to me. I can't RTBC, having written the patch, but I'll ping some people...

bnjmnm’s picture

Status: Needs review » Needs work
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
@@ -219,6 +218,12 @@ protected function assertContextualLinksClickable(): void {
+    $this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas'));

I'm concerned this won't be sufficient. The successful fix in #3268368: Robustify and restore \Drupal\Tests\ckeditor5\FunctionalJavascript\MediaLibraryTest::testButton accomplished this by wating for something more specific than the dialog wrapper ID. For example, if you use debugger; to pause execution at Drupal.offCanvasafterCreate.afterCreate, #drupal-off-canvas already exists, but the dialog hasn't been fully resized/repositioned (and interestingly, the close button is not yet rendered).

Based on just comparing the markup pre and post resize, the following selector *might* be a reliable way to check for something that appears after resize + draggable completes #drupal-off-canvas > form[style=""]

phenaproxima’s picture

StatusFileSize
new5.12 KB

Discussed this a little with @bnjmnm on Zoom. We're thinking that what might help here is to create a simple framework to detect when the off-canvas area is all done resizing itself, and have the test detect that. So, I gave that a try here; let's see how it does after 500 runs. I wasn't able to get the JavaScript dependencies installed to compile this from ES6 to plain JavaScript -- some weird npm error -- so for the moment I bypassed that.

phenaproxima’s picture

StatusFileSize
new5.12 KB

Whoops; had a typo which broke that.

xjm’s picture

FWIW #10 did look pretty sufficient based on the test results at that time, or at least mitigating.

  1. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
    @@ -31,6 +31,7 @@ class LayoutBuilderDisableInteractionsTest extends WebDriverTestBase {
    +    'off_canvas_test',
    
    @@ -219,6 +219,12 @@ protected function assertContextualLinksClickable(): void {
    +    $this->assertNotEmpty($assert_session->waitForElementVisible('css', '[data-resize-done="true"]'));
    

    Is the idea that we would use this test module and assertion attribute in more tests that look for things that might be in the off-canvas area?

    If so, should we provide an explicit trait and method for it?

  2. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
    @@ -219,6 +219,12 @@ protected function assertContextualLinksClickable(): void {
    +    // @see: https://www.drupal.org/project/drupal/issues/3268680
    

    We don't need to @see the issue that added the comment; that's what git blame is for. ;) The inline comment itself (aside from this line) is sufficient for that. :)

Meanwhile, I'll queue up some test result sets for the lastest patch and baseline.

xjm’s picture

+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
@@ -219,6 +219,12 @@ protected function assertContextualLinksClickable(): void {
+    // to become visible. This is to prevent a regular occurring random

Nit: should be "regularly occurring".

ravi.shankar’s picture

StatusFileSize
new5.05 KB

Addressed point number 2 of comment #23 and comment #24.

ravi.shankar’s picture

StatusFileSize
new1.24 KB

Missed the interdiff in comment #25, so adding here.

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new1.76 KB
new7.98 KB
new6.21 KB

I discussed this with @xjm and we agreed to add a new test trait for testing the off-canvas area, and keep things as they are in the patch.

So, I present:

  1. A fail patch that will run the broken test 1,000 times, proving beyond a reasonable doubt that it's broken.
  2. A pass patch which runs the fixed test, and only that test, 1000 times, proving beyond a reasonable doubt that the proposed fix actually fixes the problem.
  3. A passing patch that runs the normal test suites, and includes the agreed-upon fix.

The last submitted patch, 27: 3268680-27-1000x-PASS.patch, failed testing. View results

phenaproxima’s picture

Well...that didn't freakin' work. Will investigate tomorrow.

xjm’s picture

  1. The "FAIL" patch is missing marking the test unskipped. ;) So of course it passes.
     
  2. This is failing specifically on the new assertion, 100% of the time. Maybe we need to pass the assertion session into the method or something, because it's not defined in the scope inside the method? But no, your patch fixed that already. At least it's a 100% fail so can be debugged locally. Is it because it's creating a new instance of it? Or... no idea.
    Testing Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest
    F                                                                   1 / 1 (100%)
    
    Time: 01:34.400, Memory: 6.00 MB
    
    There was 1 failure:
    
    1) Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::testFormsLinksDisabled
    Failed asserting that a NULL is not empty.
    
    
    /var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:121
    /var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55
    /var/www/html/core/modules/system/tests/src/Traits/OffCanvasTestTrait.php:20
    /var/www/html/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php:228
    /var/www/html/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php:132
    /var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:726
  3. The patch by itself has CS errors on the JS file:
    Created 17 Mar 2022 at 15:01 CDT. phenaproxima posted patch. Updated 17 Mar 2022 at 15:09 CDT.
    
    Custom Commands Failed - View results on dispatcher
    
    --- Commands Executed ---
    core/scripts/dev/commit-code-check.sh --drupalci
    Return Code: 1
    --- Output ---
    CSpell: passed
    
    ----------------------------------------------------------------------------------------------------
    Checking core/modules/system/tests/modules/off_canvas_test/js/resize-helper.es6.js
    
    yarn run v1.22.17
    $ cross-env BABEL_ENV=legacy node ./scripts/js/babel-es6-build.js --check --file /var/www/html/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.es6.js
    [20:09:25] '/var/www/html/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.es6.js' is being checked.
    Done in 0.74s.
    
    /var/www/html/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.es6.js
       2:1  error  Delete `⏎··`                    prettier/prettier
       5:3  error  Delete `··`                     prettier/prettier
       6:1  error  Replace `·····` with `···`      prettier/prettier
       7:4  error  Delete `··`                     prettier/prettier
       8:1  error  Delete `··`                     prettier/prettier
       9:4  error  Delete `··`                     prettier/prettier
      10:1  error  Delete `··`                     prettier/prettier
      11:1  error  Replace `·····` with `···`      prettier/prettier
      12:4  error  Delete `··`                     prettier/prettier
      13:1  error  Delete `··`                     prettier/prettier
      14:5  error  Delete `····`                   prettier/prettier
      15:1  error  Delete `····`                   prettier/prettier
      16:1  error  Replace `········` with `····`  prettier/prettier
      17:1  error  Delete `····`                   prettier/prettier
      18:3  error  Replace `··}⏎` with `};`        prettier/prettier
    </li>
    
    ✖ 15 problems (15 errors, 0 warnings)
      15 errors and 0 warnings potentially fixable with the `--fix` option.

    Maybe that makes sense in context? if you run the check locally?

xjm’s picture

Status: Needs review » Needs work
xjm’s picture

StatusFileSize
new3.94 KB
new1.43 KB

This should fix the JS errors.

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new2.59 KB
new7.97 KB
new6.17 KB

OK, let's try that again. In reply to #30:

  1. D'oh! This time let's actually make sure the failing test, y'know, runs.
  2. Turns out the problem was an invalid path to resize-helper.js in off_canvas_test.libraries.yml. Fixed.
  3. Looks like it's just some JS coding standards errors, mostly whitespace-related, as you found in your patch @xjm. This passes the coding standards checks locally for me.

The last submitted patch, 33: 3268680-33-1000x-FAIL.patch, failed testing. View results

xjm’s picture

7 fails in nearly 10,000 results for the current baseline (the last three envs are about 80% done) means the fail rate of the fail-patch at this time of day is .0007 (or 0.07%) and (we're not actually sure of that last significant digit, could be anything between 0.1 and 1). That means every test has a 0.9993 chance of passing, which in turn means that there's about a 1% chance that we wouldn't see a still-possible fail in the number of queued test runs.

So I will requeue the whole set for the passing patch. :) (Not the fix-only patch though; testing it more than 1 time but fewer than 5,000 doesn't help us here.) :)

xjm’s picture

Queued it for 9 more runs. That'll make 16K total. If the base fail rate is roughly 0.0007, the chances of us NOT getting a fail are then miniscule. (If it were as low as 0.0001, then there would still be a 20% chance of us missing the fail with the current baseline. Isn't statistics fun! However, we got two more fails near the end of the last batches, so I think we're on the right power of 10.)

If we compare this with #14, I think we've shown pretty clearly that this fail rate goes way up at night.

xjm’s picture

Status: Needs review » Reviewed & tested by the community

I'm convinced. :)

alexpott’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 32bee19 and pushed to 10.0.x. Thanks!
Committed and pushed 0fdbe80815 to 9.4.x and 0a06ce704a to 9.3.x. Thanks!

Backported to 9.3.x due as this is only test changes.

Need to rebuild the JS on 10.0.x because of JS build tool updates...

diff --git a/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.js b/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.js
index ee36776565..77c613f3fa 100644
--- a/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.js
+++ b/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.js
@@ -6,10 +6,12 @@
 **/

 (function (_ref) {
-  var offCanvas = _ref.offCanvas;
-  var originalResetSize = offCanvas.resetSize;
+  let {
+    offCanvas
+  } = _ref;
+  const originalResetSize = offCanvas.resetSize;

-  offCanvas.resetSize = function (event) {
+  offCanvas.resetSize = event => {
     originalResetSize(event);
     event.data.$element.attr('data-resize-done', 'true');
   };

  • alexpott committed 4d32bbc on 10.0.x
    Issue #3268680 by phenaproxima, xjm, Spokje, ravi.shankar, bnjmmn: [...

  • alexpott committed 24472ee on 9.4.x
    Issue #3268680 by phenaproxima, xjm, Spokje, ravi.shankar, bnjmmn: [...

  • alexpott committed 0a06ce7 on 9.3.x
    Issue #3268680 by phenaproxima, xjm, Spokje, ravi.shankar, bnjmmn: [...
bnjmnm’s picture

Perhaps it's vanity, but I updated issue credit to the correctly spelled version of me.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.