mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-06-07 14:21:55 +00:00
update
This commit is contained in:
parent
c9e41fd12a
commit
10cac9adc8
56
src/pool_test.go
Normal file
56
src/pool_test.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"strconv"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPool(t *testing.T) {
|
||||||
|
return
|
||||||
|
InstanceOfResourcePool().init(Configuration{})
|
||||||
|
|
||||||
|
for j := 0; j < 100; j++ {
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
node := NodeStatus{ClientID: strconv.Itoa(i)}
|
||||||
|
InstanceOfResourcePool().update(node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
count := 0
|
||||||
|
for _, seg := range InstanceOfResourcePool().pools {
|
||||||
|
logrus.Info(seg.ID, "<--->", len(seg.Nodes), " ", seg.Nodes == nil, " Next:", seg.Next.ID)
|
||||||
|
count += len(seg.Nodes)
|
||||||
|
}
|
||||||
|
logrus.Info(count)
|
||||||
|
|
||||||
|
counter := map[int]int{}
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
seg := InstanceOfResourcePool().getNodePool(strconv.Itoa(i))
|
||||||
|
counter[seg]++
|
||||||
|
}
|
||||||
|
//for k, v := range counter {
|
||||||
|
//fmt.Println(k, "-->",v)
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAllocate(t *testing.T) {
|
||||||
|
InstanceOfResourcePool().init(Configuration{})
|
||||||
|
|
||||||
|
job := Job{Name: strconv.Itoa(int(time.Now().Unix() % 1000000000))}
|
||||||
|
job.Group = "default"
|
||||||
|
var tasks []Task
|
||||||
|
task := Task{}
|
||||||
|
task.Name = "node1"
|
||||||
|
task.NumberGPU = 1
|
||||||
|
task.NumberCPU = 2
|
||||||
|
task.Memory = 4096
|
||||||
|
task.IsPS = false
|
||||||
|
task.MemoryGPU = 4096
|
||||||
|
tasks = append(tasks, task)
|
||||||
|
job.Tasks = tasks
|
||||||
|
|
||||||
|
InstanceOfResourcePool().acquireResource(job)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user