From 6ee2c6313591b9ce23c1d47a6ddb4a8fe1df0705 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 23 Aug 2024 14:20:17 +0200 Subject: [PATCH] testserver: allow caller to set up ktesting In scheduler_perf, the caller configures ktesting without per-test output. When StartTestServer initialized it again, it did so with per-test output. In other cases it might have been simply redundant. --- cmd/kube-apiserver/app/testing/testserver.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/kube-apiserver/app/testing/testserver.go b/cmd/kube-apiserver/app/testing/testserver.go index 6969cb70662..3c3b9e55ecd 100644 --- a/cmd/kube-apiserver/app/testing/testserver.go +++ b/cmd/kube-apiserver/app/testing/testserver.go @@ -150,7 +150,11 @@ func NewDefaultTestServerOptions() *TestServerInstanceOptions { // files that because Golang testing's call to os.Exit will not give a stop channel go routine // enough time to remove temporary files. func StartTestServer(t ktesting.TB, instanceOptions *TestServerInstanceOptions, customFlags []string, storageConfig *storagebackend.Config) (result TestServer, err error) { - tCtx := ktesting.Init(t) + // Some callers may have initialize ktesting already. + tCtx, ok := t.(ktesting.TContext) + if !ok { + tCtx = ktesting.Init(t) + } if instanceOptions == nil { instanceOptions = NewDefaultTestServerOptions()