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

Cache request responses in UI tests to avoid some external requests #21492

Draft
wants to merge 1 commit into
base: 5.x-dev
Choose a base branch
from

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Nov 6, 2023

Description:

Many of our UI tests might currently request the Marketplace or the Matomo API to look for updates and similar. Depending on the response time this can slow down the tests.

This PR implements a simple caching for requests sent to any Matomo domain during a UI test run. After the run, the cache will be cleared.

Across our 4 UI test suites this currently saves around 200 - 300 requests. Haven't counted that in detail though.
Hard to say how much time that saves. Comparing the run times of this PR and 5.x-dev it seems to be around 1-5 minutes for each suite.

Note: This is not meant to be a final solution and only to improve the current situation a bit. A proper solution would imho be to implement proper response mocks, where we manually place the (expected) responses instead, so the tests don't perform any requests to marketplace/api anymore.

@matomo-org/core-reviewers happy to your opinions on this (temporary) approach.

Review

@sgiehl sgiehl added c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. labels Nov 6, 2023
@sgiehl sgiehl requested a review from a team November 6, 2023 16:03
@michalkleiner
Copy link
Contributor

Interesting approach. So we're basically saying the back-end might be slow so we store and reuse the processed responses. In principle I don't have a problem with this but it might complicate debugging later on when someone tests things locally and changes some data and expects that to be visible but the cached response will be returned and it may take time to realise that the cache is there.
Also when we briefly touched on this, for some reason I thought it would be cached at the headless browser end running the tests, but that could be even trickier to implement.
Ultimately this is a temporary measure and mock responses should be used as the final solution, so I'd be happy with this for a while 👍.

@sgiehl
Copy link
Member Author

sgiehl commented Nov 8, 2023

Interesting approach. So we're basically saying the back-end might be slow so we store and reuse the processed responses. In principle I don't have a problem with this but it might complicate debugging later on when someone tests things locally and changes some data and expects that to be visible but the cached response will be returned and it may take time to realise that the cache is there.

The requests are only cached during UI tests. And each run of ./console tests:run-ui by default will clear the cached files in the beginning. So there shouldn't be any issues like that.

Also when we briefly touched on this, for some reason I thought it would be cached at the headless browser end running the tests, but that could be even trickier to implement.

How should that be possible. The requests are sent from the backend/php and not from the browser, so there is no way how the browser could cache them.

@sgiehl sgiehl force-pushed the cacherequests branch 2 times, most recently from 38a4835 to 67846d5 Compare November 27, 2023 13:09
Copy link
Contributor

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Dec 12, 2023
Copy link
Contributor

github-actions bot commented Mar 2, 2024

This PR was last updated more than one month ago, maybe it's time to close it. Please check if there is anything we still can do or close this PR. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale for long The label used by the Close Stale Issues action label Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Stale for long The label used by the Close Stale Issues action Stale The label used by the Close Stale Issues action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants