diff --git a/pkg/scheduler/actions/allocate/allocate_test.go b/pkg/scheduler/actions/allocate/allocate_test.go index 16f2eb63ff..3aff6b8895 100644 --- a/pkg/scheduler/actions/allocate/allocate_test.go +++ b/pkg/scheduler/actions/allocate/allocate_test.go @@ -165,7 +165,7 @@ func TestAllocate(t *testing.T) { for i, test := range tests { t.Run(test.Name, func(t *testing.T) { test.Plugins = plugins - test.RegistSession(tiers, nil) + test.RegisterSession(tiers, nil) defer test.Close() test.Run([]framework.Action{New()}) if err := test.CheckAll(i); err != nil { diff --git a/pkg/scheduler/actions/preempt/preempt_test.go b/pkg/scheduler/actions/preempt/preempt_test.go index 72a9df95ad..3421f243cf 100644 --- a/pkg/scheduler/actions/preempt/preempt_test.go +++ b/pkg/scheduler/actions/preempt/preempt_test.go @@ -271,7 +271,7 @@ func TestPreempt(t *testing.T) { test.Plugins = plugins test.PriClass = []*schedulingv1.PriorityClass{highPrio, lowPrio} t.Run(test.Name, func(t *testing.T) { - test.RegistSession(tiers, nil) + test.RegisterSession(tiers, nil) defer test.Close() test.Run(actions) if err := test.CheckAll(i); err != nil { diff --git a/pkg/scheduler/actions/reclaim/reclaim_test.go b/pkg/scheduler/actions/reclaim/reclaim_test.go index eb3d905e21..824cd90694 100644 --- a/pkg/scheduler/actions/reclaim/reclaim_test.go +++ b/pkg/scheduler/actions/reclaim/reclaim_test.go @@ -87,7 +87,7 @@ func TestReclaim(t *testing.T) { }, } test.Plugins = plugins - test.RegistSession(tiers, nil) + test.RegisterSession(tiers, nil) test.Run([]framework.Action{reclaim}) if err := test.CheckAll(i); err != nil { t.Fatal(err) diff --git a/pkg/scheduler/actions/shuffle/shuffle_test.go b/pkg/scheduler/actions/shuffle/shuffle_test.go index 76c4dbbe3e..6c504c2e1a 100644 --- a/pkg/scheduler/actions/shuffle/shuffle_test.go +++ b/pkg/scheduler/actions/shuffle/shuffle_test.go @@ -109,7 +109,7 @@ func TestShuffle(t *testing.T) { } t.Run(test.Name, func(t *testing.T) { - ssn := test.RegistSession(tiers, nil) + ssn := test.RegisterSession(tiers, nil) defer test.Close() ssn.AddVictimTasksFns("fake", fakePluginVictimFns()) test.Run([]framework.Action{shuffle}) diff --git a/pkg/scheduler/plugins/binpack/binpack_test.go b/pkg/scheduler/plugins/binpack/binpack_test.go index 9302b1f13e..59019608f2 100644 --- a/pkg/scheduler/plugins/binpack/binpack_test.go +++ b/pkg/scheduler/plugins/binpack/binpack_test.go @@ -218,7 +218,7 @@ func TestNode(t *testing.T) { }, }, } - ssn := test.RegistSession(tiers, nil) + ssn := test.RegisterSession(tiers, nil) for _, job := range ssn.Jobs { for _, task := range job.Tasks { taskID := fmt.Sprintf("%s/%s", task.Namespace, task.Name) diff --git a/pkg/scheduler/plugins/drf/hdrf_test.go b/pkg/scheduler/plugins/drf/hdrf_test.go index 7e57550038..69b481f018 100644 --- a/pkg/scheduler/plugins/drf/hdrf_test.go +++ b/pkg/scheduler/plugins/drf/hdrf_test.go @@ -200,7 +200,7 @@ func TestHDRF(t *testing.T) { } for _, test := range tests { t.Run(t.Name(), func(t *testing.T) { - ssn := test.RegistSession(tiers, nil) + ssn := test.RegisterSession(tiers, nil) defer test.Close() test.Run([]framework.Action{allocate.New()}) for _, job := range ssn.Jobs { diff --git a/pkg/scheduler/plugins/numaaware/policy/policy_best_effort_test.go b/pkg/scheduler/plugins/numaaware/policy/policy_best_effort_test.go index e2e123e201..828258c1a5 100644 --- a/pkg/scheduler/plugins/numaaware/policy/policy_best_effort_test.go +++ b/pkg/scheduler/plugins/numaaware/policy/policy_best_effort_test.go @@ -24,7 +24,7 @@ import ( ) func Test_best_effort_predicate(t *testing.T) { - teseCases := []struct { + testCases := []struct { name string providersHints []map[string][]TopologyHint expect TopologyHint @@ -312,7 +312,7 @@ func Test_best_effort_predicate(t *testing.T) { }, } - for _, testcase := range teseCases { + for _, testcase := range testCases { policy := NewPolicyBestEffort([]int{0, 1}) bestHit, _ := policy.Predicate(testcase.providersHints) if !reflect.DeepEqual(bestHit, testcase.expect) { diff --git a/pkg/scheduler/plugins/numaaware/policy/policy_none_test.go b/pkg/scheduler/plugins/numaaware/policy/policy_none_test.go new file mode 100644 index 0000000000..ed531006e5 --- /dev/null +++ b/pkg/scheduler/plugins/numaaware/policy/policy_none_test.go @@ -0,0 +1,44 @@ +/* +Copyright 2024 The Volcano 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. +*/ + +package policy + +import ( + "reflect" + "testing" +) + +func Test_none_predicate(t *testing.T) { + testCases := []struct { + name string + providersHints []map[string][]TopologyHint + expect TopologyHint + }{ + { + name: "test-1", + providersHints: []map[string][]TopologyHint{}, + expect: TopologyHint{}, + }, + } + + for _, testcase := range testCases { + policy := NewPolicyNone([]int{0, 1}) + bestHit, _ := policy.Predicate(testcase.providersHints) + if !reflect.DeepEqual(bestHit, testcase.expect) { + t.Errorf("%s failed, expect %v, bestHit= %v\n", testcase.name, testcase.expect, bestHit) + } + } +} diff --git a/pkg/scheduler/plugins/numaaware/policy/policy_restricted_test.go b/pkg/scheduler/plugins/numaaware/policy/policy_restricted_test.go index 2e2d2c030b..c1054bfa29 100644 --- a/pkg/scheduler/plugins/numaaware/policy/policy_restricted_test.go +++ b/pkg/scheduler/plugins/numaaware/policy/policy_restricted_test.go @@ -24,7 +24,7 @@ import ( ) func Test_restricted_predicate(t *testing.T) { - teseCases := []struct { + testCases := []struct { name string providersHints []map[string][]TopologyHint expect TopologyHint @@ -312,7 +312,7 @@ func Test_restricted_predicate(t *testing.T) { }, } - for _, testcase := range teseCases { + for _, testcase := range testCases { policy := NewPolicyRestricted([]int{0, 1}) bestHit, _ := policy.Predicate(testcase.providersHints) if !reflect.DeepEqual(bestHit, testcase.expect) { diff --git a/pkg/scheduler/plugins/numaaware/policy/policy_single_numa_node_test.go b/pkg/scheduler/plugins/numaaware/policy/policy_single_numa_node_test.go index 1638b6ab09..5b041b9a68 100644 --- a/pkg/scheduler/plugins/numaaware/policy/policy_single_numa_node_test.go +++ b/pkg/scheduler/plugins/numaaware/policy/policy_single_numa_node_test.go @@ -24,7 +24,7 @@ import ( ) func Test_single_numa_node_predicate(t *testing.T) { - teseCases := []struct { + testCases := []struct { name string providersHints []map[string][]TopologyHint expect TopologyHint @@ -278,7 +278,7 @@ func Test_single_numa_node_predicate(t *testing.T) { }, } - for _, testcase := range teseCases { + for _, testcase := range testCases { policy := NewPolicySingleNumaNode([]int{0, 1}) bestHit, _ := policy.Predicate(testcase.providersHints) if !reflect.DeepEqual(bestHit, testcase.expect) { diff --git a/pkg/scheduler/plugins/predicates/predicates_test.go b/pkg/scheduler/plugins/predicates/predicates_test.go index 70bc1bff00..2525912922 100644 --- a/pkg/scheduler/plugins/predicates/predicates_test.go +++ b/pkg/scheduler/plugins/predicates/predicates_test.go @@ -111,7 +111,7 @@ func TestEventHandler(t *testing.T) { }, } t.Run(test.Name, func(t *testing.T) { - test.RegistSession(tiers, nil) + test.RegisterSession(tiers, nil) defer test.Close() test.Run(actions) if err := test.CheckAll(i); err != nil { diff --git a/pkg/scheduler/plugins/tdm/tdm_test.go b/pkg/scheduler/plugins/tdm/tdm_test.go index 08615890ee..6bd10d1a28 100644 --- a/pkg/scheduler/plugins/tdm/tdm_test.go +++ b/pkg/scheduler/plugins/tdm/tdm_test.go @@ -228,7 +228,7 @@ func Test_TDM(t *testing.T) { }, }, } - ssn := test.RegistSession(tiers, nil) + ssn := test.RegisterSession(tiers, nil) defer test.Close() for _, job := range ssn.Jobs { @@ -541,7 +541,7 @@ func Test_TDM_victimsFn(t *testing.T) { }, }, } - ssn := test.RegistSession(tiers, nil) + ssn := test.RegisterSession(tiers, nil) defer test.Close() d, _ := time.ParseDuration(test.args[evictPeriodLabel].(string)) diff --git a/pkg/scheduler/uthelper/helper.go b/pkg/scheduler/uthelper/helper.go index 5334ece399..750eabe1ee 100644 --- a/pkg/scheduler/uthelper/helper.go +++ b/pkg/scheduler/uthelper/helper.go @@ -33,8 +33,8 @@ import ( "volcano.sh/volcano/pkg/scheduler/util" ) -// RegistPlugins plugins -func RegistPlugins(plugins map[string]framework.PluginBuilder) { +// RegisterPlugins plugins +func RegisterPlugins(plugins map[string]framework.PluginBuilder) { for name, plugin := range plugins { framework.RegisterPluginBuilder(name, plugin) } @@ -68,8 +68,8 @@ type TestCommonStruct struct { var _ Interface = &TestCommonStruct{} -// RegistSession open session with tiers and configuration, and mock schedulerCache with self-defined FakeBinder and FakeEvictor -func (test *TestCommonStruct) RegistSession(tiers []conf.Tier, config []conf.Configuration) *framework.Session { +// RegisterSession open session with tiers and configuration, and mock schedulerCache with self-defined FakeBinder and FakeEvictor +func (test *TestCommonStruct) RegisterSession(tiers []conf.Tier, config []conf.Configuration) *framework.Session { binder := &util.FakeBinder{ Binds: map[string]string{}, Channel: make(chan string), @@ -102,7 +102,7 @@ func (test *TestCommonStruct) RegistSession(tiers []conf.Tier, config []conf.Con schedulerCache.AddPriorityClass(pc) } - RegistPlugins(test.Plugins) + RegisterPlugins(test.Plugins) ssn := framework.OpenSession(schedulerCache, tiers, config) test.ssn = ssn schedulerCache.Run(test.stop) diff --git a/pkg/scheduler/uthelper/interface.go b/pkg/scheduler/uthelper/interface.go index b67d8c1761..9fbf21e5ee 100644 --- a/pkg/scheduler/uthelper/interface.go +++ b/pkg/scheduler/uthelper/interface.go @@ -25,8 +25,8 @@ import ( type Interface interface { // Run executes the actions Run(actions []framework.Action) - // RegistSession init the session - RegistSession(tiers []conf.Tier, config []conf.Configuration) *framework.Session + // RegisterSession init the session + RegisterSession(tiers []conf.Tier, config []conf.Configuration) *framework.Session // Close release session and do cleanup Close() // CheckAll do all checks