"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/scheduler/internal/queue/scheduling_queue_test.go" between
kubernetes-1.15.9.tar.gz and kubernetes-1.15.10.tar.gz

About: Kubernetes is a platform for automating deployment, scaling, and operations of application containers across clusters of hosts (written in "Go"). 1.15.x series.

scheduling_queue_test.go  (kubernetes-1.15.9):scheduling_queue_test.go  (kubernetes-1.15.10)
skipping to change at line 31 skipping to change at line 31
"reflect" "reflect"
"sync" "sync"
"testing" "testing"
"time" "time"
dto "github.com/prometheus/client_model/go" dto "github.com/prometheus/client_model/go"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/clock"
"k8s.io/client-go/tools/cache"
podutil "k8s.io/kubernetes/pkg/api/v1/pod" podutil "k8s.io/kubernetes/pkg/api/v1/pod"
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache" internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
"k8s.io/kubernetes/pkg/scheduler/metrics" "k8s.io/kubernetes/pkg/scheduler/metrics"
"k8s.io/kubernetes/pkg/scheduler/util" "k8s.io/kubernetes/pkg/scheduler/util"
) )
var negPriority, lowPriority, midPriority, highPriority, veryHighPriority = int3 2(-100), int32(0), int32(100), int32(1000), int32(10000) var negPriority, lowPriority, midPriority, highPriority, veryHighPriority = int3 2(-100), int32(0), int32(100), int32(1000), int32(10000)
var mediumPriority = (lowPriority + highPriority) / 2 var mediumPriority = (lowPriority + highPriority) / 2
var highPriorityPod, highPriNominatedPod, medPriorityPod, unschedulablePod = v1. Pod{ var highPriorityPod, highPriNominatedPod, medPriorityPod, unschedulablePod = v1. Pod{
skipping to change at line 1332 skipping to change at line 1333
if err := metrics.UnschedulablePods.Write(metricProto); e rr != nil { if err := metrics.UnschedulablePods.Write(metricProto); e rr != nil {
t.Errorf("error writing UnschedulablePods metric: %v", err) t.Errorf("error writing UnschedulablePods metric: %v", err)
} }
unschedulableNum = metricProto.Gauge.GetValue() unschedulableNum = metricProto.Gauge.GetValue()
if int64(unschedulableNum) != test.expected[2] { if int64(unschedulableNum) != test.expected[2] {
t.Errorf("UnschedulablePods: Expected %v, got %v" , test.expected[2], unschedulableNum) t.Errorf("UnschedulablePods: Expected %v, got %v" , test.expected[2], unschedulableNum)
} }
}) })
} }
} }
func TestBackOffFlow(t *testing.T) {
cl := clock.NewFakeClock(time.Now())
q := NewPriorityQueueWithClock(nil, cl, nil)
steps := []struct {
wantBackoff time.Duration
}{
{wantBackoff: time.Second},
{wantBackoff: 2 * time.Second},
{wantBackoff: 4 * time.Second},
{wantBackoff: 8 * time.Second},
{wantBackoff: 10 * time.Second},
{wantBackoff: 10 * time.Second},
{wantBackoff: 10 * time.Second},
}
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pod",
Namespace: "test-ns",
UID: "test-uid",
},
}
podID := nsNameForPod(pod)
podKey, err := cache.MetaNamespaceKeyFunc(pod)
if err != nil {
t.Fatal(err)
}
if err := q.Add(pod); err != nil {
t.Fatal(err)
}
for i, step := range steps {
t.Run(fmt.Sprintf("step %d", i), func(t *testing.T) {
timestamp := cl.Now()
// Simulate schedule attempt.
pod, err := q.Pop()
if err != nil {
t.Fatal(err)
}
if err := q.AddUnschedulableIfNotPresent(pod, int64(i));
err != nil {
t.Fatal(err)
}
// An event happens.
q.MoveAllToActiveQueue()
if _, ok, _ := q.podBackoffQ.GetByKey(podKey); !ok {
t.Errorf("pod %v is not in the backoff queue", po
dID)
}
// Check backoff duration.
deadline, ok := q.podBackoff.GetBackoffTime(podID)
if !ok {
t.Errorf("didn't get backoff for pod %s", podID)
}
backoff := deadline.Sub(timestamp)
if backoff != step.wantBackoff {
t.Errorf("got backoff %s, want %s", backoff, step
.wantBackoff)
}
// Simulate routine that continuously flushes the backoff
queue.
cl.Step(time.Millisecond)
q.flushBackoffQCompleted()
// Still in backoff queue after an early flush.
if _, ok, _ := q.podBackoffQ.GetByKey(podKey); !ok {
t.Errorf("pod %v is not in the backoff queue", po
dID)
}
// Moved out of the backoff queue after timeout.
cl.Step(backoff)
q.flushBackoffQCompleted()
if _, ok, _ := q.podBackoffQ.GetByKey(podKey); ok {
t.Errorf("pod %v is still in the backoff queue",
podID)
}
})
}
// After some time, backoff information is cleared.
cl.Step(time.Hour)
q.podBackoff.CleanupPodsCompletesBackingoff()
_, ok := q.podBackoff.GetBackoffTime(podID)
if ok {
t.Errorf("backoff information for pod %s was not cleared", podID)
}
}
 End of changes. 2 change blocks. 
0 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)