From 673a22eae8195dd2a08a40f8a4a6295630d61d58 Mon Sep 17 00:00:00 2001 From: Kobayashi Daisuke Date: Thu, 16 Apr 2020 16:47:19 +0900 Subject: [PATCH] Add test case in scheduler/profile/profile_test.go to improve the test coverage: check invalid configs --- pkg/scheduler/profile/profile_test.go | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/pkg/scheduler/profile/profile_test.go b/pkg/scheduler/profile/profile_test.go index 7733e045d4d..a0013ad78a4 100644 --- a/pkg/scheduler/profile/profile_test.go +++ b/pkg/scheduler/profile/profile_test.go @@ -82,6 +82,20 @@ func TestNewProfile(t *testing.T) { }, wantErr: "at least one bind plugin is needed", }, + { + name: "one queue sort plugin required for profile", + cfg: config.KubeSchedulerProfile{ + SchedulerName: "profile-1", + Plugins: &config.Plugins{ + Bind: &config.PluginSet{ + Enabled: []config.Plugin{ + {Name: "Bind1"}, + }, + }, + }, + }, + wantErr: "no queue sort plugin is enabled", + }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { @@ -273,6 +287,35 @@ func TestNewMap(t *testing.T) { }, wantErr: "duplicate profile", }, + { + name: "scheduler name is needed", + cfgs: []config.KubeSchedulerProfile{ + { + Plugins: &config.Plugins{ + QueueSort: &config.PluginSet{ + Enabled: []config.Plugin{ + {Name: "QueueSort"}, + }, + }, + Bind: &config.PluginSet{ + Enabled: []config.Plugin{ + {Name: "Bind1"}, + }, + }, + }, + }, + }, + wantErr: "scheduler name is needed", + }, + { + name: "plugins required for profile", + cfgs: []config.KubeSchedulerProfile{ + { + SchedulerName: "profile-1", + }, + }, + wantErr: "plugins required for profile", + }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) {