Skip to content

Commit

Permalink
Merge pull request #3467 from googs1025/fix_testcommonstruct
Browse files Browse the repository at this point in the history
fix testcommonstruct
  • Loading branch information
volcano-sh-bot authored May 15, 2024
2 parents 9ac82ff + f154433 commit 016d215
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 77 deletions.
12 changes: 6 additions & 6 deletions pkg/scheduler/actions/allocate/allocate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ func TestAllocate(t *testing.T) {
Queues: []*schedulingv1.Queue{
util.BuildQueue("c1", 1, nil),
},
BindMap: map[string]string{
ExpectBindMap: map[string]string{
"c1/p1": "n1",
"c1/p2": "n1",
},
BindsNum: 2,
ExpectBindsNum: 2,
},
{
Name: "two Jobs on one node",
Expand Down Expand Up @@ -102,11 +102,11 @@ func TestAllocate(t *testing.T) {
util.BuildQueue("c1", 1, nil),
util.BuildQueue("c2", 1, nil),
},
BindMap: map[string]string{
ExpectBindMap: map[string]string{
"c2/pg2-p-1": "n1",
"c1/pg1-p-1": "n1",
},
BindsNum: 2,
ExpectBindsNum: 2,
},
{
Name: "high priority queue should not block others",
Expand All @@ -128,10 +128,10 @@ func TestAllocate(t *testing.T) {
util.BuildQueue("c1", 1, nil),
util.BuildQueue("c2", 1, nil),
},
BindMap: map[string]string{
ExpectBindMap: map[string]string{
"c1/p2": "n1",
},
BindsNum: 1,
ExpectBindsNum: 1,
},
}

Expand Down
30 changes: 15 additions & 15 deletions pkg/scheduler/actions/preempt/preempt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, nil),
},
EvictNum: 0,
ExpectEvictNum: 0,
},
{
Name: "do not preempt if job is pipelined",
Expand All @@ -86,7 +86,7 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, nil),
},
EvictNum: 0,
ExpectEvictNum: 0,
},
{
Name: "preempt one task of different job to fit both jobs on one node",
Expand All @@ -106,8 +106,8 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, nil),
},
Evicted: []string{"c1/preemptee1"},
EvictNum: 1,
ExpectEvicted: []string{"c1/preemptee1"},
ExpectEvictNum: 1,
},
{
Name: "preempt enough tasks to fit large task of different job",
Expand All @@ -129,8 +129,8 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, nil),
},
Evicted: []string{"c1/preemptee2", "c1/preemptee1"},
EvictNum: 2,
ExpectEvicted: []string{"c1/preemptee2", "c1/preemptee1"},
ExpectEvictNum: 2,
},
{
// case about #3161
Expand All @@ -149,8 +149,8 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, api.BuildResourceList("4", "4G")),
},
Evicted: []string{"c1/preemptee1"},
EvictNum: 1,
ExpectEvicted: []string{"c1/preemptee1"},
ExpectEvictNum: 1,
},
{
// case about #3161
Expand All @@ -169,7 +169,7 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, api.BuildResourceList("6", "6G")),
},
EvictNum: 0,
ExpectEvictNum: 0,
},
{
// case about issue #2232
Expand All @@ -190,8 +190,8 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, api.BuildResourceList("3", "3G")),
},
Evicted: []string{"c1/preemptee2"},
EvictNum: 1,
ExpectEvicted: []string{"c1/preemptee2"},
ExpectEvictNum: 1,
},
{
// case about #3335
Expand All @@ -210,8 +210,8 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, api.BuildResourceList("6", "6G")),
},
Evicted: []string{"c1/preemptee1"},
EvictNum: 1,
ExpectEvicted: []string{"c1/preemptee1"},
ExpectEvictNum: 1,
},
{
// case about #3335
Expand All @@ -230,8 +230,8 @@ func TestPreempt(t *testing.T) {
Queues: []*schedulingv1beta1.Queue{
util.BuildQueue("q1", 1, api.BuildResourceList("6", "6G")),
},
Evicted: []string{"c1/preemptee1"},
EvictNum: 1,
ExpectEvicted: []string{"c1/preemptee1"},
ExpectEvictNum: 1,
},
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/scheduler/actions/reclaim/reclaim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func TestReclaim(t *testing.T) {
util.BuildQueue("q1", 1, nil),
util.BuildQueue("q2", 1, nil),
},
EvictNum: 1,
Evicted: []string{"c1/preemptee2"}, // let pod2 in the middle when sort tasks be preemptable and will not disturb
ExpectEvictNum: 1,
ExpectEvicted: []string{"c1/preemptee2"}, // let pod2 in the middle when sort tasks be preemptable and will not disturb
},
{
Name: "sort reclaimees when reclaiming from overusing queue",
Expand Down Expand Up @@ -96,8 +96,8 @@ func TestReclaim(t *testing.T) {
util.BuildQueue("q2", 1, nil),
util.BuildQueue("q3", 1, nil),
},
EvictNum: 1,
Evicted: []string{"c1/preemptee2-1"}, // low priority job's preemptable pod is evicted
ExpectEvictNum: 1,
ExpectEvicted: []string{"c1/preemptee2-1"}, // low priority job's preemptable pod is evicted
},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/actions/shuffle/shuffle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func TestShuffle(t *testing.T) {
util.BuildPodWithPriority("test", "pod3-1", "node2", v1.PodRunning, api.BuildResourceList("1", "2G"), "pg3", make(map[string]string), make(map[string]string), &lowPriority),
util.BuildPodWithPriority("test", "pod3-2", "node2", v1.PodRunning, api.BuildResourceList("1", "2G"), "pg3", make(map[string]string), make(map[string]string), &highPriority),
},
EvictNum: 3,
Evicted: []string{"test/pod1-1", "test/pod2-1", "test/pod3-1"},
ExpectEvictNum: 3,
ExpectEvicted: []string{"test/pod1-1", "test/pod2-1", "test/pod3-1"},
},
}
shuffle := New()
Expand Down
24 changes: 12 additions & 12 deletions pkg/scheduler/plugins/capacity/capacity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ func Test_capacityPlugin_OnSessionOpen(t *testing.T) {
Nodes: []*corev1.Node{n1, n2},
PodGroups: []*schedulingv1beta1.PodGroup{pg1, pg2},
Queues: []*schedulingv1beta1.Queue{queue1},
BindMap: map[string]string{
ExpectBindMap: map[string]string{
"ns1/p2": "n1",
},
BindsNum: 1,
ExpectBindsNum: 1,
},
{
Name: "case1: Pod not allocatable when queue exceed queue capability",
Plugins: plugins,
Pods: []*corev1.Pod{p3, p4},
Nodes: []*corev1.Node{n1, n2},
PodGroups: []*schedulingv1beta1.PodGroup{pg3, pg4},
Queues: []*schedulingv1beta1.Queue{queue2},
BindsNum: 0,
Name: "case1: Pod not allocatable when queue exceed queue capability",
Plugins: plugins,
Pods: []*corev1.Pod{p3, p4},
Nodes: []*corev1.Node{n1, n2},
PodGroups: []*schedulingv1beta1.PodGroup{pg3, pg4},
Queues: []*schedulingv1beta1.Queue{queue2},
ExpectBindsNum: 0,
},
{
Name: "case2: Can reclaim from other queues when allocated < deserved",
Expand All @@ -104,11 +104,11 @@ func Test_capacityPlugin_OnSessionOpen(t *testing.T) {
Nodes: []*corev1.Node{n1, n2},
PodGroups: []*schedulingv1beta1.PodGroup{pg5, pg6},
Queues: []*schedulingv1beta1.Queue{queue3, queue4},
PipeLined: map[string][]string{
ExpectPipeLined: map[string][]string{
"ns1/pg6": {"n2"},
},
Evicted: []string{"ns1/p6"},
EvictNum: 1,
ExpectEvicted: []string{"ns1/p6"},
ExpectEvictNum: 1,
},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/plugins/predicates/predicates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ func TestEventHandler(t *testing.T) {
PriClass: []*schedulingv1.PriorityClass{p1, p2},
PodGroups: []*schedulingv1beta1.PodGroup{pg1, pg2},
Queues: []*schedulingv1beta1.Queue{queue1},
BindMap: map[string]string{ // podKey -> node
ExpectBindMap: map[string]string{ // podKey -> node
"ns1/worker-3": "node1",
},
BindsNum: 1,
ExpectBindsNum: 1,
},
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/scheduler/plugins/tdm/tdm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n1,
},
EvictNum: 2,
ExpectEvictNum: 2,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:01",
Expand All @@ -358,7 +358,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n1,
},
EvictNum: 0,
ExpectEvictNum: 0,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:00",
Expand All @@ -380,7 +380,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n1,
},
EvictNum: 3,
ExpectEvictNum: 3,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:01",
Expand All @@ -402,7 +402,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n2,
},
EvictNum: 3,
ExpectEvictNum: 3,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:01",
Expand All @@ -426,7 +426,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n1, n2,
},
EvictNum: 6,
ExpectEvictNum: 6,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:01",
Expand All @@ -448,7 +448,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n2,
},
EvictNum: 3,
ExpectEvictNum: 3,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:01",
Expand All @@ -470,7 +470,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n2,
},
EvictNum: 2,
ExpectEvictNum: 2,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:01",
Expand All @@ -492,7 +492,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n2,
},
EvictNum: 3,
ExpectEvictNum: 3,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:01",
Expand All @@ -516,7 +516,7 @@ func Test_TDM_victimsFn(t *testing.T) {
Nodes: []*v1.Node{
n1, n2,
},
EvictNum: 6,
ExpectEvictNum: 6,
},
args: framework.Arguments{
"tdm.revocable-zone.rz1": "0:00-0:01",
Expand Down
Loading

0 comments on commit 016d215

Please sign in to comment.