mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-09 11:40:25 +08:00
优化节点列表
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/iwind/TeaGo/bootstrap"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
@@ -52,3 +53,29 @@ func TestNodeValueDAO_CreateManyValues(t *testing.T) {
|
||||
}
|
||||
t.Log("finished")
|
||||
}
|
||||
|
||||
func TestNodeValueDAO_SumAllNodeValues(t *testing.T) {
|
||||
var dao = models.NewNodeValueDAO()
|
||||
sum, avg, max, err := dao.SumAllNodeValues(nil, nodeconfigs.NodeRoleNode, nodeconfigs.NodeValueItemCPU, "usage", 1, nodeconfigs.NodeValueDurationUnitMinute)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("sum:", sum, "avg:", avg, "max:", max)
|
||||
}
|
||||
|
||||
func TestNodeValueDAO_ComposeNodeStatus(t *testing.T) {
|
||||
var dao = models.NewNodeValueDAO()
|
||||
one, err := dao.Query(nil).DescPk().Find()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if one != nil {
|
||||
var config = &nodeconfigs.NodeStatus{}
|
||||
err = dao.ComposeNodeStatus(nil, one.(*models.NodeValue).Role, int64(one.(*models.NodeValue).NodeId), config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
logs.PrintAsJSON(config, t)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user