Skip to content

Ensure test is properly shut down on failure #2258

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bbockelm
Copy link
Collaborator

Without this, if the test fails, various goroutines stick around and can prevent the unit test framework from a clean shutdown.

Without this, if the test fails, various goroutines stick around
and can prevent the unit test framework from a clean shutdown.
@bbockelm bbockelm requested a review from jhiemstrawisc April 26, 2025 00:22
Comment on lines 207 to 210
if err != nil {
f.FedCancel()
f.T.Fatalf("Failure in fedServeInternal: %v", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this works, but out of curiosity why not do:

_, f.FedCancel, err = launchers.LaunchModules(ctx, modules)
require.NoError(t, err, "Failure to launch federation")

If I understand correctly, the issue with f.T.Fatal() is that it shuts down immediately, preventing the deferred Teardown() function from running. None of the other error checks we do after launching modules in Spinup() seem to need an explicit call to FedCancel(), and I think it's because require.NoError() doesn't prevent the teardown.

@jhiemstrawisc jhiemstrawisc added test Improvements to the test suite internal Internal code improvements, not user-facing labels Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Internal code improvements, not user-facing test Improvements to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants