Skip to content

Commit

Permalink
Merge pull request kubernetes#113835 from zshihang/master
Browse files Browse the repository at this point in the history
fix test flake in TestLegacyServiceAccountTokenTracking
  • Loading branch information
k8s-ci-robot committed Nov 11, 2022
2 parents 520e2c8 + 6784610 commit cf12a74
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/integration/serviceaccount/service_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,18 +371,26 @@ func TestLegacyServiceAccountTokenTracking(t *testing.T) {
myConfig.BearerToken = string(test.secretTokenData)
roClient := clientset.NewForConfigOrDie(&myConfig)
dateBefore := time.Now().UTC().Format(dateFormat)
go func() {
doServiceAccountAPIRequests(t, roClient, myns, true, true, false)
}()
doServiceAccountAPIRequests(t, roClient, myns, true, true, false)

var wg sync.WaitGroup
concurrency := 5
for i := 0; i < concurrency; i++ {
wg.Add(1)
go func() {
doServiceAccountAPIRequests(t, roClient, myns, true, true, false)
wg.Done()
}()
}
wg.Wait()
dateAfter := time.Now().UTC().Format(dateFormat)
liveSecret, err := c.CoreV1().Secrets(myns).Get(context.TODO(), test.secretName, metav1.GetOptions{})
if err != nil {
t.Fatalf("Could not get secret: %v", err)
}

if test.expectWarning && len(wh.warnings) != 8 {
t.Fatalf("Expect 8 warnings, got %d", len(wh.warnings))
// doServiceAccountAPIRequests has 4 API requests
if test.expectWarning && len(wh.warnings) != 4*concurrency {
t.Fatalf("Expect %d warnings, got %d", 4*concurrency, len(wh.warnings))
}
if !test.expectWarning && len(wh.warnings) != 0 {
t.Fatalf("Don't expect warnings, got %d", len(wh.warnings))
Expand Down

0 comments on commit cf12a74

Please sign in to comment.