diff --git a/server/cmd/control-plane/main.go b/server/cmd/control-plane/main.go index 2493944d..71bed570 100644 --- a/server/cmd/control-plane/main.go +++ b/server/cmd/control-plane/main.go @@ -87,6 +87,7 @@ func newAPIHandler(db *sql.DB, indexes ...api.CandidateIndex) http.Handler { ProposalBackend: api.ProposalProviderFromStore(db), ProposalPromoter: api.ProposalPromoterFromStore(db), ServerRegistrar: api.ServerRegistrarFromStore(db), + ResultSubmitter: store.PostgresResults{DB: db}, Assignment: api.AssignmentProviderFromStore(db), CandidateIndex: candidateIndex, ProbeRecorder: store.PostgresQueue{DB: db}, diff --git a/server/cmd/control-plane/main_test.go b/server/cmd/control-plane/main_test.go index 6248922f..de7115c3 100644 --- a/server/cmd/control-plane/main_test.go +++ b/server/cmd/control-plane/main_test.go @@ -14,3 +14,27 @@ func TestAPIHandlerExposesHealthWithoutDatabase(t *testing.T) { t.Fatalf("health status = %d", rec.Code) } } + +// TestServerRoutesRequireWorkloadVerifyToBeWired pins a real, known gap +// rather than leaving it silent: newAPIHandler wires ServerRegistrar and +// ResultSubmitter, but never a WorkloadVerify -- and Service.serverMutation +// treats a nil WorkloadVerify as fatal for BOTH the register and result +// routes, regardless of whether their own dependency is present. So today, +// in the actual running binary, POST /v1/servers/{id}/register and +// /v1/servers/{id}/result both always 503, independent of a real database or +// real request. This test should start failing (and be updated, not +// deleted) the day a real WorkloadVerify is wired -- that's the intended +// signal, not a bug in the test. +func TestServerRoutesRequireWorkloadVerifyToBeWired(t *testing.T) { + handler := newAPIHandler(nil) + for _, path := range []string{"/v1/servers/server-1/register", "/v1/servers/server-1/result"} { + req := httptest.NewRequest(http.MethodPost, path, nil) + req.Header.Set("Idempotency-Key", "regression-pin-key-123456") + req.Header.Set("Authorization", "Bearer anything") + rec := httptest.NewRecorder() + handler.ServeHTTP(rec, req) + if rec.Code != http.StatusServiceUnavailable { + t.Fatalf("%s status = %d, want 503 (WorkloadVerify still unwired) -- if this changed, update this test rather than deleting it", path, rec.Code) + } + } +}