Fix staticcheck in test/integration/{scheduler_perf,garbagecollector}

This commit is contained in:
tiloso 2021-01-06 21:37:19 +01:00
parent 18605d8814
commit e1ceac0783
3 changed files with 4 additions and 9 deletions

View File

@ -1,8 +1,6 @@
cluster/images/etcd/migrate cluster/images/etcd/migrate
pkg/controller/replicaset pkg/controller/replicaset
pkg/kubelet/dockershim pkg/kubelet/dockershim
test/integration/garbagecollector
test/integration/scheduler_perf
vendor/k8s.io/apimachinery/pkg/api/apitesting/roundtrip vendor/k8s.io/apimachinery/pkg/api/apitesting/roundtrip
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation
vendor/k8s.io/apimachinery/pkg/runtime/serializer/json vendor/k8s.io/apimachinery/pkg/runtime/serializer/json

View File

@ -598,6 +598,7 @@ func setupRCsPods(t *testing.T, gc *garbagecollector.GarbageCollector, clientSet
} }
orphan := false orphan := false
switch { switch {
//lint:file-ignore SA1019 Keep testing deprecated OrphanDependents option until it's being removed
case options.OrphanDependents == nil && options.PropagationPolicy == nil && len(initialFinalizers) == 0: case options.OrphanDependents == nil && options.PropagationPolicy == nil && len(initialFinalizers) == 0:
// if there are no deletion options, the default policy for replication controllers is orphan // if there are no deletion options, the default policy for replication controllers is orphan
orphan = true orphan = true
@ -1024,12 +1025,7 @@ func TestBlockingOwnerRefDoesBlock(t *testing.T) {
// dependency graph before handling the foreground deletion of the rc. // dependency graph before handling the foreground deletion of the rc.
ctx.startGC(5) ctx.startGC(5)
timeout := make(chan struct{}) timeout := make(chan struct{})
go func() { time.AfterFunc(5*time.Second, func() { close(timeout) })
select {
case <-time.After(5 * time.Second):
close(timeout)
}
}()
if !cache.WaitForCacheSync(timeout, gc.IsSynced) { if !cache.WaitForCacheSync(timeout, gc.IsSynced) {
t.Fatalf("failed to wait for garbage collector to be synced") t.Fatalf("failed to wait for garbage collector to be synced")
} }

View File

@ -439,6 +439,7 @@ func benchmarkScheduling(numExistingPods, minPods int,
testPodStrategy testutils.TestPodCreateStrategy, testPodStrategy testutils.TestPodCreateStrategy,
b *testing.B) { b *testing.B) {
if b.N < minPods { if b.N < minPods {
//lint:ignore SA3001 Set a minimum for b.N to get more meaningful results
b.N = minPods b.N = minPods
} }
finalFunc, podInformer, clientset := mustSetupScheduler() finalFunc, podInformer, clientset := mustSetupScheduler()
@ -498,7 +499,7 @@ func benchmarkScheduling(numExistingPods, minPods int,
b.StopTimer() b.StopTimer()
} }
// makeBasePodWithSecrets creates a Pod object to be used as a template. // makeBasePodWithSecret creates a Pod object to be used as a template.
// The pod uses a single Secrets volume. // The pod uses a single Secrets volume.
func makeBasePodWithSecret() *v1.Pod { func makeBasePodWithSecret() *v1.Pod {
basePod := &v1.Pod{ basePod := &v1.Pod{