Add federation worker and canonical handoffs

This commit is contained in:
kami
2026-07-28 16:17:18 +04:00
parent 58793a5aa3
commit 2cecbc4015
22 changed files with 1429 additions and 108 deletions
+35
View File
@@ -0,0 +1,35 @@
package main
import (
"os"
"path/filepath"
"testing"
"time"
"orchestra/internal/registry"
)
type unreachable struct{}
func (unreachable) Reachable(string, time.Duration) bool { return false }
func TestFederatedReachabilityDefersRemoteHerdrToWorkerHeartbeat(t *testing.T) {
path := filepath.Join(t.TempDir(), "config.json")
if err := os.WriteFile(path, []byte(`{
"machines":[{"id":"homesrv","address":"192.168.1.104:9145"},{"id":"workpc","address":"192.168.1.105:9145"}],
"herdrs":[{"id":"local","machine_id":"homesrv","harness":"opencode"},{"id":"remote","machine_id":"workpc","harness":"opencode"}]
}`), 0o600); err != nil {
t.Fatal(err)
}
r, err := registry.Load(path)
if err != nil {
t.Fatal(err)
}
check := federatedReachability{base: unreachable{}, remote: remoteHerdrAddresses(r, "homesrv")}
if check.Reachable("192.168.1.105:9245", time.Second) != true {
t.Fatal("remote herdr should be admitted for worker heartbeat gating")
}
if check.Reachable("192.168.1.104:9245", time.Second) {
t.Fatal("local herdr should still require its TCP probe")
}
}