mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #113835 from zshihang/master
fix test flake in TestLegacyServiceAccountTokenTracking
This commit is contained in:
commit
cf12a74b18
@ -371,18 +371,26 @@ func TestLegacyServiceAccountTokenTracking(t *testing.T) {
|
|||||||
myConfig.BearerToken = string(test.secretTokenData)
|
myConfig.BearerToken = string(test.secretTokenData)
|
||||||
roClient := clientset.NewForConfigOrDie(&myConfig)
|
roClient := clientset.NewForConfigOrDie(&myConfig)
|
||||||
dateBefore := time.Now().UTC().Format(dateFormat)
|
dateBefore := time.Now().UTC().Format(dateFormat)
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
concurrency := 5
|
||||||
|
for i := 0; i < concurrency; i++ {
|
||||||
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
doServiceAccountAPIRequests(t, roClient, myns, true, true, false)
|
doServiceAccountAPIRequests(t, roClient, myns, true, true, false)
|
||||||
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
doServiceAccountAPIRequests(t, roClient, myns, true, true, false)
|
}
|
||||||
|
wg.Wait()
|
||||||
dateAfter := time.Now().UTC().Format(dateFormat)
|
dateAfter := time.Now().UTC().Format(dateFormat)
|
||||||
liveSecret, err := c.CoreV1().Secrets(myns).Get(context.TODO(), test.secretName, metav1.GetOptions{})
|
liveSecret, err := c.CoreV1().Secrets(myns).Get(context.TODO(), test.secretName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get secret: %v", err)
|
t.Fatalf("Could not get secret: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if test.expectWarning && len(wh.warnings) != 8 {
|
// doServiceAccountAPIRequests has 4 API requests
|
||||||
t.Fatalf("Expect 8 warnings, got %d", len(wh.warnings))
|
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 {
|
if !test.expectWarning && len(wh.warnings) != 0 {
|
||||||
t.Fatalf("Don't expect warnings, got %d", len(wh.warnings))
|
t.Fatalf("Don't expect warnings, got %d", len(wh.warnings))
|
||||||
|
Loading…
Reference in New Issue
Block a user