Merge pull request #86716 from SataQiu/staticcheck-20191230

Fix staticcheck failures of test/integration/scale test/integration/serviceaccount test/integration/serving test/integration/volume
This commit is contained in:
Kubernetes Prow Robot 2019-12-30 20:39:39 -08:00 committed by GitHub
commit d0c719dbd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 20 deletions

View File

@ -68,12 +68,8 @@ test/integration/framework
test/integration/garbagecollector test/integration/garbagecollector
test/integration/master test/integration/master
test/integration/replicationcontroller test/integration/replicationcontroller
test/integration/scale
test/integration/scheduler_perf test/integration/scheduler_perf
test/integration/serviceaccount
test/integration/serving
test/integration/ttlcontroller test/integration/ttlcontroller
test/integration/volume
vendor/k8s.io/apimachinery/pkg/api/meta vendor/k8s.io/apimachinery/pkg/api/meta
vendor/k8s.io/apimachinery/pkg/api/resource vendor/k8s.io/apimachinery/pkg/api/resource
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured

View File

@ -35,11 +35,6 @@ import (
"k8s.io/kubernetes/test/integration/framework" "k8s.io/kubernetes/test/integration/framework"
) )
type subresourceTest struct {
resource schema.GroupVersionResource
kind schema.GroupVersionKind
}
func makeGVR(group, version, resource string) schema.GroupVersionResource { func makeGVR(group, version, resource string) schema.GroupVersionResource {
return schema.GroupVersionResource{Group: group, Version: version, Resource: resource} return schema.GroupVersionResource{Group: group, Version: version, Resource: resource}
} }
@ -58,7 +53,7 @@ func TestScaleSubresources(t *testing.T) {
}) })
defer tearDown() defer tearDown()
resourceLists, err := clientSet.Discovery().ServerResources() _, resourceLists, err := clientSet.Discovery().ServerGroupsAndResources()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -206,10 +201,6 @@ var (
} }
) )
func setup(t *testing.T) (client kubernetes.Interface, tearDown func()) {
return setupWithOptions(t, nil, nil)
}
func setupWithOptions(t *testing.T, instanceOptions *apitesting.TestServerInstanceOptions, flags []string) (client kubernetes.Interface, tearDown func()) { func setupWithOptions(t *testing.T, instanceOptions *apitesting.TestServerInstanceOptions, flags []string) (client kubernetes.Interface, tearDown func()) {
result := apitesting.StartTestServerOrDie(t, instanceOptions, flags, framework.SharedEtcd()) result := apitesting.StartTestServerOrDie(t, instanceOptions, flags, framework.SharedEtcd())

View File

@ -115,7 +115,7 @@ func TestServiceAccountTokenAutoCreate(t *testing.T) {
} }
// Create service account // Create service account
serviceAccount, err := c.CoreV1().ServiceAccounts(ns).Create(&v1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: name}}) _, err = c.CoreV1().ServiceAccounts(ns).Create(&v1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: name}})
if err != nil { if err != nil {
t.Fatalf("Service Account not created: %v", err) t.Fatalf("Service Account not created: %v", err)
} }
@ -145,7 +145,7 @@ func TestServiceAccountTokenAutoCreate(t *testing.T) {
} }
// Trigger creation of a new referenced token // Trigger creation of a new referenced token
serviceAccount, err = c.CoreV1().ServiceAccounts(ns).Get(name, metav1.GetOptions{}) serviceAccount, err := c.CoreV1().ServiceAccounts(ns).Get(name, metav1.GetOptions{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -292,6 +292,9 @@ func testComponent(t *testing.T, tester componentTester, kubeconfig, brokenKubec
} }
body, err := ioutil.ReadAll(r.Body) body, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatalf("failed to read response body: %v", err)
}
defer r.Body.Close() defer r.Body.Close()
if got, expected := r.StatusCode, *tt.wantSecureCode; got != expected { if got, expected := r.StatusCode, *tt.wantSecureCode; got != expected {
t.Fatalf("expected http %d at %s of component, got: %d %q", expected, tt.path, got, string(body)) t.Fatalf("expected http %d at %s of component, got: %d %q", expected, tt.path, got, string(body))
@ -307,6 +310,9 @@ func testComponent(t *testing.T, tester componentTester, kubeconfig, brokenKubec
t.Fatalf("failed to GET %s from component: %v", tt.path, err) t.Fatalf("failed to GET %s from component: %v", tt.path, err)
} }
body, err := ioutil.ReadAll(r.Body) body, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatalf("failed to read response body: %v", err)
}
defer r.Body.Close() defer r.Body.Close()
if got, expected := r.StatusCode, *tt.wantInsecureCode; got != expected { if got, expected := r.StatusCode, *tt.wantInsecureCode; got != expected {
t.Fatalf("expected http %d at %s of component, got: %d %q", expected, tt.path, got, string(body)) t.Fatalf("expected http %d at %s of component, got: %d %q", expected, tt.path, got, string(body))

View File

@ -132,8 +132,6 @@ func fakePodWithPVC(name, pvcName, namespace string) (*v1.Pod, *v1.PersistentVol
return fakePod, fakePVC return fakePod, fakePVC
} }
type podCountFunc func(int) bool
var defaultTimerConfig = attachdetach.TimerConfig{ var defaultTimerConfig = attachdetach.TimerConfig{
ReconcilerLoopPeriod: 100 * time.Millisecond, ReconcilerLoopPeriod: 100 * time.Millisecond,
ReconcilerMaxWaitForUnmountDuration: 6 * time.Second, ReconcilerMaxWaitForUnmountDuration: 6 * time.Second,

View File

@ -666,11 +666,10 @@ func TestPersistentVolumeMultiPVsPVCs(t *testing.T) {
select { select {
case <-stopCh: case <-stopCh:
break return
default: default:
continue continue
} }
} }
}() }()