Add real-time test progress logging to stderr in e2e#8912
Draft
titilambert wants to merge 1 commit into
Draft
Conversation
Contributor
Author
|
This change is part of the following stack: Change managed by git-spice. |
Contributor
PR Title Lint Failed ❌Current Title: Your PR title doesn't follow the expected format. Please update your PR title to follow one of these patterns: Conventional Commits Format:
Guidelines:
Examples:
Please update your PR title and the lint check will run again automatically. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds real-time progress signals for e2e scenario execution by writing START/PASS/FAIL lines directly to stderr, aiming to surface test progress in Azure DevOps logs while tests are still running.
Changes:
- Emit a
STARTEDline tostderrwhen a scenario begins. - Emit
PASS/FAILlines (with elapsed time) tostderron subtest completion via a deferred helper.
Comment on lines
77
to
81
| func RunScenario(t *testing.T, s *Scenario) { | ||
| t.Parallel() | ||
| fmt.Fprintf(os.Stderr, "⏳ STARTED %s\n", t.Name()) | ||
| start := time.Now() | ||
| // Special case for testing VHD caching. Not used by default. |
c279e19 to
35167d3
Compare
Comment on lines
+79
to
+80
| fmt.Fprintf(os.Stderr, "⏳ STARTED %s\n", t.Name()) | ||
| start := time.Now() |
Comment on lines
84
to
86
| t.Parallel() | ||
| defer logTestResult(t, start) | ||
| runScenarioWithPreProvision(t, s) |
Comment on lines
91
to
93
| t.Parallel() | ||
| defer logTestResult(t, start) | ||
| err := runScenario(t, copyScenario(s)) |
Comment on lines
99
to
101
| t.Parallel() | ||
| defer logTestResult(t, start) | ||
| sCopy := copyScenario(s) |
|
|
||
| # gotestsum configure to only show logs for failed tests, json file for detailed logs | ||
| # Run the tests! Yey! | ||
| echo "STDERR_STREAMING_CHECK: this should appear immediately" >&2 |
35167d3 to
9b3063d
Compare
Comment on lines
+79
to
+80
| logTestProgress("⏳ STARTED %s", t.Name()) | ||
| start := time.Now() |
Comment on lines
83
to
87
| t.Run("VHDCreation", func(t *testing.T) { | ||
| t.Parallel() | ||
| defer logTestResult(t, start) | ||
| runScenarioWithPreProvision(t, s) | ||
| }) |
Comment on lines
91
to
93
| t.Parallel() | ||
| defer logTestResult(t, start) | ||
| err := runScenario(t, copyScenario(s)) |
Comment on lines
99
to
101
| t.Parallel() | ||
| defer logTestResult(t, start) | ||
| sCopy := copyScenario(s) |
| if path == "" { | ||
| return | ||
| } | ||
| f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644) |
Comment on lines
115
to
+129
| @@ -116,6 +125,9 @@ fi | |||
| ${rerun_fails:+--rerun-fails=$rerun_fails} ${rerun_fails:+--packages=.} \ | |||
| -- -parallel 60 -timeout "${E2E_GO_TEST_TIMEOUT}" || test_exit_code=$? | |||
|
|
|||
| kill $TAIL_PID 2>/dev/null || true | |||
| rm -f "$E2E_PROGRESS_LOG" | |||
9b3063d to
f3c7059
Compare
f3c7059 to
89e9f91
Compare
Comment on lines
115
to
+129
| @@ -116,6 +125,9 @@ fi | |||
| ${rerun_fails:+--rerun-fails=$rerun_fails} ${rerun_fails:+--packages=.} \ | |||
| -- -parallel 60 -timeout "${E2E_GO_TEST_TIMEOUT}" || test_exit_code=$? | |||
|
|
|||
| kill $TAIL_PID 2>/dev/null || true | |||
| rm -f "$E2E_PROGRESS_LOG" | |||
Comment on lines
+120
to
+125
| f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644) | ||
| if err != nil { | ||
| return | ||
| } | ||
| defer f.Close() | ||
| fmt.Fprintf(f, format+"\n", args...) |
Comment on lines
+133
to
+140
| func logTestResult(t testing.TB, start time.Time) { | ||
| duration := time.Since(start).Round(time.Second) | ||
| if t.Failed() { | ||
| logTestProgress("✗ FAIL %s (%s)", t.Name(), duration) | ||
| } else { | ||
| logTestProgress("✓ PASS %s (%s)", t.Name(), duration) | ||
| } | ||
| } |
Comment on lines
+115
to
+117
| export E2E_PROGRESS_LOG="$(mktemp)" | ||
| stdbuf -oL tail -f "$E2E_PROGRESS_LOG" & | ||
| TAIL_PID=$! |
89e9f91 to
5d59834
Compare
Comment on lines
+115
to
119
| export E2E_PROGRESS_LOG="$(mktemp)" | ||
| stdbuf -oL tail -f "$E2E_PROGRESS_LOG" & | ||
| TAIL_PID=$! | ||
|
|
||
| test_exit_code=0 |
| if path == "" { | ||
| return | ||
| } | ||
| f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644) |
5d59834 to
d859aac
Compare
| # from within tests does not appear in real-time. Instead, tests write | ||
| # progress to a file and tail -f streams it outside of go test's capture. | ||
| export E2E_PROGRESS_LOG="$(mktemp)" | ||
| stdbuf -oL tail -f "$E2E_PROGRESS_LOG" & |
| if path == "" { | ||
| return | ||
| } | ||
| f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #