Remove run node UI and expire registrations
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user