Unverified Commit 9891d0a8 authored by Joseph's avatar Joseph Committed by GitHub
Browse files

koord-scheduler: fix DeviceShare UT (#594)

Signed-off-by: default avatarJoseph <joseph.t.lee@outlook.com>
parent b7d9def4
Showing with 12 additions and 0 deletions
+12 -0
...@@ -19,6 +19,7 @@ package deviceshare ...@@ -19,6 +19,7 @@ package deviceshare
import ( import (
"context" "context"
"fmt" "fmt"
"sort"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
...@@ -1416,12 +1417,23 @@ func Test_Plugin_Reserve(t *testing.T) { ...@@ -1416,12 +1417,23 @@ func Test_Plugin_Reserve(t *testing.T) {
status := p.Reserve(context.TODO(), cycleState, tt.args.pod, tt.args.nodeName) status := p.Reserve(context.TODO(), cycleState, tt.args.pod, tt.args.nodeName)
assert.Equal(t, tt.wants.status, status) assert.Equal(t, tt.wants.status, status)
if tt.wants.allocationResult != nil { if tt.wants.allocationResult != nil {
sortDeviceAllocations(tt.wants.allocationResult)
sortDeviceAllocations(tt.args.state.allocationResult)
assert.Equal(t, tt.wants.allocationResult, tt.args.state.allocationResult) assert.Equal(t, tt.wants.allocationResult, tt.args.state.allocationResult)
} }
}) })
} }
} }
func sortDeviceAllocations(deviceAllocations apiext.DeviceAllocations) {
for k, v := range deviceAllocations {
sort.Slice(v, func(i, j int) bool {
return v[i].Minor < v[j].Minor
})
deviceAllocations[k] = v
}
}
func Test_Plugin_Unreserve(t *testing.T) { func Test_Plugin_Unreserve(t *testing.T) {
namespacedName := types.NamespacedName{ namespacedName := types.NamespacedName{
Namespace: "default", Namespace: "default",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment