diff --git a/cmd/archie-state-store/recovery_test.go b/cmd/archie-state-store/recovery_test.go index a775037e1..b58629f29 100644 --- a/cmd/archie-state-store/recovery_test.go +++ b/cmd/archie-state-store/recovery_test.go @@ -27,6 +27,7 @@ import ( "github.com/samcharles93/archie-core/internal/app/archied" "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" + "github.com/samcharles93/archie-core/internal/infrastructure/workflowsteps" "github.com/samcharles93/archie-core/internal/store" ) @@ -685,13 +686,29 @@ func writeConfigWithLogFile(t *testing.T, dir string) (string, string) { // from the same config file the operator hands validate: the command's verdict // is about the pair, and a store whose settings never matched the config is a // state boot does not recognise either. +// +// The seeding builds its control-plane server from the shared provider set +// (internal/infrastructure/workflowsteps), which is what every composition root +// registers -- including openStateStoreControlPlane, the root helper the +// recovery path uses. This test cannot call that unexported helper, so it +// registers the same set itself rather than an empty manager: the definitions +// are decoded with the vocabulary the served path validates against, which is +// what makes the seeded values the ones validate is asked about. func seedStoreResources(t *testing.T, st *store.Store, configPath string) { t.Helper() doc, err := configuration.New(nil).Resolve(configPath, "") if err != nil { t.Fatalf("resolve %s: %v", configPath, err) } - if _, err := controlplane.NewServer(st).ImportConfig(t.Context(), doc.Config); err != nil { + steps, err := workflowsteps.NewManager() + if err != nil { + t.Fatalf("register workflow step vocabulary: %v", err) + } + server, err := controlplane.NewServer(st, steps) + if err != nil { + t.Fatalf("build control plane server: %v", err) + } + if _, err := server.ImportConfig(t.Context(), doc.Config); err != nil { t.Fatalf("seed store resources: %v", err) } } diff --git a/internal/app/archied/state_store_recovery.go b/internal/app/archied/state_store_recovery.go index 92b371d1f..fe4636726 100644 --- a/internal/app/archied/state_store_recovery.go +++ b/internal/app/archied/state_store_recovery.go @@ -11,6 +11,12 @@ // cannot stop the process that runs it, so the snapshot that makes a failed // update reversible is taken against a serving store through SQLite's own // consistent copy. +// +// The control-plane server both validate and rollback read through is built by +// openStateStoreControlPlane -- the same root helper the served path uses -- so +// the offline checks resolve the same workflow step vocabulary as the process +// whose verdict they predict, and a constructor error is a refusal here rather +// than a server that would validate against a different vocabulary. package archied import ( @@ -19,7 +25,6 @@ import ( "fmt" "time" - "github.com/samcharles93/archie-core/internal/app/controlplane" "github.com/samcharles93/archie-core/internal/config" pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" @@ -131,7 +136,10 @@ func validateStore(ctx context.Context, options StateStoreRecoveryOptions) (stri } defer func() { _ = st.Close() }() - server := controlplane.NewServer(st) + server, err := openStateStoreControlPlane(st) + if err != nil { + return "", err + } // Is there a resources table at all? A store written before the control plane // existed has none, and the State Store creates it and seeds every kind from // this same config on its next start -- so there is nothing stored to check @@ -210,7 +218,10 @@ func rollbackResource(ctx context.Context, options StateStoreRecoveryOptions) (s } defer func() { _ = st.Close() }() - server := controlplane.NewServer(st) + server, err := openStateStoreControlPlane(st) + if err != nil { + return "", err + } if !server.Owns(options.Kind) { return "", fmt.Errorf("unknown resource kind %q", options.Kind) }