Problem/Motivation

\Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait skips both testPatch and testPost but this occurs after installing Drupal. This can cost 15 seconds of compute time per skipped test... see page 169 of https://git.drupalcode.org/project/drupal/-/pipelines/227006/test_report...

Steps to reproduce

Run ./vendor/bin/phpunit core/modules/comment/tests/src/Functional/Rest/CommentXmlBasicAuthTest.php --filter testPostDxWithoutCriticalBaseFields

Proposed resolution

Use attributes to add methods run before a test to mark it skipped if we are skipping based on name.

Running ./vendor/bin/phpunit core/modules/comment/tests/src/Functional/Rest/CommentXmlBasicAuthTest.php --filter testPostDxWithoutCriticalBaseFields before takes Time: 00:08.349, Memory: 10.00 MB and after takes Time: 00:00.463, Memory: 10.00 MB

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

N/a

Issue fork drupal-3462264

Command icon 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:

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Issue summary: View changes
Status: Active » Needs review

alexpott’s picture

Title: XmlEntityNormalizationQuirksTrait skips testPatch and testPost but still installs Drupal » Skip unsupported methods in rest tests in an efficient way

Better title...

catch’s picture

This looks great, do we want to do the other REST tests that skip on the XML format?

Looks like at least these:

UserXmlCookieTest
UserXmlAnonTest
UserXmlBasicAuthTest
UserXmlCookieTest
WorkspaceXmlBasicAuthTest
WorkspaceXmlAnonTest
WorkspaceXmlCookieTest
core/modules/taxonomy/tests/src/Functional/Rest/TermXmlBasicAuthTest.php
core/modules/taxonomy/tests/src/Functional/Rest/TermXmlCookieTest.php
core/modules/taxonomy/tests/src/Functional/Rest/TermXmlAnonTest.php
core/modules/image/tests/src/Functional/Rest/ImageStyleXmlAnonTest.php
core/modules/image/tests/src/Functional/Rest/ImageStyleXmlCookieTest.php
core/modules/image/tests/src/Functional/Rest/ImageStyleXmlBasicAuthTest.php
core/modules/node/tests/src/Functional/Rest/NodeXmlAnonTest.php
core/modules/node/tests/src/Functional/Rest/NodeXmlBasicAuthTest.php
core/modules/node/tests/src/Functional/Rest/NodeXmlCookieTest.php
core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlAnonTest.php
core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlCookieTest.php
core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeXmlBasicAuthTest.php


I think we can also use the same pattern in:

jsonapi/tests/src/Functional/FileUploadTest.php

and similar too, probably better in its own issue though.

alexpott’s picture

Title: Skip unsupported methods in rest tests in an efficient way » Skip unsupported methods in rest/jsonapi tests in an efficient way
alexpott’s picture

The MR takes us to only 7 functional test methods being skipped that actually take longer than 0.00 seconds! Down from over hundred...

I think this is ready for review.

alexpott’s picture

Added an MR to backport this to 10.x using the annotation for before instead of the attribute.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Both MRs look great to me.

  • catch committed 843bfc19 on 11.0.x
    Issue #3462264 by alexpott: Skip unsupported methods in rest/jsonapi...

  • catch committed d3e85883 on 11.x
    Issue #3462264 by alexpott: Skip unsupported methods in rest/jsonapi...

  • catch committed 135b0ee7 on 10.3.x
    Issue #3462264 by alexpott: Skip unsupported methods in rest/jsonapi...

  • catch committed 936c5cf8 on 10.4.x
    Issue #3462264 by alexpott: Skip unsupported methods in rest/jsonapi...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Hard to see what the impact on pipeline wall times is going to be due to variation between test runs, but even if it only takes 10 seconds to install Drupal, ~100 less installs is 1000 seconds less test time. There are also some specific tests (like file upload ones) which have been some of the most individually long running tests that this should help with too.

Committed/pushed the respective MRs to 11.x/11.0.x/10.4.x, 10.3.x, thanks!

Status: Fixed » Closed (fixed)

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

wim leers’s picture

👏