Move the TestWaitTerminate middlewar to a module

Created on 29 March 2024, about 1 year ago

Problem/Motivation

The TestWaitTerminate middleware is added for all functional tests, but it's only needed by tests that use WaitTerminateTestTrait. This is likely to be a small performance hit on functional and functional js tests.

I think we could move the middleware to a testing module, then enable that module on all the tests that use the trait

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
PHPUnitย  โ†’

Last updated about 13 hours ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @catch
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    From @alexpott:

    You could do something like \Drupal\Core\Test\TestSetupTrait::$strictConfigSchema - just write the middleware directly to the services file and be doneโ€ฆ and not use state at all.

  • First commit to issue fork.
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland berdir Switzerland

    I had a look at this, and that makes sense, I'm just not exactly sure how change it to that from where we are. The current trait sets state flag which I guess you can do anytime within the test. We could rebuild the container when the method is called and write the file then, but that seems complicated and requires reading, parsing and writing it again, or writing another file that we include?

    That method currently needs to be called after setup obviously, while a new one would need to be called before to avoid extra rebuilds and complexity.

    Maybe we should just deprecate the trait entirely in favor of a flag in the test base or a trait used there, like \Drupal\Core\Test\TestSetupTrait::$strictConfigSchema. For BC, we check if the trait is present and then do it to?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Could we set the flag in the same trait, deprecate the method (docs-only deprecation I guess to start with because it'll break tests if we @trigger_error), and use it like that?

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland berdir Switzerland

    I think the logic for writing the services.yml file needs to be in \Drupal\Core\Test\FunctionalTestSetupTrait::prepareSettings, that's why my proposal is to deprecate the trait entirely and just have the flag there.

  • Status changed to Postponed: needs info about 1 month ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia mstrelan

    Apologies I didn't find this when I opened ๐Ÿ“Œ Move test middleware out of CoreServiceProvider Active . Wondering if this is still relevant? If we can avoid the container rebuild that would be ideal, but not sure if it's worth changing now.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    For me I think ๐Ÿ“Œ Move test middleware out of CoreServiceProvider Active has improved this enough that we can probably close this one. I was mainly concerned about the extra database queries on every request.

Production build 0.71.5 2024