Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test/integration/kubelet staticcheck failures #81885

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion hack/.staticcheck_failures
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ test/integration/etcd
test/integration/examples
test/integration/framework
test/integration/garbagecollector
test/integration/kubelet
test/integration/master
test/integration/replicationcontroller
test/integration/scale
Expand Down
24 changes: 22 additions & 2 deletions test/integration/kubelet/watch_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,35 @@ func TestWatchBasedManager(t *testing.T) {
// create 1000 secrets in parallel
t.Log(time.Now(), "creating 1000 secrets")
wg := sync.WaitGroup{}
errCh := make(chan error, 1)
for i := 0; i < 10; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
for j := 0; j < 100; j++ {
name := fmt.Sprintf("s%d", i*100+j)
if _, err := client.CoreV1().Secrets(testNamespace).Create(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: name}}); err != nil {
t.Fatal(err)
select {
case errCh <- err:
default:
}
}
}
fmt.Print(".")
}(i)
}

wg.Wait()
select {
case err := <-errCh:
t.Fatal(err)
default:
}
t.Log(time.Now(), "finished creating 1000 secrets")

// fetch all secrets
wg = sync.WaitGroup{}
errCh = make(chan error, 1)
for i := 0; i < 10; i++ {
wg.Add(1)
go func(i int) {
Expand All @@ -99,13 +110,22 @@ func TestWatchBasedManager(t *testing.T) {
return true, nil
})
if err != nil {
t.Fatalf("failed on %s: %v", name, err)
select {
case errCh <- fmt.Errorf("failed on :%s: %v", name, err):
default:
}
}
if d := time.Since(start); d > time.Second {
t.Logf("%s took %v", name, d)
}
}
}(i)
}

wg.Wait()
select {
case err = <-errCh:
t.Fatal(err)
default:
}
}