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

Catch violations in times(...) expectations #2766

Merged
merged 15 commits into from
Feb 15, 2023

Conversation

imotov
Copy link
Collaborator

@imotov imotov commented Feb 8, 2023

Description

Adds a new quit() method to universe that causes all spawned actors to quit. It also collects actors exit codes that can be used to verify that all actors quit gracefully, which in turn allows to fail the test if mock objects expectations are not met.

Relates to #2754

How was this PR tested?

Added several tests to universe.rs. I also had to modify several times(...) parameters to make tests pass. Somebody who is more familiar with these tests should probably check if these changes make sense or if I inadvertently found and buried actual bugs.

Adds a new quit() method to universe that causes all spawned actors
to quit. It also collects actors exit codes that can be used to verify
that all actors quit gracefully, which in turn allows to fail the test
if mock objects expectations are not met.

Relates to quickwit-oss#2754
@imotov
Copy link
Collaborator Author

imotov commented Feb 8, 2023

I opened #2768 to fix the license header checker.

imotov and others added 6 commits February 8, 2023 13:53
Improve panic handling

Co-authored-by: Paul Masurel <paul@quickwit.io>
Also adds a check to the universe.drop() to make sure that
universe.assert_quit() was indeed called at the end of the test.
Copy link
Collaborator

@fulmicoton fulmicoton left a comment

Choose a reason for hiding this comment

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

LGTM...

See comments inline.
Can you investigate the Shared<JoinHandle> solution too?
If it is a dead-end no pb.

@imotov
Copy link
Collaborator Author

imotov commented Feb 15, 2023

One thing that still annoys me with the current implementation is that when a test that uses universe fails for some unrelated reason the logic in universe drop is still triggered. So, you see two panics - first is your test's panic, which is useful, but then you also get the universe's drop panic with irrelevant message "Did you call universe.assert_quit()?". I just implemented it and it confuses me sometimes, I imagine it might also confuse others. Not really sure how to detect it though.

@fulmicoton
Copy link
Collaborator

@imotov Yes, if it is too confusing we may have to remove this Drop impl. Anyway, LGTM

@fulmicoton fulmicoton merged commit 81159a3 into quickwit-oss:main Feb 15, 2023
imotov added a commit to imotov/quickwit that referenced this pull request Feb 16, 2023
If test fails with panic and universe drop is called it kills the test
runner instead of displaying the first panic.

Relates to quickwit-oss#2766
fulmicoton pushed a commit that referenced this pull request Feb 16, 2023
* Universe shouldn't panic if thread is panicking

If test fails with panic and universe drop is called it kills the test
runner instead of displaying the first panic.

Relates to #2766

* Fix format
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