From 33f6625a843af4c9cfa53a7add8aa44c838f370f Mon Sep 17 00:00:00 2001 From: Cao Shufeng Date: Tue, 28 Nov 2017 17:40:35 +0800 Subject: [PATCH] fix scheduling queue unit test This change makes sure the Pop() test finish completely. --- plugin/pkg/scheduler/core/scheduling_queue_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/pkg/scheduler/core/scheduling_queue_test.go b/plugin/pkg/scheduler/core/scheduling_queue_test.go index 343b7593bf5..cd3ba05db9b 100644 --- a/plugin/pkg/scheduler/core/scheduling_queue_test.go +++ b/plugin/pkg/scheduler/core/scheduling_queue_test.go @@ -18,6 +18,7 @@ package core import ( "reflect" + "sync" "testing" "k8s.io/api/core/v1" @@ -87,12 +88,16 @@ func TestPriorityQueue_Add(t *testing.T) { func TestPriorityQueue_Pop(t *testing.T) { q := NewPriorityQueue() + wg := sync.WaitGroup{} + wg.Add(1) go func() { + defer wg.Done() if p, err := q.Pop(); err != nil || p != &highPriorityPod { t.Errorf("Expected: %v after Pop, but got: %v", highPriorityPod.Name, p.Name) } }() q.Add(&highPriorityPod) + wg.Wait() } func TestPriorityQueue_Update(t *testing.T) {