支持单个服务更新

This commit is contained in:
GoEdgeLab
2022-01-19 22:15:52 +08:00
parent 5d06c34fd7
commit 83d3ab75c3
6 changed files with 656 additions and 346 deletions

View File

@@ -5,6 +5,7 @@ import (
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/logs"
"testing"
"time"
)
func TestSharedNodeConfig(t *testing.T) {
@@ -64,3 +65,37 @@ func TestNodeConfig_Groups(t *testing.T) {
}
logs.PrintAsJSON(config.AvailableGroups(), t)
}
func TestCloneNodeConfig(t *testing.T) {
var config = &NodeConfig{Id: 1, NodeId: "1", IsOn: true}
for i := 0; i < 100_000; i++ {
config.Servers = append(config.Servers, &serverconfigs.ServerConfig{})
}
var before = time.Now()
newConfig, err := CloneNodeConfig(config)
t.Log(time.Since(before))
if err != nil {
t.Fatal(err)
}
newConfig.Servers = []*serverconfigs.ServerConfig{}
logs.PrintAsJSON(newConfig, t)
}
func TestNodeConfig_AddServer(t *testing.T) {
var config = &NodeConfig{Id: 1, NodeId: "1", IsOn: true}
config.AddServer(&serverconfigs.ServerConfig{Id: 1})
config.AddServer(&serverconfigs.ServerConfig{Id: 2})
t.Log("===before===")
for _, s := range config.Servers {
t.Log(s.Id)
}
t.Log("===after===")
config.AddServer(&serverconfigs.ServerConfig{Id: 3})
config.RemoveServer(2)
for _, s := range config.Servers {
t.Log(s.Id)
}
}