Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Speed up Behat tests #4750

Merged

Conversation

mhsdesign
Copy link
Member

@mhsdesign mhsdesign commented Nov 14, 2023

During the refactoring of our testsuite via #4455 a performance optimization got lost.

Previously we only setUp a content repository once because the schema creation in the setup is super slow: #4762

By preventing the projections to be resetup again, we gain a noticeable performance improvement (about 80%) of the whole e2e tests on the ci:

Before After
18:32m 3:52m

locally they run in like a minute.

To let tests in Neos.Neos profit from the same performance boost, we need to avoid the cr tables being dropped due to the @flowEntities tag (see neos/behat#37 (comment)). This. is achieved via the adjustments in neos/behat#37 which will respect the configured ignoredTables configuration.


Additionally a sleep(2); statement which was run for every scenario was hidden in the Neos.Neos tests.

This was an early hotfix for our previously async running tests. Currently we run tests only in sync mode CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION=1 as the async mode is broken: #4612

Upgrade instructions

Review instructions

Things and answers (collected from neos/behat#37 and slack):

Dont we have to truncate the tables every time so the projections are empty?

we do that explicitly via $contentRepository->resetProjectionStates();.

Can we safely empty the tables? Would that be the equivalent to resetProjectionStates?

nope we need an initial entry in the checkpoint tables

Shouldnt we make setUp just faster by caching the createSchema?

yes and no. With #4762 we plan to optimize performance of the setup but without caching the schema see issue.

Related: #4388

@bwaidelich bwaidelich changed the title Task: speedup behavioral test by ninety three percent TASK: Speedup behat tests Nov 17, 2023
With this change we setup the content repository only once for all tests `$contentRepository->setUp();`.
The projections contents are cleared in each iteration via `$contentRepository->resetProjectionStates();` and this works quite well for the escr core tests.
For tests using the `@flowEntities` annotation and database reset we must avoid to drop all the escr tables as otherwise we would need to setup the cr again. This will be fixed in neos/behat#37.

Why are we going through so much hassle to (hackily) setup the cr only once? Because each projection calls `$schemaManager->createSchema()` twice when being setup and this slows down test enormously by 80%
Currently we run tests only in sync mode `CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION=1` as the async mode is broken: neos#4612

I presume the `sleep(2)` is an artefact for the async tests to work at some earlier point.
@mhsdesign mhsdesign force-pushed the task/speedupBehavioralTestByNinetyThreePercent branch from 254fd17 to 0505bb2 Compare November 17, 2023 18:57
@mhsdesign mhsdesign marked this pull request as ready for review November 17, 2023 19:33
@mhsdesign mhsdesign closed this Nov 17, 2023
@mhsdesign mhsdesign reopened this Nov 17, 2023
@mhsdesign mhsdesign closed this Nov 17, 2023
@mhsdesign mhsdesign reopened this Nov 17, 2023
@mhsdesign mhsdesign closed this Nov 17, 2023
@mhsdesign mhsdesign deleted the task/speedupBehavioralTestByNinetyThreePercent branch November 17, 2023 20:32
@mhsdesign mhsdesign restored the task/speedupBehavioralTestByNinetyThreePercent branch November 17, 2023 20:32
@mhsdesign mhsdesign reopened this Nov 17, 2023
Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic, thanks for taking care!

@kdambekalns kdambekalns changed the title TASK: Speedup behat tests TASK: Speed up Behat tests Nov 18, 2023
Copy link
Member

@kdambekalns kdambekalns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 by 👀

@mhsdesign mhsdesign merged commit 8aa5ee9 into neos:9.0 Nov 18, 2023
21 of 26 checks passed
@mhsdesign mhsdesign deleted the task/speedupBehavioralTestByNinetyThreePercent branch November 18, 2023 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants