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

clear EventDispatcher cache in tests #17620

Merged
merged 1 commit into from May 26, 2021
Merged

clear EventDispatcher cache in tests #17620

merged 1 commit into from May 26, 2021

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented May 25, 2021

Description:

Was writing some tests that require the ActivityLog plugin but failed to get them working. The reason actually was, that the ActivityLog plugin dynamically tries to register hooks. To get that working in tests it's required to clear the registered hooks that might have been cached previously.

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@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. Needs Review PRs that need a code review labels May 25, 2021
@sgiehl sgiehl added this to the 4.3.1 milestone May 25, 2021
@@ -92,6 +93,7 @@ public function setUp(): void

PiwikCache::getEagerCache()->flushAll();
PiwikCache::getTransientCache()->flushAll();
EventDispatcher::getInstance()->clearCache();
Copy link
Member

Choose a reason for hiding this comment

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

Can we put this in Fixture::clearInMemoryCaches()?

Copy link
Member

Choose a reason for hiding this comment

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

I see we call that in tearDown only for some reason... seems like a mistake, and we should clear all of those caches here too...

Copy link
Member Author

Choose a reason for hiding this comment

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

@diosmosis updated the PR

Copy link
Member Author

Choose a reason for hiding this comment

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

@diosmosis seems clearing all caches at this point lets various integration tests start failing. Seems clearing all static instances is a problem at that point as some fixtures are manipulating those before.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted it so it only adds the additional cache clear, but left a note so it's clear why not all caches are cleared

@mattab mattab modified the milestones: 4.3.1, 4.4.0 May 26, 2021
@sgiehl sgiehl force-pushed the cleareventcache branch 2 times, most recently from 4481fe3 to 6b7c677 Compare May 26, 2021 08:06
@diosmosis diosmosis merged commit cf2572e into 4.x-dev May 26, 2021
@diosmosis diosmosis deleted the cleareventcache branch May 26, 2021 17:41
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. Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants