mirror of https://github.com/k3s-io/k3s
Merge pull request #66471 from islinwb/improve_TestZeroRequest
Automatic merge from submit-queue (batch tested with PRs 66291, 66471, 66499). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Improve unit test TestZeroRequest **What this PR does / why we need it**: **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #66468 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/8/head
commit
4dbcf32b3c
|
@ -615,6 +615,7 @@ func TestZeroRequest(t *testing.T) {
|
||||||
pods []*v1.Pod
|
pods []*v1.Pod
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
name string
|
name string
|
||||||
|
expectedScore int
|
||||||
}{
|
}{
|
||||||
// The point of these next two tests is to show you get the same priority for a zero-request pod
|
// The point of these next two tests is to show you get the same priority for a zero-request pod
|
||||||
// as for a pod with the defaults requests, both when the zero-request pod is already on the machine
|
// as for a pod with the defaults requests, both when the zero-request pod is already on the machine
|
||||||
|
@ -627,6 +628,7 @@ func TestZeroRequest(t *testing.T) {
|
||||||
{Spec: large1}, {Spec: noResources1},
|
{Spec: large1}, {Spec: noResources1},
|
||||||
{Spec: large2}, {Spec: small2},
|
{Spec: large2}, {Spec: small2},
|
||||||
},
|
},
|
||||||
|
expectedScore: 25,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &v1.Pod{Spec: small},
|
pod: &v1.Pod{Spec: small},
|
||||||
|
@ -636,6 +638,7 @@ func TestZeroRequest(t *testing.T) {
|
||||||
{Spec: large1}, {Spec: noResources1},
|
{Spec: large1}, {Spec: noResources1},
|
||||||
{Spec: large2}, {Spec: small2},
|
{Spec: large2}, {Spec: small2},
|
||||||
},
|
},
|
||||||
|
expectedScore: 25,
|
||||||
},
|
},
|
||||||
// The point of this test is to verify that we're not just getting the same score no matter what we schedule.
|
// The point of this test is to verify that we're not just getting the same score no matter what we schedule.
|
||||||
{
|
{
|
||||||
|
@ -646,10 +649,10 @@ func TestZeroRequest(t *testing.T) {
|
||||||
{Spec: large1}, {Spec: noResources1},
|
{Spec: large1}, {Spec: noResources1},
|
||||||
{Spec: large2}, {Spec: small2},
|
{Spec: large2}, {Spec: small2},
|
||||||
},
|
},
|
||||||
|
expectedScore: 23,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedPriority int = 25
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
// This should match the configuration in defaultPriorities() in
|
// This should match the configuration in defaultPriorities() in
|
||||||
|
@ -683,14 +686,8 @@ func TestZeroRequest(t *testing.T) {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
for _, hp := range list {
|
for _, hp := range list {
|
||||||
if test.name == "test priority of larger pod with machine with zero-request pod" {
|
if hp.Score != test.expectedScore {
|
||||||
if hp.Score == expectedPriority {
|
t.Errorf("expected %d for all priorities, got list %#v", test.expectedScore, list)
|
||||||
t.Errorf("expected non-%d for all priorities, got list %#v", expectedPriority, list)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if hp.Score != expectedPriority {
|
|
||||||
t.Errorf("expected %d for all priorities, got list %#v", expectedPriority, list)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue