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

Tests trigger shotover shutdown and then unwrap the result of the join handle #139

Merged
merged 1 commit into from
Aug 17, 2021
Merged

Tests trigger shotover shutdown and then unwrap the result of the join handle #139

merged 1 commit into from
Aug 17, 2021

Conversation

rukai
Copy link
Member

@rukai rukai commented Aug 13, 2021

I figured out a solution to the problems I hinted at in #138
The solution to panicking in drops in test helpers is to check std::thread::panicking to tell if we are currently panicking. If we are panicking then we should not run any code that can panic.

We could possibly simplify the code in the future by allowing double panics if rust-lang/rust#82850 is ever resolved. But the current implementation is fine and its probably desirable to never double panic regardless of rust-lang/rust#82850 anyway.

closes #134

This PR improves tests such that:

  • Errors that bring down shotover are logged over error!
  • DockerCompose can no longer cause double panics.
  • Every test tests that shotover can shutdown after the test is run.

This PR improves the shutdown process by adding the trigger_shutdown broadcast channel so that we can trigger a shutdown from any source.

This PR supercedes #138 so we can just close 138 if we are happy with this one.

@rukai rukai requested a review from benbromhead August 16, 2021 00:29
..ConfigOpts::default()
};
let spawn = Runner::new(opts).unwrap().run_spawn();
pub struct ShotoverManager {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a dev-dep and go in the test-helpers dep as this appears to be duplicated in the tests folder as well

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that they depend on types from the shotover-proxy crate and moving them to test-helpers would create a circular dependency.

A possible fix is to move the shotover-proxy specific logic into a lambda passed in by a benches/helpers.rs wrapper.
But I wanted to investigate that in a separate PR.
Although if your not comfortable with leaving so much code duplicated for now, I can investigate it here?

Copy link
Member

Choose a reason for hiding this comment

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

Ok makes sense.

DRY is good, but as you hinted at this smells like a pre-mature optimisation without further investigation.

I don't mind the duplicated code, feel free to merge.

@benbromhead
Copy link
Member

Feel free to close out #138 as well as this looks to be the preferred approach

@rukai rukai mentioned this pull request Aug 17, 2021
@rukai rukai merged commit e033bf7 into shotover:main Aug 17, 2021
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.

Tests should unwrap Result::err returned by Runner::run_spawn
2 participants