Make race detector happy by removing parallelism
Signed-off-by: Monis Khan <mok@vmware.com>
This commit is contained in:
parent
15a5332428
commit
1c60e09f13
@ -20,6 +20,7 @@ import (
|
|||||||
"go.pinniped.dev/internal/client"
|
"go.pinniped.dev/internal/client"
|
||||||
"go.pinniped.dev/internal/constable"
|
"go.pinniped.dev/internal/constable"
|
||||||
"go.pinniped.dev/internal/here"
|
"go.pinniped.dev/internal/here"
|
||||||
|
"go.pinniped.dev/internal/plog"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint: gochecknoinits
|
//nolint: gochecknoinits
|
||||||
@ -80,6 +81,8 @@ func newExchangeCredentialCmd(args []string, stdout, stderr io.Writer) *exchange
|
|||||||
c.cmd.SetOut(stdout)
|
c.cmd.SetOut(stdout)
|
||||||
c.cmd.SetErr(stderr)
|
c.cmd.SetErr(stderr)
|
||||||
|
|
||||||
|
plog.RemoveKlogGlobalFlags()
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ func TestNewCredentialExchangeCmd(t *testing.T) {
|
|||||||
r.Equal(knownGoodHelpForExchangeCredential, stdout.String())
|
r.Equal(knownGoodHelpForExchangeCredential, stdout.String())
|
||||||
r.Empty(stderr.String())
|
r.Empty(stderr.String())
|
||||||
})
|
})
|
||||||
}, spec.Parallel(), spec.Report(report.Terminal{}))
|
}, spec.Sequential(), spec.Report(report.Terminal{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExchangeCredential(t *testing.T) {
|
func TestExchangeCredential(t *testing.T) {
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
pinnipedclientset "go.pinniped.dev/generated/1.19/client/concierge/clientset/versioned"
|
pinnipedclientset "go.pinniped.dev/generated/1.19/client/concierge/clientset/versioned"
|
||||||
"go.pinniped.dev/internal/constable"
|
"go.pinniped.dev/internal/constable"
|
||||||
"go.pinniped.dev/internal/here"
|
"go.pinniped.dev/internal/here"
|
||||||
|
"go.pinniped.dev/internal/plog"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint: gochecknoinits
|
//nolint: gochecknoinits
|
||||||
@ -91,6 +92,7 @@ func (c *getKubeConfigCommand) Command() *cobra.Command {
|
|||||||
cmd.Flags().StringVar(&c.flags.authenticatorType, "authenticator-type", c.flags.authenticatorType, "Authenticator type (e.g., 'webhook')")
|
cmd.Flags().StringVar(&c.flags.authenticatorType, "authenticator-type", c.flags.authenticatorType, "Authenticator type (e.g., 'webhook')")
|
||||||
cmd.Flags().StringVar(&c.flags.authenticatorName, "authenticator-name", c.flags.authenticatorType, "Authenticator name")
|
cmd.Flags().StringVar(&c.flags.authenticatorName, "authenticator-name", c.flags.authenticatorType, "Authenticator name")
|
||||||
mustMarkRequired(cmd, "token")
|
mustMarkRequired(cmd, "token")
|
||||||
|
plog.RemoveKlogGlobalFlags()
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNewGetKubeConfigCmd(t *testing.T) {
|
func TestNewGetKubeConfigCmd(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
@ -95,7 +94,6 @@ func TestNewGetKubeConfigCmd(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
cmd := newGetKubeConfigCommand().Command()
|
cmd := newGetKubeConfigCommand().Command()
|
||||||
require.NotNil(t, cmd)
|
require.NotNil(t, cmd)
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestLoginOIDCCommand(t *testing.T) {
|
func TestLoginOIDCCommand(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
cfgDir := mustGetConfigDir()
|
cfgDir := mustGetConfigDir()
|
||||||
|
|
||||||
time1 := time.Date(3020, 10, 12, 13, 14, 15, 16, time.UTC)
|
time1 := time.Date(3020, 10, 12, 13, 14, 15, 16, time.UTC)
|
||||||
@ -88,7 +86,6 @@ func TestLoginOIDCCommand(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
var (
|
var (
|
||||||
gotIssuer string
|
gotIssuer string
|
||||||
gotClientID string
|
gotClientID string
|
||||||
|
@ -36,7 +36,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNewVersionCmd(t *testing.T) {
|
func TestNewVersionCmd(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
@ -64,7 +63,6 @@ func TestNewVersionCmd(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
cmd := newVersionCommand()
|
cmd := newVersionCommand()
|
||||||
require.NotNil(t, cmd)
|
require.NotNil(t, cmd)
|
||||||
|
|
||||||
|
@ -3,10 +3,21 @@
|
|||||||
|
|
||||||
package plog
|
package plog
|
||||||
|
|
||||||
import "github.com/spf13/pflag"
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/spf13/pflag"
|
||||||
|
)
|
||||||
|
|
||||||
|
//nolint: gochecknoglobals
|
||||||
|
var removeKlogGlobalFlagsLock sync.Mutex
|
||||||
|
|
||||||
// RemoveKlogGlobalFlags attempts to "remove" flags that get unconditionally added by importing klog.
|
// RemoveKlogGlobalFlags attempts to "remove" flags that get unconditionally added by importing klog.
|
||||||
func RemoveKlogGlobalFlags() {
|
func RemoveKlogGlobalFlags() {
|
||||||
|
// since we mess with global state, we need a lock to synchronize us when called in parallel during tests
|
||||||
|
removeKlogGlobalFlagsLock.Lock()
|
||||||
|
defer removeKlogGlobalFlagsLock.Unlock()
|
||||||
|
|
||||||
// if this function starts to panic, it likely means that klog stopped mucking with global flags
|
// if this function starts to panic, it likely means that klog stopped mucking with global flags
|
||||||
const globalLogFlushFlag = "log-flush-frequency"
|
const globalLogFlushFlag = "log-flush-frequency"
|
||||||
if err := pflag.CommandLine.MarkHidden(globalLogFlushFlag); err != nil {
|
if err := pflag.CommandLine.MarkHidden(globalLogFlushFlag); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user