Yet more debugging of tests which only fail in main CI

This commit is contained in:
Ryan Richard 2021-05-17 14:20:41 -07:00
parent 8c660f09bc
commit 99099fd32f
1 changed files with 10 additions and 4 deletions

View File

@ -14,6 +14,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"k8s.io/apiserver/pkg/authentication/authenticator" "k8s.io/apiserver/pkg/authentication/authenticator"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
@ -404,7 +406,10 @@ func TestSimultaneousRequestsOnSingleProvider(t *testing.T) {
resultCh := make(chan authUserResult, iterations) resultCh := make(chan authUserResult, iterations)
for i := 0; i < iterations; i++ { for i := 0; i < iterations; i++ {
go func() { go func() {
authResponse, authenticated, err := provider.AuthenticateUser(ctx, authUserCtx, authUserCtxCancelFunc := context.WithTimeout(context.Background(), 2*time.Minute)
defer authUserCtxCancelFunc()
authResponse, authenticated, err := provider.AuthenticateUser(authUserCtx,
env.SupervisorUpstreamLDAP.TestUserCN, env.SupervisorUpstreamLDAP.TestUserPassword, env.SupervisorUpstreamLDAP.TestUserCN, env.SupervisorUpstreamLDAP.TestUserPassword,
) )
resultCh <- authUserResult{ resultCh <- authUserResult{
@ -416,9 +421,10 @@ func TestSimultaneousRequestsOnSingleProvider(t *testing.T) {
} }
for i := 0; i < iterations; i++ { for i := 0; i < iterations; i++ {
result := <-resultCh result := <-resultCh
require.NoError(t, result.err) // Record failures but allow the test to keep running so that all the background goroutines have a chance to try.
require.True(t, result.authenticated, "expected the user to be authenticated, but they were not") assert.NoError(t, result.err)
require.Equal(t, &authenticator.Response{ assert.True(t, result.authenticated, "expected the user to be authenticated, but they were not")
assert.Equal(t, &authenticator.Response{
User: &user.DefaultInfo{Name: "pinny", UID: "1000", Groups: []string{}}, User: &user.DefaultInfo{Name: "pinny", UID: "1000", Groups: []string{}},
}, result.response) }, result.response)
} }