Files
EdgeAPI/internal/db/models/node_ip_address_dao_test.go

66 lines
1.3 KiB
Go
Raw Permalink Normal View History

2021-09-12 20:21:42 +08:00
//go:build plus
// +build plus
2020-08-30 16:12:00 +08:00
package models
import (
2024-07-27 14:15:25 +08:00
"testing"
2021-09-12 20:21:42 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
2020-08-30 16:12:00 +08:00
_ "github.com/go-sql-driver/mysql"
2021-09-12 20:21:42 +08:00
"github.com/iwind/TeaGo/dbs"
2020-08-30 16:12:00 +08:00
)
2021-09-12 20:21:42 +08:00
func TestNodeIPAddressDAO_FireThresholds(t *testing.T) {
dbs.NotifyReady()
var tx *dbs.Tx
var nodeId int64 = 126
node, err := SharedNodeDAO.FindEnabledNode(tx, nodeId)
if err != nil {
t.Fatal(err)
}
if node == nil {
t.Log("node not found")
return
}
err = SharedNodeIPAddressDAO.FireThresholds(tx, nodeconfigs.NodeRoleNode, nodeId)
if err != nil {
t.Fatal(err)
}
t.Log("ok")
}
2021-09-13 10:51:05 +08:00
func TestNodeIPAddressDAO_LoopTasks(t *testing.T) {
dbs.NotifyReady()
var tx *dbs.Tx
err := SharedNodeIPAddressDAO.loopTask(tx, nodeconfigs.NodeRoleNode)
if err != nil {
t.Fatal(err)
}
t.Log("ok")
}
func TestNodeIPAddressDAO_FindAddressIsHealthy(t *testing.T) {
dbs.NotifyReady()
var tx *dbs.Tx
isHealthy, err := SharedNodeIPAddressDAO.FindAddressIsHealthy(tx, 1)
if err != nil {
t.Fatal(err)
}
t.Log("isHealthy:", isHealthy)
}
func TestNodeIPAddressDAO_UpdateAddressHealthCount(t *testing.T) {
dbs.NotifyReady()
var tx *dbs.Tx
2022-04-23 13:26:15 +08:00
isChanged, err := SharedNodeIPAddressDAO.UpdateAddressHealthCount(tx, 1, true, 3, 3, false)
if err != nil {
t.Fatal(err)
}
t.Log("isChanged:", isChanged)
}