-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor tests to fix timeouts and improve cleanup (#422)
A recent refactor of the test code introduced persistent timeouts, even in tests that do not perform API-intensive tasks (for example, read-only tests that request capacity information). These timeouts were happening because the tests temporarily replace stdout with a byte buffer in order to capture command output for validation; during the most recent refactor, the code that closes the byte buffer and restores stdout was moved to a `t.Cleanup` handler, so the buffer was not closed until after the test finished, causing the test to hang until it timed out. This moves the stdout-juggling code into a helper function to ensure that we are using the same logic across all tests. The helper function logs any errors that happen while closing or reading the byte buffer, but does not fail the test for those errors; the tests themselves should fail if those errors impact the behavior under test. Fixes #416. Related to #343. In addition, existing test helpers are refactored to more easily ensure that resources created with test helpers are automatically cleaned up after a test runs and to ensure that tests fail early if a test resource could not be created. Test helpers for deleting resources now log the ID of the resource they are trying to delete so we can more easily triage issues with test cleanup.
- Loading branch information
Showing
28 changed files
with
358 additions
and
1,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.