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

mvlog/tests: clean up files in test body #18554

Merged
merged 1 commit into from
May 20, 2024

Conversation

andrwng
Copy link
Contributor

@andrwng andrwng commented May 16, 2024

I noticed that death tests were leaving behind some directories, even
though the test appears to be exiting successfully.

It turns out that because death tests run a separate process[1], it was
creating an extra directory, but not running the teardown because of the
process crash.

So this hacks the tests to clean up in the test body before the crash.

[1] https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests-and-threads

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.1.x
  • v23.3.x
  • v23.2.x

Release Notes

  • none

@vbotbuildovich
Copy link
Collaborator

I noticed that death tests were leaving behind some directories, even
though the test appears to be exiting successfully.

It turns out that because death tests run a separate process[1], it was
creating an extra directory, but not running the teardown because of the
process crash.

So this hacks the tests to clean up in the test body before the crash.

[1] https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests-and-threads
@andrwng andrwng changed the title mvlog/tests: add missing cleanup for files mvlog/tests: clean up files in test body May 17, 2024
ss::future<> TearDownAsync() override {
for (auto& file : files_) {
co_await file->close();
}
co_await ss::recursive_remove_directory(
std::filesystem::path{base_dir_});
// NOTE: death tests may clean themselves up in the test body to avoid
Copy link
Contributor

Choose a reason for hiding this comment

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

"may clean" or "may need to clean"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it should be "need to". Can follow up if you think it's unclear enough to trip up on

@andrwng andrwng merged commit 48c7980 into redpanda-data:dev May 20, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants