Merge pull request #81885 from mattjmcnaughton/mattjmcnaughton/fix-staticcheck-kubelet-test-integration

Fix `test/integration/kubelet` staticcheck failures
This commit is contained in:
Kubernetes Prow Robot 2019-10-05 00:59:13 -07:00 committed by GitHub
commit 285dd49444
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View File

@ -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

View File

@ -61,6 +61,7 @@ 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) {
@ -68,17 +69,27 @@ func TestWatchBasedManager(t *testing.T) {
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) {
@ -99,7 +110,10 @@ 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)
@ -107,5 +121,11 @@ func TestWatchBasedManager(t *testing.T) {
}
}(i)
}
wg.Wait()
select {
case err = <-errCh:
t.Fatal(err)
default:
}
}