1 Star 0 Fork 46

wangzihao/ascend-for-volcano

forked from Ascend/ascend-for-volcano 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
huawei_npu_test.go 3.72 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright(C)2020-2022. Huawei Technologies Co.,Ltd. All rights reserved.
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 main is using for HuaWei Ascend pin affinity schedule.
*/
package main
import (
"testing"
"volcano.sh/volcano/pkg/scheduler/framework"
"volcano.sh/volcano/pkg/scheduler/plugins/ascend-volcano-plugin/plugin"
"volcano.sh/volcano/pkg/scheduler/plugins/ascend-volcano-plugin/test"
)
type handlerStartTest struct {
name string
want *plugin.ScheduleHandler
}
func buildTestHandlerStartTestCases() []handlerStartTest {
testCases := []handlerStartTest{
{
name: "HandlerStart ok test",
want: &plugin.ScheduleHandler{},
},
}
return testCases
}
func TestHandlerStart(t *testing.T) {
tests := buildTestHandlerStartTestCases()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := HandlerStart(); got == nil {
t.Errorf("HandlerStart() = %v, want %v", got, tt.want)
}
})
}
}
func TestName(t *testing.T) {
tests := []struct {
name string
tp *huaweiNPUPlugin
want string
}{
{
name: "01-Name ok test",
tp: &huaweiNPUPlugin{},
want: PluginName,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.tp.Name(); got != tt.want {
t.Errorf("Name() = %v, want %v", got, tt.want)
}
})
}
}
func TestNew(t *testing.T) {
type args struct {
arguments framework.Arguments
}
tests := []struct {
name string
args args
want framework.Plugin
}{
{
name: "New ok test",
args: args{arguments: framework.Arguments{PluginName: "haha"}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := New(tt.args.arguments); got == nil {
t.Errorf("New() = %v, want %v", got, tt.want)
}
})
}
}
type fields struct {
Scheduler *plugin.ScheduleHandler
Arguments framework.Arguments
}
type args struct {
ssn *framework.Session
cacheFunBefore func()
cacheFunAfter func()
}
type onSessionOpenTest struct {
name string
fields fields
args args
}
func buildOnSessionOpenTestCases() []onSessionOpenTest {
tests := []onSessionOpenTest{
{
name: "OnSessionOpen test ssn nil ok",
fields: fields{Scheduler: HandlerStart()},
args: args{ssn: nil, cacheFunBefore: func() {}, cacheFunAfter: func() {}},
},
}
return tests
}
func TestOnSessionOpen(t *testing.T) {
tests := buildOnSessionOpenTestCases()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tp := &huaweiNPUPlugin{
Scheduler: tt.fields.Scheduler,
Arguments: tt.fields.Arguments,
}
tt.args.cacheFunBefore()
tp.OnSessionOpen(tt.args.ssn)
tt.args.cacheFunAfter()
})
}
}
type onSessionCloseTest struct {
name string
fields fields
args args
}
func buildOnSessionCloseTestCases() []onSessionCloseTest {
testSsn := test.FakeNormalSSN()
tests := []onSessionCloseTest{
{
name: "OnSessionCloseTestCases test ok",
fields: fields{Scheduler: HandlerStart()},
args: args{ssn: testSsn},
},
}
return tests
}
func TestOnSessionClose(t *testing.T) {
tests := buildOnSessionCloseTestCases()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tp := &huaweiNPUPlugin{
Scheduler: tt.fields.Scheduler,
Arguments: tt.fields.Arguments,
}
tp.OnSessionClose(tt.args.ssn)
})
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/zhobb/ascend-for-volcano.git
git@gitee.com:zhobb/ascend-for-volcano.git
zhobb
ascend-for-volcano
ascend-for-volcano
master

搜索帮助