mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 04:52:08 +00:00
ktesting: log warning on timeout
How exactly a test reacts when its context times out is unclear. In the case of scheduler_perf, the apiserver started to shut down and the test failure then was about not being able to reach the apiserver, which was a bit confusing. To make it more obvious why the shutdown starts, a WARNING message gets added to the test output by ktesting before cancellation and thus before any other output related to that cancellation.
This commit is contained in:
parent
cc9234cffd
commit
5447d28c0d
@ -59,6 +59,14 @@ func withTimeout(ctx context.Context, tb TB, timeout time.Duration, timeoutCause
|
||||
// No need to set a cause here. The cause or error of
|
||||
// the parent context will be used.
|
||||
case <-after.C:
|
||||
// Code using this tCtx may or may not log the
|
||||
// information above when it runs into the
|
||||
// cancellation. It's better if we do it, just to be on
|
||||
// the safe side.
|
||||
//
|
||||
// Would be nice to log this with the source code location
|
||||
// of our caller, but testing.Logf does not support that.
|
||||
tb.Logf("\nWARNING: %s\n", timeoutCause)
|
||||
cancel(canceledError(timeoutCause))
|
||||
}
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user