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

chore: refactor tests to fix timeouts and improve cleanup #422

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

ctreatma
Copy link
Contributor

@ctreatma ctreatma commented Dec 20, 2023

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.

@ctreatma ctreatma requested a deployment to internal December 20, 2023 20:22 — with GitHub Actions Abandoned
@displague displague merged commit 4bfe00f into main Dec 20, 2023
8 of 9 checks passed
@displague displague deleted the test-cleanup-part-dieux branch December 20, 2023 21:53
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.

E2E tests fail to get capacity
3 participants