From 692b0f0160aea67edddce15d08d92577b547b082 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 2 Nov 2026 11:35:33 +0100 Subject: [PATCH] Prove a rolled-back build is not placed again on the node tools, the one process judged by default Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL --- internal/apply/process_witness_test.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/apply/process_witness_test.go b/internal/apply/process_witness_test.go index fa51ff7..0be3ba1 100644 --- a/internal/apply/process_witness_test.go +++ b/internal/apply/process_witness_test.go @@ -72,36 +72,36 @@ func TestARolledBackBuildIsNotPlacedAgain(t *testing.T) { t.Cleanup(func() { unitDir, daemonRoot = wasUnits, wasBundles }) run := func(ctx context.Context, name string, args ...string) (string, error) { return "", nil } - oldBody, oldDigest := anArchive(t, map[string]string{"mesh-controller": "old\n"}) - newBody, newDigest := anArchive(t, map[string]string{"mesh-controller": "new\n"}) - controller := func(body []byte, digest, env string) string { - return `{"id":"mesh-controller.controller","type":"process","name":"mesh-controller","source":"` + serving(t, body) + - `","digest":"` + digest + `","run":["./mesh-controller","serve"],"env":{"X":"` + env + `"}}` + oldBody, oldDigest := anArchive(t, map[string]string{"node-tools": "old\n"}) + newBody, newDigest := anArchive(t, map[string]string{"node-tools": "new\n"}) + runtime := func(body []byte, digest, env string) string { + return `{"id":"node-tools.runtime","type":"process","name":"node-tools","source":"` + serving(t, body) + + `","digest":"` + digest + `","run":["./node-tools"],"env":{"X":"` + env + `"}}` } - _, state, err := Apply(context.Background(), archHost(t), declare(t, controller(oldBody, oldDigest, "1")), store.State{}, + _, state, err := Apply(context.Background(), archHost(t), declare(t, runtime(oldBody, oldDigest, "1")), store.State{}, store.OriginDeclared, run, nil, nil) if err != nil { t.Fatal(err) } - _, state, err = Apply(context.Background(), archHost(t), declare(t, controller(newBody, newDigest, "1")), state, + _, state, err = Apply(context.Background(), archHost(t), declare(t, runtime(newBody, newDigest, "1")), state, store.OriginDeclared, run, nil, nil) if err != nil { t.Fatal(err) } - if _, err := witness.Restore(context.Background(), bundles, "mesh-controller", "never took the lease", witness.Runner(run), + if _, err := witness.Restore(context.Background(), bundles, "node-tools", "never answered", witness.Runner(run), time.Now()); err != nil { t.Fatal(err) } // The mesh still declares the new build, and its unit changes: the process is re-placed. - report, _, err := Apply(context.Background(), archHost(t), declare(t, controller(newBody, newDigest, "2")), state, + report, _, err := Apply(context.Background(), archHost(t), declare(t, runtime(newBody, newDigest, "2")), state, store.OriginDeclared, run, nil, nil) if err != nil { t.Fatal(err) } - if got, _ := os.ReadFile(filepath.Join(bundles, "mesh-controller", "mesh-controller")); string(got) != "old\n" { + if got, _ := os.ReadFile(filepath.Join(bundles, "node-tools", "node-tools")); string(got) != "old\n" { t.Fatalf("the rolled-back build was placed again: %q", got) } - if o := outcomeOf(report, "mesh-controller.controller"); !strings.Contains(o.Detail, "rolled back on this machine") { + if o := outcomeOf(report, "node-tools.runtime"); !strings.Contains(o.Detail, "rolled back on this machine") { t.Fatalf("the apply does not say why it kept the build before: %+v", o) } }