Remove run node UI and expire registrations

This commit is contained in:
npc0-hue
2026-08-21 12:03:06 +08:00
parent b5a366e30d
commit fb5adf06d6
17 changed files with 175 additions and 206 deletions
+34
View File
@@ -118,6 +118,40 @@ func TestCoreServiceAcceptsRunHeartbeat(t *testing.T) {
}
}
func TestCoreServiceClearsRunRegistrationAfterHeartbeatTTL(t *testing.T) {
svc := newTestCoreService()
hello, err := svc.RegisterRunHello(validRunControlHello())
if err != nil {
t.Fatalf("register hello: %v", err)
}
svc.now = func() time.Time { return fixedTime.Add(runHeartbeatStaleAfter - time.Nanosecond) }
active, err := svc.ListRunEndpoints(domain.RunEndpointFilter{Status: domain.RunEndpointStatusOnline})
if err != nil || len(active) != 1 || active[0].ID != "run-local" {
t.Fatalf("expected registration inside TTL, endpoints=%+v err=%v", active, err)
}
svc.now = func() time.Time { return fixedTime.Add(runHeartbeatStaleAfter + time.Second) }
if _, err := svc.GetRunEndpoint("run-local"); !errors.Is(err, repo.ErrNotFound) {
t.Fatalf("expected expired registration to be cleared, got %v", err)
}
cleared, err := svc.ListRunEndpoints(domain.RunEndpointFilter{})
if err != nil || len(cleared) != 0 {
t.Fatalf("expected no stale registrations in list, endpoints=%+v err=%v", cleared, err)
}
_, err = svc.AcceptRunHeartbeat(domain.RunControlHeartbeat{
RunEndpointID: "run-local",
SessionToken: hello.SessionToken,
Version: "0.1.1",
Status: domain.RunEndpointStatusOnline,
CapabilityFingerprint: "cap-v1",
Capacity: domain.RunCapacity{MaxJobs: 4},
})
if err == nil || !strings.Contains(err.Error(), "sessionToken is invalid") {
t.Fatalf("expected stale session to be rejected after registration cleanup, got %v", err)
}
}
func TestCoreServiceRejectsInvalidRunHeartbeatToken(t *testing.T) {
svc := newTestCoreService()
if _, err := svc.RegisterRunHello(validRunControlHello()); err != nil {