diff --git a/cmd/pinniped/cmd/login_oidc_test.go b/cmd/pinniped/cmd/login_oidc_test.go index c73565a59..ff7409e54 100644 --- a/cmd/pinniped/cmd/login_oidc_test.go +++ b/cmd/pinniped/cmd/login_oidc_test.go @@ -15,7 +15,6 @@ import ( "time" "github.com/stretchr/testify/require" - "go.uber.org/zap" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientauthv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" clocktesting "k8s.io/utils/clock/testing" @@ -531,12 +530,9 @@ func TestLoginOIDCCommand(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { var buf bytes.Buffer - fakeClock := clocktesting.NewFakeClock(now) - ctx := plog.TestZapOverrides(context.Background(), t, &buf, nil, zap.WithClock(plog.ZapClock(fakeClock))) + ctx := plog.AddZapOverridesToContext(context.Background(), t, &buf, nil, clocktesting.NewFakeClock(now)) - var ( - gotOptions []oidcclient.Option - ) + var gotOptions []oidcclient.Option cmd := oidcLoginCommand(oidcLoginCommandDeps{ lookupEnv: func(s string) (string, bool) { v, ok := tt.env[s] diff --git a/cmd/pinniped/cmd/login_static_test.go b/cmd/pinniped/cmd/login_static_test.go index f11a76bad..e2f520bdc 100644 --- a/cmd/pinniped/cmd/login_static_test.go +++ b/cmd/pinniped/cmd/login_static_test.go @@ -13,7 +13,6 @@ import ( "time" "github.com/stretchr/testify/require" - "go.uber.org/zap" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientauthv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" clocktesting "k8s.io/utils/clock/testing" @@ -178,8 +177,7 @@ func TestLoginStaticCommand(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { var buf bytes.Buffer - fakeClock := clocktesting.NewFakeClock(now) - ctx := plog.TestZapOverrides(context.Background(), t, &buf, nil, zap.WithClock(plog.ZapClock(fakeClock))) + ctx := plog.AddZapOverridesToContext(context.Background(), t, &buf, nil, clocktesting.NewFakeClock(now)) cmd := staticLoginCommand(staticLoginDeps{ lookupEnv: func(s string) (string, bool) { diff --git a/go.mod b/go.mod index a53052462..59f1d5a31 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ replace k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230717233707-2695361 require ( github.com/MakeNowJust/heredoc/v2 v2.0.1 - github.com/chromedp/cdproto v0.0.0-20231025043423-5615e204d422 + github.com/chromedp/cdproto v0.0.0-20231101223124-24f5925b5980 github.com/chromedp/chromedp v0.9.3 github.com/coreos/go-oidc/v3 v3.7.0 github.com/coreos/go-semver v0.3.1 @@ -38,7 +38,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 - github.com/tdewolff/minify/v2 v2.20.4 + github.com/tdewolff/minify/v2 v2.20.6 go.uber.org/zap v1.26.0 golang.org/x/crypto v0.14.0 golang.org/x/net v0.17.0 @@ -54,7 +54,7 @@ require ( k8s.io/client-go v0.28.3 k8s.io/component-base v0.28.3 k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 - k8s.io/klog/v2 v2.100.1 + k8s.io/klog/v2 v2.110.1 k8s.io/kube-aggregator v0.28.3 k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 k8s.io/utils v0.0.0-20230726121419-3b25d923346b @@ -132,7 +132,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect github.com/subosito/gotenv v1.4.0 // indirect - github.com/tdewolff/parse/v2 v2.7.2 // indirect + github.com/tdewolff/parse/v2 v2.7.4 // indirect go.etcd.io/etcd/api/v3 v3.5.9 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect go.etcd.io/etcd/client/v3 v3.5.9 // indirect diff --git a/go.sum b/go.sum index fd3384112..6028a428d 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chromedp/cdproto v0.0.0-20231011050154-1d073bb38998/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= -github.com/chromedp/cdproto v0.0.0-20231025043423-5615e204d422 h1:9d05eR3+VAcQqH5qiKbpMFa83XFK7jVDfAXIindFPbU= -github.com/chromedp/cdproto v0.0.0-20231025043423-5615e204d422/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= +github.com/chromedp/cdproto v0.0.0-20231101223124-24f5925b5980 h1:/nOO3ctHFqUmUwK5EdItjTCRQQCTcxWU7aJgyjFGtEc= +github.com/chromedp/cdproto v0.0.0-20231101223124-24f5925b5980/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= github.com/chromedp/chromedp v0.9.3 h1:Wq58e0dZOdHsxaj9Owmfcf+ibtpYN1N0FWVbaxa/esg= github.com/chromedp/chromedp v0.9.3/go.mod h1:NipeUkUcuzIdFbBP8eNNvl9upcceOfWzoJn6cRe4ksA= github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic= @@ -166,7 +166,6 @@ github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8V github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= @@ -482,12 +481,12 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.4.0 h1:yAzM1+SmVcz5R4tXGsNMu1jUl2aOJXoiWUCEwwnGrvs= github.com/subosito/gotenv v1.4.0/go.mod h1:mZd6rFysKEcUhUHXJk0C/08wAgyDBFuwEYL7vWWGaGo= -github.com/tdewolff/minify/v2 v2.20.4 h1:rN2rooMxvJKDXdwpNsdHrCduSyBG+vMBs7wbAVpF/SM= -github.com/tdewolff/minify/v2 v2.20.4/go.mod h1:AMF0J/eNujZLDbfMZvWweg5TSG/KuK+/UGKc+k1N8/w= -github.com/tdewolff/parse/v2 v2.7.2 h1:9NdxF0nk/+lPI0YADDonSlpiY15hGcVUhXRj9hnK8sM= -github.com/tdewolff/parse/v2 v2.7.2/go.mod h1:9p2qMIHpjRSTr1qnFxQr+igogyTUTlwvf9awHSm84h8= -github.com/tdewolff/test v1.0.10 h1:uWiheaLgLcNFqHcdWveum7PQfMnIUTf9Kl3bFxrIoew= -github.com/tdewolff/test v1.0.10/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= +github.com/tdewolff/minify/v2 v2.20.6 h1:R4+Iw1ZqJxrqH52WWHtCpukMuhmO/EasY8YlDiSxphw= +github.com/tdewolff/minify/v2 v2.20.6/go.mod h1:9t0EY9xySGt1vrP8iscmJfywQwDCQyQBYN6ge+9GwP0= +github.com/tdewolff/parse/v2 v2.7.4 h1:zrUn2CFg9+5llbUZcsycctFlNRyV1D5gFBZRxuGzdzk= +github.com/tdewolff/parse/v2 v2.7.4/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA= +github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52 h1:gAQliwn+zJrkjAHVcBEYW/RFvd2St4yYimisvozAYlA= +github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= @@ -973,8 +972,8 @@ k8s.io/component-base v0.28.3/go.mod h1:fDJ6vpVNSk6cRo5wmDa6eKIG7UlIQkaFmZN2fYgI k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks= k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= -k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= +k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kms v0.28.3 h1:jYwwAe96XELNjYWv1G4kNzizcFoZ50OOElvPansbw70= k8s.io/kms v0.28.3/go.mod h1:kSMjU2tg7vjqqoWVVCcmPmNZ/CofPsoTbSxAipCvZuE= k8s.io/kube-aggregator v0.28.3 h1:CVbj3+cpshSHR5dWPzLYx3sVpIDEPLlzMSxY/lAc9cM= diff --git a/internal/plog/config_test.go b/internal/plog/config_test.go index 4645cb62e..1c7888631 100644 --- a/internal/plog/config_test.go +++ b/internal/plog/config_test.go @@ -18,7 +18,6 @@ import ( "go.uber.org/zap" "k8s.io/component-base/logs" "k8s.io/klog/v2" - "k8s.io/klog/v2/textlogger" clocktesting "k8s.io/utils/clock/testing" ) @@ -30,12 +29,12 @@ func TestFormat(t *testing.T) { scanner := bufio.NewScanner(&buf) - now, err := time.Parse(time.RFC3339Nano, "2022-11-21T23:37:26.953313745Z") + fakeNow, err := time.Parse(time.RFC3339Nano, "2022-11-21T23:37:26.953313745Z") require.NoError(t, err) - fakeClock := clocktesting.NewFakeClock(now) - nowStr := now.Local().Format(time.RFC1123) + fakeClock := clocktesting.NewFakeClock(fakeNow) + nowStr := fakeNow.Local().Format(time.RFC1123) - ctx = TestZapOverrides(ctx, t, &buf, nil, zap.WithClock(ZapClock(fakeClock))) + ctx = AddZapOverridesToContext(ctx, t, &buf, nil, fakeClock) err = ValidateAndSetLogLevelAndFormatGlobally(ctx, LogSpec{Level: LevelDebug}) require.NoError(t, err) @@ -112,7 +111,7 @@ func TestFormat(t *testing.T) { Logr().V(klogLevelAll).Info("also should not be logged", "open", "close") require.Empty(t, buf.String()) - ctx = TestZapOverrides(ctx, t, &buf, nil, zap.WithClock(ZapClock(fakeClock)), zap.AddStacktrace(LevelInfo)) + ctx = AddZapOverridesToContext(ctx, t, &buf, nil, fakeClock, zap.AddStacktrace(LevelInfo)) err = ValidateAndSetLogLevelAndFormatGlobally(ctx, LogSpec{Level: LevelDebug}) require.NoError(t, err) @@ -141,7 +140,7 @@ testing.tRunner ), ), scanner.Text()) - ctx = TestZapOverrides(ctx, t, &buf, nil, zap.WithClock(ZapClock(fakeClock))) + ctx = AddZapOverridesToContext(ctx, t, &buf, nil, fakeClock) err = ValidateAndSetLogLevelAndFormatGlobally(ctx, LogSpec{Level: LevelDebug, Format: FormatCLI}) require.NoError(t, err) @@ -158,14 +157,6 @@ testing.tRunner require.Equal(t, fmt.Sprintf(nowStr+` burrito plog/config_test.go:%d wee {"a": "b", "slightly less than a year": "363d", "slightly more than 2 years": "2y4d", "error": "invalid log level, valid choices are the empty string, info, debug, trace and all"}`, getLineNumberOfCaller()-4), scanner.Text()) - origTimeNow := textlogger.TimeNow - t.Cleanup(func() { - textlogger.TimeNow = origTimeNow - }) - textlogger.TimeNow = func() time.Time { - return now - } - old := New().WithName("created before mode change").WithValues("is", "old") err = ValidateAndSetLogLevelAndFormatGlobally(ctx, LogSpec{Level: LevelDebug, Format: FormatText}) @@ -187,13 +178,13 @@ testing.tRunner Logr().WithName("panda").V(KlogLevelDebug).Info("are the best", "yes?", "yes.") require.True(t, scanner.Scan()) require.NoError(t, scanner.Err()) - require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "panda: are the best" yes?="yes."`, + require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "are the best" logger="panda" yes?="yes."`, pid, getLineNumberOfCaller()-4), scanner.Text()) New().WithName("hi").WithName("there").WithValues("a", 1, "b", 2).Always("do it") require.True(t, scanner.Scan()) require.NoError(t, scanner.Err()) - require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "hi/there: do it" a=1 b=2`, + require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "do it" logger="hi.there" a=1 b=2`, pid, getLineNumberOfCaller()-4), scanner.Text()) l := WithValues("x", 33, "z", 22) @@ -211,7 +202,7 @@ testing.tRunner old.Always("should be klog text format", "for", "sure") require.True(t, scanner.Scan()) require.NoError(t, scanner.Err()) - require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "created before mode change: should be klog text format" is="old" for="sure"`, + require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "should be klog text format" logger="created before mode change" is="old" for="sure"`, pid, getLineNumberOfCaller()-4), scanner.Text()) // make sure child loggers do not share state @@ -221,11 +212,11 @@ testing.tRunner old2.Info("info") require.True(t, scanner.Scan()) require.NoError(t, scanner.Err()) - require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "created before mode change: warn" is="old" i am="old1" warning=true`, + require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "warn" logger="created before mode change" is="old" i am="old1" warning=true`, pid, getLineNumberOfCaller()-5), scanner.Text()) require.True(t, scanner.Scan()) require.NoError(t, scanner.Err()) - require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "created before mode change/old2: info" is="old"`, + require.Equal(t, fmt.Sprintf(`I1121 23:37:26.953313%8d config_test.go:%d] "info" logger="created before mode change.old2" is="old"`, pid, getLineNumberOfCaller()-8), scanner.Text()) Trace("should not be logged", "for", "sure") diff --git a/internal/plog/testing.go b/internal/plog/testing.go index f5c1fea49..2d74a705c 100644 --- a/internal/plog/testing.go +++ b/internal/plog/testing.go @@ -1,4 +1,4 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package plog @@ -22,18 +22,41 @@ import ( // contextKey type is unexported to prevent collisions. type contextKey int -const zapOverridesKey contextKey = iota +const testOverridesContextKey contextKey = iota -func TestZapOverrides(ctx context.Context, t *testing.T, w io.Writer, f func(*zap.Config), opts ...zap.Option) context.Context { +type testOverrides struct { + t *testing.T + w io.Writer + f func(*zap.Config) + fakeClock *clocktesting.FakeClock + opts []zap.Option +} + +// AddZapOverridesToContext adds Zap (and klog/textlogger) overrides to the context. +// This is done so that production code can read these values for test overrides. +// Do not pass zap.WithClock in opts since that will be constructed for you from fakeClock. +func AddZapOverridesToContext( + ctx context.Context, + t *testing.T, + w io.Writer, + f func(*zap.Config), + fakeClock *clocktesting.FakeClock, + opts ...zap.Option, +) context.Context { t.Helper() // discourage use outside of tests + require.NotNil(t, fakeClock, "fakeClock is required") + + opts = append(opts, zap.WithClock(ZapClock(fakeClock))) overrides := &testOverrides{ - t: t, - w: w, - f: f, - opts: opts, + t: t, + w: w, + f: f, + fakeClock: fakeClock, + opts: opts, } - return context.WithValue(ctx, zapOverridesKey, overrides) + + return context.WithValue(ctx, testOverridesContextKey, overrides) } func TestLogger(t *testing.T, w io.Writer) Logger { @@ -53,7 +76,7 @@ func TestZapr(t *testing.T, w io.Writer) logr.Logger { ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) - ctx = TestZapOverrides(ctx, t, w, + ctx = AddZapOverridesToContext(ctx, t, w, func(config *zap.Config) { config.Level = zap.NewAtomicLevelAt(math.MinInt8) // log everything during tests @@ -66,8 +89,8 @@ func TestZapr(t *testing.T, w io.Writer) logr.Logger { enc.AppendString(trimmed + funcEncoder(caller)) } }, - zap.WithClock(ZapClock(clocktesting.NewFakeClock(now))), // have the clock be static during tests - zap.AddStacktrace(nopLevelEnabler{}), // do not log stacktraces + clocktesting.NewFakeClock(now), // have the clock be static during tests + zap.AddStacktrace(nopLevelEnabler{}), // do not log stacktraces ) // there is no buffering so we can ignore flush @@ -111,10 +134,3 @@ var _ zapcore.LevelEnabler = nopLevelEnabler{} type nopLevelEnabler struct{} func (nopLevelEnabler) Enabled(_ zapcore.Level) bool { return false } - -type testOverrides struct { - t *testing.T - w io.Writer - f func(*zap.Config) - opts []zap.Option -} diff --git a/internal/plog/zap.go b/internal/plog/zap.go index 2b9976ef8..57dd16a36 100644 --- a/internal/plog/zap.go +++ b/internal/plog/zap.go @@ -1,4 +1,4 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package plog @@ -25,19 +25,27 @@ import ( ) func newLogr(ctx context.Context, encoding string, klogLevel klog.Level) (logr.Logger, func(), error) { + overrides, hasOverrides := ctx.Value(testOverridesContextKey).(*testOverrides) + if encoding == "text" { var w io.Writer = os.Stderr flush := func() { _ = os.Stderr.Sync() } - // allow tests to override klog config (but cheat and re-use the zap override key) - if overrides, ok := ctx.Value(zapOverridesKey).(*testOverrides); ok { + var textloggerOptions []textlogger.ConfigOption + + if hasOverrides { if overrides.w != nil { w = newSink(overrides.w) // make sure the value is safe for concurrent use flush = func() {} } + textloggerOptions = append(textloggerOptions, textlogger.FixedTime(overrides.fakeClock.Now())) } - return textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(int(klogLevel)), textlogger.Output(w))), flush, nil + textloggerOptions = append(textloggerOptions, + textlogger.Verbosity(int(klogLevel)), + textlogger.Output(w)) + + return textlogger.NewLogger(textlogger.NewConfig(textloggerOptions...)), flush, nil } path := "stderr" // this is how zap refers to os.Stderr @@ -51,8 +59,7 @@ func newLogr(ctx context.Context, encoding string, klogLevel klog.Level) (logr.L } var opts []zap.Option - // allow tests to override zap config - if overrides, ok := ctx.Value(zapOverridesKey).(*testOverrides); ok { + if hasOverrides { if overrides.w != nil { // use a per invocation random string as the key into the global map testKey := "/" + base64.RawURLEncoding.EncodeToString([]byte(rand.String(32))) @@ -78,9 +85,7 @@ func newLogr(ctx context.Context, encoding string, klogLevel klog.Level) (logr.L if overrides.f != nil { f = overrides.f } - if overrides.opts != nil { - opts = overrides.opts - } + opts = append(opts, overrides.opts...) } // when using the trace or all log levels, an error log will contain the full stack. diff --git a/test/integration/pod_shutdown_test.go b/test/integration/pod_shutdown_test.go index 91101c554..335312f7c 100644 --- a/test/integration/pod_shutdown_test.go +++ b/test/integration/pod_shutdown_test.go @@ -112,7 +112,7 @@ func testShutdownAllPodsOfApp(t *testing.T, env *testlib.TestEnv, namespace stri // process was performed successfully and without being blocked. require.Containsf(t, pl.logsBuf.String(), `"[graceful-termination] shutdown event","name":"ShutdownInitiated"`, "did not find expected message in pod log for pod %q", pl.pod.Name) - require.Containsf(t, pl.logsBuf.String(), `"[graceful-termination] apiserver is exiting\n"`, + require.Containsf(t, pl.logsBuf.String(), `[graceful-termination] apiserver is exiting`, "did not find expected message in pod log for pod %q", pl.pod.Name) t.Logf("found expected graceful-termination messages in the logs of pod %q", pl.pod.Name) }