diff --git a/Makefile b/Makefile index 1c5fef127..a910a5892 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,10 @@ clean: rm -rf _output rm -rf _tmp -verify: verify-gofmt verify-vendor lint lint-chart verify-spelling verify-toc verify-gen +verify: verify-govet verify-spelling verify-gofmt verify-vendor lint lint-chart verify-toc verify-gen + +verify-govet: + ./hack/verify-govet.sh verify-spelling: ./hack/verify-spelling.sh diff --git a/hack/verify-govet.sh b/hack/verify-govet.sh new file mode 100755 index 000000000..d834fd12d --- /dev/null +++ b/hack/verify-govet.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Copyright 2021 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source "$(dirname "${BASH_SOURCE}")/lib/init.sh" + +go vet ${OS_ROOT}/... diff --git a/pkg/descheduler/descheduler_test.go b/pkg/descheduler/descheduler_test.go index d3c95e771..9b00e9b5b 100644 --- a/pkg/descheduler/descheduler_test.go +++ b/pkg/descheduler/descheduler_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" fakeclientset "k8s.io/client-go/kubernetes/fake" @@ -44,15 +44,21 @@ func TestTaintsUpdated(t *testing.T) { } rs.Client = client rs.DeschedulingInterval = 100 * time.Millisecond + errChan := make(chan error, 1) + defer close(errChan) go func() { err := RunDeschedulerStrategies(ctx, rs, dp, "v1beta1", stopChannel) + errChan <- err + }() + select { + case err := <-errChan: if err != nil { t.Fatalf("Unable to run descheduler strategies: %v", err) } - }() + case <-time.After(300 * time.Millisecond): + // Wait for few cycles and then verify the only pod still exists + } - // Wait for few cycles and then verify the only pod still exists - time.Sleep(300 * time.Millisecond) pods, err := client.CoreV1().Pods(p1.Namespace).List(ctx, metav1.ListOptions{}) if err != nil { t.Errorf("Unable to list pods: %v", err)