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

refactor: when testing deferral, don't observe life cycle events #1596

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dimaqq
Copy link
Contributor

@dimaqq dimaqq commented Feb 28, 2025

Pulled out from the OTEL branch.
Since life cycle events can't be deferred anyway, let's not observe them in these tests.
I hope this makes the tests more focused, and perhaps easier to maintain.

Inspired by #1589

Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

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

The change looks good to me - but the PR title seems wrong. This isn't ignoring lifecycle events (which would be a bad change I think), this is making the test code do the same thing but be more maintainable.

@dimaqq dimaqq changed the title refactor: ignore life cycle events while testing deferral refactor: when testing deferral, don't observe life cycle events Feb 28, 2025
@dimaqq
Copy link
Contributor Author

dimaqq commented Feb 28, 2025

I've rewritten the PR title and description.

I think what motivated my change was that I was confused by "defer by count" in the first place.

It felt like a total coincidence that CollectStatus was not deferred.

@tonyandrewmeyer
Copy link
Contributor

I've rewritten the PR title and description.

I think what motivated my change was that I was confused by "defer by count" in the first place.

It felt like a total coincidence that CollectStatus was not deferred.

Sorry, this is mostly my bad. I somehow overlooked before the new if statement, so I was only seeing the change in how the observed events are extracted and that didn't line up with the title.

However, it's not really a coincidence, it's careful manipulation of the counts so that the lifecycle ones aren't deferred (the test would error if that happened, since defer raises).

I don't think the "defer by count" is great for maintainability - this change probably does improve things a bit so that when figuring out counts you can skip over the lifecycle ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants