Files

31 lines
949 B
Go

package agent
import (
"testing"
"gitea.mynodes.xyz/ilker/llmgw/internal/agent/engines"
)
func TestEnginesListenOnTheManagementAddressWhenItIsThisMachines(t *testing.T) {
cases := map[string]string{
"127.0.0.1": "127.0.0.1", // one of this machine's
"203.0.113.9": "", // not: every address rather than none
"gpu07.lan": "", // a name
"0.0.0.0": "",
"": "",
}
for mgmt, want := range cases {
a := &Agent{cfg: Config{MgmtAddr: mgmt}}
if got := a.bindAddr(); got != want {
t.Errorf("management address %q: listens on %q, expected %q", mgmt, got, want)
}
}
a := &Agent{}
if got := a.engineBase(engines.ShardSpec{HTTPPort: 8000}); got != "http://127.0.0.1:8000" {
t.Errorf("on every address, asked at %s", got)
}
if got := a.engineBase(engines.ShardSpec{HTTPPort: 8000, BindAddr: "10.0.0.147"}); got != "http://10.0.0.147:8000" {
t.Errorf("on one address, asked at %s", got)
}
}