tests: neutral names in carlos run's tests (no tenant names in platform work)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 files changed,
+213
−182
internal/console/apiruns_test.go+59 −33internal/console/apirunsfollow_test.go+28 −28internal/console/apirunsmove_test.go+12 −11internal/console/claim_invariant_fixtures_test.go+5 −5internal/console/runsweep_test.go+26 −26internal/host/runs_test.go+16 −16internal/provision/reconcile_test.go+11 −7internal/runs/chunker_test.go+17 −17internal/runs/runs_test.go+31 −31internal/runs/stage_linux_test.go+8 −8
diff --git a/internal/console/apiruns_test.go b/internal/console/apiruns_test.go| index d7c4e9394..e412673eb 100644 |
| --- a/internal/console/apiruns_test.go |
| +++ b/internal/console/apiruns_test.go |
| @@ -21,7 +21,7 @@ import ( |
| "github.com/carlosframework/platform/internal/svcrole" |
| ) |
| -const runTestHost = "acme.go.tito.io" |
| +const runTestHost = "acme.example.com" |
| type runFx struct { |
| *consoleFixture |
| @@ -30,13 +30,39 @@ type runFx struct { |
| func runFixture(t *testing.T) *runFx { |
| t.Helper() |
| - fx, member := instanceFixture(t, "code-run") |
| - putDBRecord(t, fx, provision.Record{Host: runTestHost, Channel: "stable", CreatedAt: time.Now().UTC()}) |
| + fx := newConsoleFixture(t) |
| + now := time.Now() |
| + if _, err := fx.st.CreateAppIn(OpsAccountID, "shop", "paul@keymail.dev", now); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := fx.st.AddMember(OpsAccountID, "alice@keymail.dev", RoleMember, now); err != nil { |
| + t.Fatal(err) |
| + } |
| + member := cliToken(t, fx, "alice@keymail.dev", "code-run") |
| + putShopRecord(t, fx, provision.Record{Host: runTestHost, Channel: "stable", CreatedAt: time.Now().UTC()}) |
| return &runFx{consoleFixture: fx, member: member} |
| } |
| +// putShopRecord writes an instance record for the shop app with the fields |
| +// a hibernating exec instance has, overridden by whatever rec sets. |
| +func putShopRecord(t *testing.T, fx *consoleFixture, rec provision.Record) { |
| + t.Helper() |
| + rec.App, rec.Account = "shop", release.OpsAccount |
| + if rec.Hibernate == nil { |
| + yes := true |
| + rec.Hibernate = &yes |
| + } |
| + body, err := json.Marshal(rec) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := fx.rel.Put(context.Background(), provision.RecordKey(rec.Account, rec.App, rec.Host), body, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| func (fx *runFx) runsURL(host string) string { |
| - return fx.ts.URL + "/api/cli/apps/" + release.OpsAccount + "/titogo/instances/" + host + "/runs" |
| + return fx.ts.URL + "/api/cli/apps/" + release.OpsAccount + "/shop/instances/" + host + "/runs" |
| } |
| // postRun sends the multipart create; parts lets a test send parts that |
| @@ -126,22 +152,22 @@ func TestAPIRunCreateAdmitsAndRecords(t *testing.T) { |
| t.Fatalf("created %+v, %v", c, err) |
| } |
| ctx := context.Background() |
| - rec, err := provision.GetRecord(ctx, fx.rel, release.OpsAccount, "titogo", runTestHost) |
| + rec, err := provision.GetRecord(ctx, fx.rel, release.OpsAccount, "shop", runTestHost) |
| if err != nil || rec.ActiveRun == nil || rec.ActiveRun.ID != c.ID || rec.ActiveRun.By != "alice@keymail.dev" { |
| t.Fatalf("record run %+v, %v", rec.ActiveRun, err) |
| } |
| if d := time.Until(rec.ActiveRun.Deadline); d < 50*time.Second || d > 61*time.Second { |
| t.Errorf("pickup deadline %s away, want about 60 s", d) |
| } |
| - req, err := runs.ReadRequest(ctx, fx.rel, release.OpsAccount, "titogo", c.ID) |
| + req, err := runs.ReadRequest(ctx, fx.rel, release.OpsAccount, "shop", c.ID) |
| if err != nil || req.Host != runTestHost || len(req.Incarnation) != 64 || req.TimeoutS != 60 || len(req.Files) != 1 || len(req.Files[0].SHA256) != 64 { |
| t.Fatalf("request %+v, %v", req, err) |
| } |
| - raw, _, err := fx.rel.Get(ctx, runs.InputKey(release.OpsAccount, "titogo", c.ID, "x.csv")) |
| + raw, _, err := fx.rel.Get(ctx, runs.InputKey(release.OpsAccount, "shop", c.ID, "x.csv")) |
| if err != nil || string(raw) != "a,b,c" { |
| t.Fatalf("input %q, %v", raw, err) |
| } |
| - events, _ := fx.st.Events(OpsAccountID, "titogo", 10) |
| + events, _ := fx.st.Events(OpsAccountID, "shop", 10) |
| found := false |
| for _, e := range events { |
| if e.Action == "run-start" && e.Target == runTestHost && e.Address == "alice@keymail.dev" && strings.Contains(e.Detail, c.ID) && strings.Contains(e.Detail, "x.csv") { |
| @@ -158,7 +184,7 @@ func TestAPIRunCreateAdmitsAndRecords(t *testing.T) { |
| func TestAPIRunCreateRefusesInOrder(t *testing.T) { |
| fx := runFixture(t) |
| ctx := context.Background() |
| - svc := serviceToken(t, fx.st, OpsAccountID, "ci", "titogo", svcrole.Instance) |
| + svc := serviceToken(t, fx.st, OpsAccountID, "ci", "shop", svcrole.Instance) |
| stranger := cliToken(t, fx.consoleFixture, "mallory@keymail.dev", "code-run-stranger") |
| if status, _ := postRun(t, fx.runsURL(runTestHost), svc, okMeta(), nil); status != http.StatusForbidden { |
| @@ -166,40 +192,40 @@ func TestAPIRunCreateRefusesInOrder(t *testing.T) { |
| } |
| status, h, body := postRunH(t, fx.runsURL(runTestHost), stranger, okMeta(), nil) |
| assertNotFound(t, "stranger", canonicalNotFound(t), status, h, body) |
| - if status, body := postRun(t, fx.runsURL("nobody.go.tito.io"), fx.member, okMeta(), nil); status != http.StatusNotFound || errorOf(t, body) != "nobody.go.tito.io is not an instance of titogo" { |
| + if status, body := postRun(t, fx.runsURL("nobody.example.com"), fx.member, okMeta(), nil); status != http.StatusNotFound || errorOf(t, body) != "nobody.example.com is not an instance of shop" { |
| t.Errorf("no record: %d %s", status, body) |
| } |
| for host, c := range map[string]struct { |
| rec provision.Record |
| msg string |
| }{ |
| - "static.go.tito.io": {provision.Record{Kind: "static"}, "static.go.tito.io is a static route. carlos run works on instances"}, |
| - "addr.go.tito.io": {provision.Record{Addr: "127.0.0.1:9"}, "addr.go.tito.io is served from its own address, so the platform does not run its process"}, |
| - "pool.go.tito.io": {provision.Record{Pool: "tito"}, "pool.go.tito.io is a pooled instance. carlos run works on instances with a process of their own"}, |
| - "fleet.go.tito.io": {provision.Record{Region: "fleet/pi"}, "fleet.go.tito.io runs on your fleet pi. carlos run works on platform boxes only"}, |
| + "static.example.com": {provision.Record{Kind: "static"}, "static.example.com is a static route. carlos run works on instances"}, |
| + "addr.example.com": {provision.Record{Addr: "127.0.0.1:9"}, "addr.example.com is served from its own address, so the platform does not run its process"}, |
| + "pool.example.com": {provision.Record{Pool: "shared"}, "pool.example.com is a pooled instance. carlos run works on instances with a process of their own"}, |
| + "fleet.example.com": {provision.Record{Region: "fleet/pi"}, "fleet.example.com runs on your fleet pi. carlos run works on platform boxes only"}, |
| } { |
| c.rec.Host = host |
| - putDBRecord(t, fx.consoleFixture, c.rec) |
| + putShopRecord(t, fx.consoleFixture, c.rec) |
| if status, body := postRun(t, fx.runsURL(host), fx.member, okMeta(), nil); status != http.StatusConflict || errorOf(t, body) != c.msg { |
| t.Errorf("%s: %d %s", host, status, body) |
| } |
| } |
| no := false |
| - putDBRecord(t, fx.consoleFixture, provision.Record{Host: "awake.go.tito.io", Hibernate: &no}) |
| - if status, body := postRun(t, fx.runsURL("awake.go.tito.io"), fx.member, okMeta(), nil); status != http.StatusConflict || !strings.Contains(errorOf(t, body), "does not sleep") { |
| + putShopRecord(t, fx.consoleFixture, provision.Record{Host: "awake.example.com", Hibernate: &no}) |
| + if status, body := postRun(t, fx.runsURL("awake.example.com"), fx.member, okMeta(), nil); status != http.StatusConflict || !strings.Contains(errorOf(t, body), "does not sleep") { |
| t.Errorf("always-on: %d %s", status, body) |
| } |
| - if _, err := provision.SetRecordMove(ctx, fx.rel, release.OpsAccount, "titogo", runTestHost, provision.MoveRequest("uk", time.Now())); err != nil { |
| + if _, err := provision.SetRecordMove(ctx, fx.rel, release.OpsAccount, "shop", runTestHost, provision.MoveRequest("uk", time.Now())); err != nil { |
| t.Fatal(err) |
| } |
| if status, body := postRun(t, fx.runsURL(runTestHost), fx.member, okMeta(), nil); status != http.StatusConflict || errorOf(t, body) != runTestHost+" is moving. run the command once the move has finished" { |
| t.Errorf("moving: %d %s", status, body) |
| } |
| - putDBRecord(t, fx.consoleFixture, provision.Record{Host: "busy.go.tito.io", ActiveRun: &provision.RunState{ID: "run_aaaaaaaaaaaaaaaaaaaaaaaaaa", State: provision.RunPicked, By: "bob@keymail.dev"}}) |
| - if status, body := postRun(t, fx.runsURL("busy.go.tito.io"), fx.member, okMeta(), nil); status != http.StatusConflict || errorOf(t, body) != "busy.go.tito.io already has a run open: run_aaaaaaaaaaaaaaaaaaaaaaaaaa, started by bob@keymail.dev" { |
| + putShopRecord(t, fx.consoleFixture, provision.Record{Host: "busy.example.com", ActiveRun: &provision.RunState{ID: "run_aaaaaaaaaaaaaaaaaaaaaaaaaa", State: provision.RunPicked, By: "bob@keymail.dev"}}) |
| + if status, body := postRun(t, fx.runsURL("busy.example.com"), fx.member, okMeta(), nil); status != http.StatusConflict || errorOf(t, body) != "busy.example.com already has a run open: run_aaaaaaaaaaaaaaaaaaaaaaaaaa, started by bob@keymail.dev" { |
| t.Errorf("open run: %d %s", status, body) |
| } |
| - putDBRecord(t, fx.consoleFixture, provision.Record{Host: "fresh.go.tito.io"}) |
| + putShopRecord(t, fx.consoleFixture, provision.Record{Host: "fresh.example.com"}) |
| bad := []struct { |
| meta runs.Meta |
| msg string |
| @@ -217,12 +243,12 @@ func TestAPIRunCreateRefusesInOrder(t *testing.T) { |
| bad[1].meta.Argv[i] = "x" |
| } |
| for _, c := range bad { |
| - if status, body := postRun(t, fx.runsURL("fresh.go.tito.io"), fx.member, c.meta, nil); status != http.StatusBadRequest || errorOf(t, body) != c.msg { |
| + if status, body := postRun(t, fx.runsURL("fresh.example.com"), fx.member, c.meta, nil); status != http.StatusBadRequest || errorOf(t, body) != c.msg { |
| t.Errorf("%q: %d %s", c.msg, status, body) |
| } |
| } |
| - putDBRecord(t, fx.consoleFixture, provision.Record{Host: "import.go.tito.io", Seed: &provision.SeedSource{Kind: provision.SeedKindImport, State: "placed"}}) |
| - if status, body := postRun(t, fx.runsURL("import.go.tito.io"), fx.member, okMeta(), nil); status != http.StatusConflict || errorOf(t, body) != "import.go.tito.io is an import that is not committed yet. finish or abort the import first" { |
| + putShopRecord(t, fx.consoleFixture, provision.Record{Host: "import.example.com", Seed: &provision.SeedSource{Kind: provision.SeedKindImport, State: "placed"}}) |
| + if status, body := postRun(t, fx.runsURL("import.example.com"), fx.member, okMeta(), nil); status != http.StatusConflict || errorOf(t, body) != "import.example.com is an import that is not committed yet. finish or abort the import first" { |
| t.Errorf("import: %d %s", status, body) |
| } |
| } |
| @@ -259,10 +285,10 @@ func TestAPIRunCreateRefusesAPartThatDisagreesWithMeta(t *testing.T) { |
| } |
| assertNoSpool(t, spool, name) |
| } |
| - if left, _ := fx.rel.List(context.Background(), runs.RunsPrefix(release.OpsAccount, "titogo")); len(left) != 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.RunsPrefix(release.OpsAccount, "shop")); len(left) != 0 { |
| t.Fatalf("a refused upload left %q", left) |
| } |
| - if rec, _ := provision.GetRecord(context.Background(), fx.rel, release.OpsAccount, "titogo", runTestHost); rec.ActiveRun != nil { |
| + if rec, _ := provision.GetRecord(context.Background(), fx.rel, release.OpsAccount, "shop", runTestHost); rec.ActiveRun != nil { |
| t.Fatal("a refused upload admitted a run") |
| } |
| } |
| @@ -299,7 +325,7 @@ func TestAPIRunCreateRaceAdmitsOne(t *testing.T) { |
| } |
| // DirStore keeps emptied directories, so count the runs that still own |
| // objects rather than the directories. |
| - prefix := runs.RunsPrefix(release.OpsAccount, "titogo") |
| + prefix := runs.RunsPrefix(release.OpsAccount, "shop") |
| keys, _ := fx.rel.List(context.Background(), prefix) |
| owners := map[string]bool{} |
| for _, k := range keys { |
| @@ -322,7 +348,7 @@ type rivalStore struct { |
| func (r *rivalStore) Put(ctx context.Context, key string, body []byte, ifMatch string) (string, error) { |
| if strings.HasSuffix(key, "/request.json") { |
| r.once.Do(func() { |
| - _, err := provision.SetRecordRun(ctx, r.Store, release.OpsAccount, "titogo", runTestHost, |
| + _, err := provision.SetRecordRun(ctx, r.Store, release.OpsAccount, "shop", runTestHost, |
| provision.RunAdmit(provision.RunAdmission{ID: "run_aaaaaaaaaaaaaaaaaaaaaaaaaa", By: "bob@keymail.dev", Deadline: time.Now().Add(time.Minute)})) |
| if err != nil { |
| r.t.Error(err) |
| @@ -343,7 +369,7 @@ func TestAPIRunCreateLoserAfterUploadLeavesNothing(t *testing.T) { |
| if want := "already has a run open: run_aaaaaaaaaaaaaaaaaaaaaaaaaa, started by bob@keymail.dev"; status != http.StatusConflict || !strings.HasSuffix(errorOf(t, body), want) { |
| t.Fatalf("%d %s", status, body) |
| } |
| - if left, _ := fx.rel.List(context.Background(), runs.RunsPrefix(release.OpsAccount, "titogo")); len(left) != 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.RunsPrefix(release.OpsAccount, "shop")); len(left) != 0 { |
| t.Fatalf("the loser left %q", left) |
| } |
| } |
| @@ -405,7 +431,7 @@ func TestAPIRunCreateRefusesABodyPastTheCap(t *testing.T) { |
| t.Fatalf("%d %s", res.StatusCode, out) |
| } |
| assertNoSpool(t, spool, "a body past the cap") |
| - if left, _ := fx.rel.List(context.Background(), runs.RunsPrefix(release.OpsAccount, "titogo")); len(left) != 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.RunsPrefix(release.OpsAccount, "shop")); len(left) != 0 { |
| t.Fatalf("left %q", left) |
| } |
| } |
| @@ -442,7 +468,7 @@ func TestAPIRunCreateAdmissionWhoseAnswerWasLost(t *testing.T) { |
| } { |
| t.Run(name, func(t *testing.T) { |
| fx := runFixture(t) |
| - fx.srv.cfg.Releases = &commitThenFailStore{Store: fx.rel, recordKey: provision.RecordKey(release.OpsAccount, "titogo", runTestHost), err: failure} |
| + fx.srv.cfg.Releases = &commitThenFailStore{Store: fx.rel, recordKey: provision.RecordKey(release.OpsAccount, "shop", runTestHost), err: failure} |
| meta := okMeta() |
| meta.Files = []runs.MetaFile{{Name: "x.csv", Size: 5}} |
| status, body := postRun(t, fx.runsURL(runTestHost), fx.member, meta, []struct{ name, body string }{{"x.csv", "a,b,c"}}) |
| @@ -454,11 +480,11 @@ func TestAPIRunCreateAdmissionWhoseAnswerWasLost(t *testing.T) { |
| t.Fatalf("created %+v, %v", c, err) |
| } |
| ctx := context.Background() |
| - rec, err := provision.GetRecord(ctx, fx.rel, release.OpsAccount, "titogo", runTestHost) |
| + rec, err := provision.GetRecord(ctx, fx.rel, release.OpsAccount, "shop", runTestHost) |
| if err != nil || rec.ActiveRun == nil || rec.ActiveRun.ID != c.ID { |
| t.Fatalf("record run %+v, %v", rec.ActiveRun, err) |
| } |
| - keys, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "titogo", c.ID)) |
| + keys, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "shop", c.ID)) |
| if len(keys) != 2 { |
| t.Fatalf("the admitted run's objects are %q, want request.json and in/x.csv", keys) |
| } |
diff --git a/internal/console/apirunsfollow_test.go b/internal/console/apirunsfollow_test.go| index c4480f2b2..10b4a2c8e 100644 |
| --- a/internal/console/apirunsfollow_test.go |
| +++ b/internal/console/apirunsfollow_test.go |
| @@ -33,14 +33,14 @@ func (fx *runFx) startRun(t *testing.T) string { |
| func (fx *runFx) transition(t *testing.T, mut func(*provision.Record) error) { |
| t.Helper() |
| - if _, err := provision.SetRecordRun(context.Background(), fx.rel, release.OpsAccount, "titogo", runTestHost, mut); err != nil { |
| + if _, err := provision.SetRecordRun(context.Background(), fx.rel, release.OpsAccount, "shop", runTestHost, mut); err != nil { |
| t.Fatal(err) |
| } |
| } |
| func (fx *runFx) chunk(t *testing.T, id string, seq int64, stream, data string) { |
| t.Helper() |
| - if _, err := fx.rel.Put(context.Background(), runs.ChunkKey(release.OpsAccount, "titogo", id, seq, stream), []byte(data), ""); err != nil { |
| + if _, err := fx.rel.Put(context.Background(), runs.ChunkKey(release.OpsAccount, "shop", id, seq, stream), []byte(data), ""); err != nil { |
| t.Fatal(err) |
| } |
| } |
| @@ -87,7 +87,7 @@ func TestAPIRunGetPagesSeveralPagesAfterTheResult(t *testing.T) { |
| for seq := int64(1); seq <= 3*runs.PageChunks; seq++ { |
| fx.chunk(t, id, seq, runs.StreamOut, "x") |
| } |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Exit: 0, LastSeq: 3 * runs.PageChunks}); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Exit: 0, LastSeq: 3 * runs.PageChunks}); err != nil { |
| t.Fatal(err) |
| } |
| var after int64 |
| @@ -161,23 +161,23 @@ func TestAPIRunAckChecksLastSeqThenCleansUp(t *testing.T) { |
| } |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| fx.chunk(t, id, 1, runs.StreamOut, "a") |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Exit: 0, LastSeq: 1}); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Exit: 0, LastSeq: 1}); err != nil { |
| t.Fatal(err) |
| } |
| fx.transition(t, provision.RunFinish(id)) |
| if status, body := fx.post(t, id, "ack", `{"last_seq":0}`); status != http.StatusConflict || errorOf(t, body) != "run "+id+" ended at chunk 1, not 0" { |
| t.Fatalf("wrong last_seq: %d %s", status, body) |
| } |
| - if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "titogo", id)); len(left) == 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "shop", id)); len(left) == 0 { |
| t.Fatal("a refused ack deleted the run") |
| } |
| if status, body := fx.post(t, id, "ack", `{"last_seq":1}`); status != http.StatusOK { |
| t.Fatalf("ack: %d %s", status, body) |
| } |
| - if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "titogo", id)); len(left) != 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "shop", id)); len(left) != 0 { |
| t.Fatalf("ack left %q", left) |
| } |
| - if rec, _ := provision.GetRecord(context.Background(), fx.rel, release.OpsAccount, "titogo", runTestHost); rec.ActiveRun != nil { |
| + if rec, _ := provision.GetRecord(context.Background(), fx.rel, release.OpsAccount, "shop", runTestHost); rec.ActiveRun != nil { |
| t.Fatalf("ack left the run on the record: %+v", rec.ActiveRun) |
| } |
| } |
| @@ -196,7 +196,7 @@ func TestAPIRunCancelBeforeAndAfterPickup(t *testing.T) { |
| if status, body := fx.post(t, id2, "cancel", ""); status != http.StatusOK || !strings.Contains(body, `"cancel"`) { |
| t.Fatalf("picked cancel: %d %s", status, body) |
| } |
| - events, _ := fx.st.Events(OpsAccountID, "titogo", 20) |
| + events, _ := fx.st.Events(OpsAccountID, "shop", 20) |
| ends := 0 |
| for _, e := range events { |
| if e.Action == "run-end" && strings.Contains(e.Detail, id) && strings.Contains(e.Detail, `"cancelled"`) { |
| @@ -239,12 +239,12 @@ func TestAPIRunGetWritesRunEndOnce(t *testing.T) { |
| fx := runFixture(t) |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Exit: 7, Box: "box-1"}); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Exit: 7, Box: "box-1"}); err != nil { |
| t.Fatal(err) |
| } |
| fx.page(t, id, 0) |
| fx.page(t, id, 0) |
| - events, _ := fx.st.Events(OpsAccountID, "titogo", 20) |
| + events, _ := fx.st.Events(OpsAccountID, "shop", 20) |
| n := 0 |
| for _, e := range events { |
| if e.Action == "run-end" && strings.Contains(e.Detail, id) { |
| @@ -265,16 +265,16 @@ func TestAPIRunAckKeepsTheObjectsOfALiveRun(t *testing.T) { |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| fx.chunk(t, id, 1, runs.StreamOut, "a") |
| // The box has written the result and not yet moved the run to done. |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Exit: 0, LastSeq: 1}); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Exit: 0, LastSeq: 1}); err != nil { |
| t.Fatal(err) |
| } |
| if status, body := fx.post(t, id, "ack", `{"last_seq":1}`); status != http.StatusConflict || errorOf(t, body) != "run "+id+" has not finished yet" { |
| t.Fatalf("ack of a picked run: %d %s", status, body) |
| } |
| - if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "titogo", id)); len(left) == 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "shop", id)); len(left) == 0 { |
| t.Fatal("an ack deleted the objects of a run the record holds as picked") |
| } |
| - if rec, _ := provision.GetRecord(context.Background(), fx.rel, release.OpsAccount, "titogo", runTestHost); rec.ActiveRun == nil || rec.ActiveRun.State != provision.RunPicked { |
| + if rec, _ := provision.GetRecord(context.Background(), fx.rel, release.OpsAccount, "shop", runTestHost); rec.ActiveRun == nil || rec.ActiveRun.State != provision.RunPicked { |
| t.Fatalf("record %+v", rec.ActiveRun) |
| } |
| } |
| @@ -283,7 +283,7 @@ func TestAPIRunAckAfterTheRecordMovedOnDeletesTheObjects(t *testing.T) { |
| fx := runFixture(t) |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Exit: 0}); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Exit: 0}); err != nil { |
| t.Fatal(err) |
| } |
| fx.transition(t, provision.RunFinish(id)) |
| @@ -292,7 +292,7 @@ func TestAPIRunAckAfterTheRecordMovedOnDeletesTheObjects(t *testing.T) { |
| if status, body := fx.post(t, id, "ack", `{"last_seq":0}`); status != http.StatusOK { |
| t.Fatalf("ack: %d %s", status, body) |
| } |
| - if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "titogo", id)); len(left) != 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "shop", id)); len(left) != 0 { |
| t.Fatalf("left %q", left) |
| } |
| } |
| @@ -300,9 +300,9 @@ func TestAPIRunAckAfterTheRecordMovedOnDeletesTheObjects(t *testing.T) { |
| func TestAPIRunRoutesRefuseAnotherHostsRun(t *testing.T) { |
| fx := runFixture(t) |
| id := fx.startRun(t) |
| - other := "other.go.tito.io" |
| - putDBRecord(t, fx.consoleFixture, provision.Record{Host: other, Channel: "stable", CreatedAt: time.Now().UTC()}) |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Exit: 0}); err != nil { |
| + other := "other.example.com" |
| + putShopRecord(t, fx.consoleFixture, provision.Record{Host: other, Channel: "stable", CreatedAt: time.Now().UTC()}) |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Exit: 0}); err != nil { |
| t.Fatal(err) |
| } |
| want := other + " has no run " + id |
| @@ -316,14 +316,14 @@ func TestAPIRunRoutesRefuseAnotherHostsRun(t *testing.T) { |
| t.Errorf("%s: %s", verb, body) |
| } |
| } |
| - if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "titogo", id)); len(left) == 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "shop", id)); len(left) == 0 { |
| t.Fatal("another host's ack deleted the run") |
| } |
| } |
| func TestAPIRunRoutesRefuseAServiceCredentialAndABadID(t *testing.T) { |
| fx := runFixture(t) |
| - svc := serviceToken(t, fx.st, OpsAccountID, "ci", "titogo", svcrole.Instance) |
| + svc := serviceToken(t, fx.st, OpsAccountID, "ci", "shop", svcrole.Instance) |
| id := "run_aaaaaaaaaaaaaaaaaaaaaaaaaa" |
| if status, _, _ := rawReq(t, http.MethodGet, fx.runsURL(runTestHost)+"/"+id, svc, ""); status != http.StatusForbidden { |
| t.Errorf("service credential: %d, want 403", status) |
| @@ -376,7 +376,7 @@ func (f *faultStore) Get(ctx context.Context, key string) ([]byte, string, error |
| // runEnds is the details of the run-end rows written for id. |
| func (fx *runFx) runEnds(t *testing.T, id string) []string { |
| t.Helper() |
| - events, err := fx.st.Events(OpsAccountID, "titogo", 50) |
| + events, err := fx.st.Events(OpsAccountID, "shop", 50) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -390,7 +390,7 @@ func (fx *runFx) runEnds(t *testing.T, id string) []string { |
| } |
| func (fx *runFx) left(id string) []string { |
| - left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "titogo", id)) |
| + left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "shop", id)) |
| return left |
| } |
| @@ -400,7 +400,7 @@ func (fx *runFx) finishedRun(t *testing.T) string { |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| fx.chunk(t, id, 1, runs.StreamOut, "a") |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Exit: 0, LastSeq: 1}); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Exit: 0, LastSeq: 1}); err != nil { |
| t.Fatal(err) |
| } |
| fx.transition(t, provision.RunFinish(id)) |
| @@ -412,7 +412,7 @@ func TestAPIRunAckThatCannotDeleteKeepsTheMarkerSoTheRowIsWrittenOnce(t *testing |
| id := fx.finishedRun(t) |
| failing := true |
| fx.srv.cfg.Releases = &faultStore{Store: fx.rel, delete: func(key string) error { |
| - if failing && key == runs.ResultKey(release.OpsAccount, "titogo", id) { |
| + if failing && key == runs.ResultKey(release.OpsAccount, "shop", id) { |
| return errors.New("delete refused") |
| } |
| return nil |
| @@ -421,7 +421,7 @@ func TestAPIRunAckThatCannotDeleteKeepsTheMarkerSoTheRowIsWrittenOnce(t *testing |
| t.Fatalf("ack: %d %s", status, body) |
| } |
| left := fx.left(id) |
| - for _, want := range []string{runs.ResultKey(release.OpsAccount, "titogo", id), runs.RequestKey(release.OpsAccount, "titogo", id), runs.AuditedKey(release.OpsAccount, "titogo", id)} { |
| + for _, want := range []string{runs.ResultKey(release.OpsAccount, "shop", id), runs.RequestKey(release.OpsAccount, "shop", id), runs.AuditedKey(release.OpsAccount, "shop", id)} { |
| if !slices.Contains(left, want) { |
| t.Fatalf("after a failed delete %q is gone; left %q", want, left) |
| } |
| @@ -450,7 +450,7 @@ func TestAPIRunEndIsNotWrittenForARunAnAckHasDeleted(t *testing.T) { |
| } |
| // A follower that read the result before the ack's delete reaches the |
| // audit after it. |
| - fx.srv.auditRunEnd(context.Background(), &Account{ID: OpsAccountID, Sqid: release.OpsAccount}, "titogo", runTestHost, id, "result", &runs.Result{LastSeq: 1}) |
| + fx.srv.auditRunEnd(context.Background(), &Account{ID: OpsAccountID, Sqid: release.OpsAccount}, "shop", runTestHost, id, "result", &runs.Result{LastSeq: 1}) |
| if left := fx.left(id); len(left) != 0 { |
| t.Fatalf("a late audit left %q", left) |
| } |
| @@ -514,7 +514,7 @@ func TestAPIRunRetriedCancelAndExpireStillEndTheRun(t *testing.T) { |
| if status, body := fx.post(t, id, c.verb, ""); status != http.StatusConflict || errorOf(t, body) != "run "+id+" has already ended" { |
| t.Fatalf("%s retry: %d %s", c.verb, status, body) |
| } |
| - if res, err := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id); err != nil || res == nil { |
| + if res, err := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "shop", id); err != nil || res == nil { |
| t.Errorf("%s retry left no result: %+v, %v", c.verb, res, err) |
| } |
| if rows := fx.runEnds(t, id); len(rows) != 1 || !strings.Contains(rows[0], `"outcome":"`+c.outcome+`"`) { |
| @@ -529,7 +529,7 @@ func TestAPIRunRetriedCancelAndExpireStillEndTheRun(t *testing.T) { |
| } |
| func TestAPIRunAckKeepsTheObjectsWhenTheClearIsNotSettled(t *testing.T) { |
| - recordKey := provision.RecordKey(release.OpsAccount, "titogo", runTestHost) |
| + recordKey := provision.RecordKey(release.OpsAccount, "shop", runTestHost) |
| for _, c := range []struct { |
| name string |
| setup func(*faultStore, *bool) |
diff --git a/internal/console/apirunsmove_test.go b/internal/console/apirunsmove_test.go| index 05e048163..8d3551b41 100644 |
| --- a/internal/console/apirunsmove_test.go |
| +++ b/internal/console/apirunsmove_test.go |
| @@ -23,12 +23,12 @@ func TestMoveDoorRefusesWhileARunIsOpen(t *testing.T) { |
| []byte(`{"v":1,"box":"uk-box","eip":"1.2.3.4","placement":"uk","data_bucket":"data-uk","data_bucket_region":"eu-west-2","hosts":{}}`), ""); err != nil { |
| t.Fatal(err) |
| } |
| - u := fx.ts.URL + "/api/cli/apps/bab/titogo/instances/" + runTestHost + "/move" |
| + u := fx.ts.URL + "/api/cli/apps/bab/shop/instances/" + runTestHost + "/move" |
| status, _, body := rawReq(t, http.MethodPost, u, fx.member, `{"region":"uk"}`) |
| if status != http.StatusConflict || !strings.Contains(body, "a run is open on this instance: "+id+". wait for it to finish or cancel it, then move the instance") { |
| t.Fatalf("legacy move: %d %s", status, body) |
| } |
| - if _, err := provision.SetRecordRun(context.Background(), fx.rel, release.OpsAccount, "titogo", runTestHost, provision.RunExpire(id)); err != nil { |
| + if _, err := provision.SetRecordRun(context.Background(), fx.rel, release.OpsAccount, "shop", runTestHost, provision.RunExpire(id)); err != nil { |
| t.Fatal(err) |
| } |
| if status, _, body := rawReq(t, http.MethodPost, u, fx.member, `{"region":"uk"}`); status != http.StatusAccepted { |
| @@ -42,21 +42,22 @@ func movePhase1RunFixture(t *testing.T) (fx *consoleFixture, token, moveURL stri |
| t.Helper() |
| fx, token = operatorInstanceFixture(t, "code-inst-move-run") |
| m := titoManifest() |
| + m.Domain = "example.com" |
| m.Regions = nil |
| m.Pool = "" |
| enableInstances(t, fx, "titogo", m) |
| u := instancesURL(fx, "bab", "titogo") |
| - if code, _, out := rawReq(t, http.MethodPost, u, token, `{"host":"acme.go.tito.io","region":"ie"}`); code != http.StatusCreated { |
| + if code, _, out := rawReq(t, http.MethodPost, u, token, `{"host":"acme.example.com","region":"ie"}`); code != http.StatusCreated { |
| t.Fatalf("create = %d %s", code, out) |
| } |
| armMoveFleet(t, fx, ieBox("ie-box"), ukBox("uk-box")) |
| - claimFor(t, fx, "acme.go.tito.io", "ie-box", "ie") |
| - return fx, token, u + "/acme.go.tito.io/move" |
| + claimFor(t, fx, "acme.example.com", "ie-box", "ie") |
| + return fx, token, u + "/acme.example.com/move" |
| } |
| func admitRun(t *testing.T, rel release.Store, id string) { |
| t.Helper() |
| - if _, err := provision.SetRecordRun(context.Background(), rel, "bab", "titogo", "acme.go.tito.io", |
| + if _, err := provision.SetRecordRun(context.Background(), rel, "bab", "titogo", "acme.example.com", |
| provision.RunAdmit(provision.RunAdmission{ID: id, By: "alice@keymail.dev", Deadline: time.Now().Add(time.Minute)})); err != nil { |
| t.Fatal(err) |
| } |
| @@ -73,14 +74,14 @@ func TestPhase1MoveDoorRefusesWhileARunIsOpen(t *testing.T) { |
| if code != http.StatusConflict || errorText(out) != "this move's state does not allow that. read its state and try again" { |
| t.Fatalf("phase 1 move with a run open = %d %s", code, out) |
| } |
| - obs, err := hostclaim.Read(ctx, fx.rel, "acme.go.tito.io") |
| + obs, err := hostclaim.Read(ctx, fx.rel, "acme.example.com") |
| if err != nil { |
| t.Fatal(err) |
| } |
| if obs.Claim.Op.Kind != hostclaim.KindServing { |
| t.Fatalf("claim op = %+v, want it untouched (serving)", obs.Claim.Op) |
| } |
| - if _, err := provision.SetRecordRun(ctx, fx.rel, "bab", "titogo", "acme.go.tito.io", provision.RunExpire("run-p1")); err != nil { |
| + if _, err := provision.SetRecordRun(ctx, fx.rel, "bab", "titogo", "acme.example.com", provision.RunExpire("run-p1")); err != nil { |
| t.Fatal(err) |
| } |
| if code, _, out := rawReq(t, http.MethodPost, moveURL, token, `{"region":"uk"}`); code != http.StatusAccepted { |
| @@ -112,7 +113,7 @@ func TestPhase1MoveDoorUnwindsWhenARunIsAdmittedAfterTheProbe(t *testing.T) { |
| fx, token, moveURL := movePhase1RunFixture(t) |
| ctx := context.Background() |
| rel := fx.rel |
| - hook := &beforePut{Store: rel, key: "control/hosts/acme.go.tito.io.json", fn: func() { admitRun(t, rel, "run-race") }} |
| + hook := &beforePut{Store: rel, key: "control/hosts/acme.example.com.json", fn: func() { admitRun(t, rel, "run-race") }} |
| fx.srv.cfg.Releases = hook |
| code, _, out := rawReq(t, http.MethodPost, moveURL, token, `{"region":"uk"}`) |
| fx.srv.cfg.Releases = rel |
| @@ -122,14 +123,14 @@ func TestPhase1MoveDoorUnwindsWhenARunIsAdmittedAfterTheProbe(t *testing.T) { |
| if code != http.StatusBadGateway || errorText(out) != "could not record the move. try again" { |
| t.Fatalf("move racing a run = %d %s", code, out) |
| } |
| - obs, err := hostclaim.Read(ctx, rel, "acme.go.tito.io") |
| + obs, err := hostclaim.Read(ctx, rel, "acme.example.com") |
| if err != nil { |
| t.Fatal(err) |
| } |
| if obs.Claim.Op.Kind != hostclaim.KindServing || obs.Claim.Op.Exec != "ie-box" || obs.Claim.Op.Journal["released_move"] == "" { |
| t.Fatalf("claim op = %+v, want serving under ie-box with the move released", obs.Claim.Op) |
| } |
| - rec, err := provision.GetRecord(ctx, rel, "bab", "titogo", "acme.go.tito.io") |
| + rec, err := provision.GetRecord(ctx, rel, "bab", "titogo", "acme.example.com") |
| if err != nil { |
| t.Fatal(err) |
| } |
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go| index b782dd227..fdba18f99 100644 |
| --- a/internal/console/claim_invariant_fixtures_test.go |
| +++ b/internal/console/claim_invariant_fixtures_test.go |
| @@ -1152,31 +1152,31 @@ var claimFixtures = map[string]claimFixture{ |
| // run route refuses on a host-claim console (claimUnsupported). |
| "route POST /api/cli/apps/{account}/{app}/instances/{host}/runs": {refused: &claimRefusalFixture{ |
| apps: claimRefs("bab/titogo"), |
| - do: claimRefusedAPI(http.MethodPost, "/api/cli/apps/bab/titogo/instances/acme.go.tito.io/runs", `{}`), |
| + do: claimRefusedAPI(http.MethodPost, "/api/cli/apps/bab/titogo/instances/acme.example.com/runs", `{}`), |
| status: http.StatusConflict, |
| msg: claimRunUnsupportedMsg, |
| }}, |
| "route GET /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}": {refused: &claimRefusalFixture{ |
| apps: claimRefs("bab/titogo"), |
| - do: claimRefusedAPI(http.MethodGet, "/api/cli/apps/bab/titogo/instances/acme.go.tito.io/runs/run_aaaaaaaaaaaaaaaaaaaaaaaaaa", ""), |
| + do: claimRefusedAPI(http.MethodGet, "/api/cli/apps/bab/titogo/instances/acme.example.com/runs/run_aaaaaaaaaaaaaaaaaaaaaaaaaa", ""), |
| status: http.StatusConflict, |
| msg: claimRunUnsupportedMsg, |
| }}, |
| "route POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/cancel": {refused: &claimRefusalFixture{ |
| apps: claimRefs("bab/titogo"), |
| - do: claimRefusedAPI(http.MethodPost, "/api/cli/apps/bab/titogo/instances/acme.go.tito.io/runs/run_aaaaaaaaaaaaaaaaaaaaaaaaaa/cancel", `{}`), |
| + do: claimRefusedAPI(http.MethodPost, "/api/cli/apps/bab/titogo/instances/acme.example.com/runs/run_aaaaaaaaaaaaaaaaaaaaaaaaaa/cancel", `{}`), |
| status: http.StatusConflict, |
| msg: claimRunUnsupportedMsg, |
| }}, |
| "route POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/expire": {refused: &claimRefusalFixture{ |
| apps: claimRefs("bab/titogo"), |
| - do: claimRefusedAPI(http.MethodPost, "/api/cli/apps/bab/titogo/instances/acme.go.tito.io/runs/run_aaaaaaaaaaaaaaaaaaaaaaaaaa/expire", `{}`), |
| + do: claimRefusedAPI(http.MethodPost, "/api/cli/apps/bab/titogo/instances/acme.example.com/runs/run_aaaaaaaaaaaaaaaaaaaaaaaaaa/expire", `{}`), |
| status: http.StatusConflict, |
| msg: claimRunUnsupportedMsg, |
| }}, |
| "route POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/ack": {refused: &claimRefusalFixture{ |
| apps: claimRefs("bab/titogo"), |
| - do: claimRefusedAPI(http.MethodPost, "/api/cli/apps/bab/titogo/instances/acme.go.tito.io/runs/run_aaaaaaaaaaaaaaaaaaaaaaaaaa/ack", `{}`), |
| + do: claimRefusedAPI(http.MethodPost, "/api/cli/apps/bab/titogo/instances/acme.example.com/runs/run_aaaaaaaaaaaaaaaaaaaaaaaaaa/ack", `{}`), |
| status: http.StatusConflict, |
| msg: claimRunUnsupportedMsg, |
| }}, |
diff --git a/internal/console/runsweep_test.go b/internal/console/runsweep_test.go| index 860c3cdc7..ecc9c2c23 100644 |
| --- a/internal/console/runsweep_test.go |
| +++ b/internal/console/runsweep_test.go |
| @@ -16,7 +16,7 @@ import ( |
| func (fx *runFx) record(t *testing.T) *provision.Record { |
| t.Helper() |
| - rec, err := provision.GetRecord(context.Background(), fx.rel, release.OpsAccount, "titogo", runTestHost) |
| + rec, err := provision.GetRecord(context.Background(), fx.rel, release.OpsAccount, "shop", runTestHost) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -46,7 +46,7 @@ func TestRunSweepExpiresAQueuedRunWhoseCallerLeft(t *testing.T) { |
| if r := fx.record(t).ActiveRun; r.State != provision.RunExpired { |
| t.Fatalf("not expired 60 s past the request (codex R3-3): %+v", r) |
| } |
| - events, _ := fx.st.Events(OpsAccountID, "titogo", 20) |
| + events, _ := fx.st.Events(OpsAccountID, "shop", 20) |
| found := false |
| for _, e := range events { |
| found = found || (e.Action == "run-end" && strings.Contains(e.Detail, id) && strings.Contains(e.Detail, `"expired"`)) |
| @@ -55,7 +55,7 @@ func TestRunSweepExpiresAQueuedRunWhoseCallerLeft(t *testing.T) { |
| t.Error("no run-end expired row") |
| } |
| // The expire route's own result: a follower can read why it ended. |
| - res, err := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id) |
| + res, err := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "shop", id) |
| if err != nil || res == nil || res.Refused != runs.RefusedExpired { |
| t.Fatalf("expired result %+v, %v", res, err) |
| } |
| @@ -70,17 +70,17 @@ func TestRunSweepExpiresAQueuedRunWhoseCallerLeft(t *testing.T) { |
| func TestRunSweepExpiresByTheRecordsDeadlineNotTheRequests(t *testing.T) { |
| fx := runFixture(t) |
| id := fx.startRun(t) |
| - req, err := runs.ReadRequest(context.Background(), fx.rel, release.OpsAccount, "titogo", id) |
| + req, err := runs.ReadRequest(context.Background(), fx.rel, release.OpsAccount, "shop", id) |
| if err != nil { |
| t.Fatal(err) |
| } |
| req.RequestedAt = time.Now().Add(-10 * time.Minute) |
| raw, _ := json.Marshal(req) |
| - _, etag, err := fx.rel.Get(context.Background(), runs.RequestKey(release.OpsAccount, "titogo", id)) |
| + _, etag, err := fx.rel.Get(context.Background(), runs.RequestKey(release.OpsAccount, "shop", id)) |
| if err != nil { |
| t.Fatal(err) |
| } |
| - if _, err := fx.rel.Put(context.Background(), runs.RequestKey(release.OpsAccount, "titogo", id), raw, etag); err != nil { |
| + if _, err := fx.rel.Put(context.Background(), runs.RequestKey(release.OpsAccount, "shop", id), raw, etag); err != nil { |
| t.Fatal(err) |
| } |
| fx.srv.runSweep(context.Background(), time.Now().Add(10*time.Second)) |
| @@ -97,7 +97,7 @@ func TestRunSweepExpiryLosesToALatePickup(t *testing.T) { |
| if r := fx.record(t).ActiveRun; r.State != provision.RunPicked { |
| t.Fatalf("the sweep overrode a pickup: %+v", r) |
| } |
| - if res, _ := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id); res != nil { |
| + if res, _ := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "shop", id); res != nil { |
| t.Fatalf("the losing sweep wrote a result: %+v", res) |
| } |
| if ends := fx.runEnds(t, id); len(ends) != 0 { |
| @@ -111,7 +111,7 @@ func TestRunSweepExpiryBeatsALatePickupTheOtherWay(t *testing.T) { |
| fx := runFixture(t) |
| id := fx.startRun(t) |
| fx.srv.runSweep(context.Background(), time.Now().Add(2*time.Minute)) |
| - _, err := provision.SetRecordRun(context.Background(), fx.rel, release.OpsAccount, "titogo", runTestHost, |
| + _, err := provision.SetRecordRun(context.Background(), fx.rel, release.OpsAccount, "shop", runTestHost, |
| provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| if !errors.Is(err, provision.ErrRunConflict) { |
| t.Fatalf("a pickup after the sweep expired the run: %v", err) |
| @@ -135,7 +135,7 @@ func TestRunSweepMarksALostRunDone(t *testing.T) { |
| if r := fx.record(t).ActiveRun; r.State != provision.RunDone { |
| t.Fatalf("lost run not done: %+v", r) |
| } |
| - res, err := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id) |
| + res, err := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "shop", id) |
| if err != nil || res == nil || res.Interrupted != runs.InterruptedLost { |
| t.Fatalf("lost result %+v, %v", res, err) |
| } |
| @@ -169,14 +169,14 @@ func TestRunSweepLostRunKeepsABoxResultThatWonTheWrite(t *testing.T) { |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Minute))) |
| own := runs.Result{Exit: 3, Started: time.Now().Add(-time.Hour), Ended: time.Now().Add(-59 * time.Minute)} |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, own); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, own); err != nil { |
| t.Fatal(err) |
| } |
| fx.srv.runSweep(context.Background(), time.Now().Add(2*time.Hour)) |
| if r := fx.record(t).ActiveRun; r.State != provision.RunDone { |
| t.Fatalf("%+v", r) |
| } |
| - res, _ := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id) |
| + res, _ := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "shop", id) |
| if res == nil || res.Exit != 3 || res.Interrupted != "" { |
| t.Fatalf("the box's result was overwritten: %+v", res) |
| } |
| @@ -190,7 +190,7 @@ func TestRunSweepClearsTerminalRunsAfterADay(t *testing.T) { |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| ended := time.Now() |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Ended: ended}); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Ended: ended}); err != nil { |
| t.Fatal(err) |
| } |
| fx.transition(t, provision.RunFinish(id)) |
| @@ -202,7 +202,7 @@ func TestRunSweepClearsTerminalRunsAfterADay(t *testing.T) { |
| if r := fx.record(t).ActiveRun; r != nil { |
| t.Fatalf("not cleared after 24 hours: %+v", r) |
| } |
| - if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "titogo", id)); len(left) != 0 { |
| + if left, _ := fx.rel.List(context.Background(), runs.Prefix(release.OpsAccount, "shop", id)); len(left) != 0 { |
| t.Fatalf("objects left %q", left) |
| } |
| } |
| @@ -235,7 +235,7 @@ func TestRunSweepFinishesAnExpiredRunThatHasNoResult(t *testing.T) { |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunExpire(id)) |
| fx.srv.runSweep(context.Background(), time.Now()) |
| - res, err := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id) |
| + res, err := runs.ReadResult(context.Background(), fx.rel, release.OpsAccount, "shop", id) |
| if err != nil || res == nil || res.Refused != runs.RefusedExpired { |
| t.Fatalf("result %+v, %v", res, err) |
| } |
| @@ -248,7 +248,7 @@ func TestRunSweepFinishesAnExpiredRunThatHasNoResult(t *testing.T) { |
| func TestRunSweepDeletesOrphanRunDirectories(t *testing.T) { |
| fx := runFixture(t) |
| ctx := context.Background() |
| - old := runs.Request{Schema: 1, ID: "run_cccccccccccccccccccccccccc", Account: release.OpsAccount, App: "titogo", Host: runTestHost, RequestedAt: time.Now().Add(-25 * time.Hour)} |
| + old := runs.Request{Schema: 1, ID: "run_cccccccccccccccccccccccccc", Account: release.OpsAccount, App: "shop", Host: runTestHost, RequestedAt: time.Now().Add(-25 * time.Hour)} |
| fx.putRunJSON(t, runs.RequestKey(old.Account, old.App, old.ID), old) |
| young := old |
| young.ID, young.RequestedAt = "run_dddddddddddddddddddddddddd", time.Now() |
| @@ -280,16 +280,16 @@ func TestRunSweepReapsAStrayRunDirectoryByItsNewestObject(t *testing.T) { |
| fx := runFixture(t) |
| ctx := context.Background() |
| id := "run_eeeeeeeeeeeeeeeeeeeeeeeeee" |
| - if _, err := fx.rel.Put(ctx, runs.ResultKey(release.OpsAccount, "titogo", id), []byte(`{}`), ""); err != nil { |
| + if _, err := fx.rel.Put(ctx, runs.ResultKey(release.OpsAccount, "shop", id), []byte(`{}`), ""); err != nil { |
| t.Fatal(err) |
| } |
| fx.srv.runSweep(ctx, time.Now()) |
| fx.srv.runSweep(ctx, time.Now()) |
| - if left, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "titogo", id)); len(left) == 0 { |
| + if left, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "shop", id)); len(left) == 0 { |
| t.Fatal("a stray written a moment ago was deleted") |
| } |
| fx.srv.runSweep(ctx, time.Now().Add(25*time.Hour)) |
| - if left, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "titogo", id)); len(left) != 0 { |
| + if left, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "shop", id)); len(left) != 0 { |
| t.Fatalf("a day-old stray survived: %q", left) |
| } |
| } |
| @@ -303,13 +303,13 @@ func TestRunSweepLeavesAStrayAloneWithoutModTimes(t *testing.T) { |
| t.Fatal("the wrapper still lists modification times") |
| } |
| id := "run_ffffffffffffffffffffffffff" |
| - if _, err := fx.rel.Put(ctx, runs.ResultKey(release.OpsAccount, "titogo", id), []byte(`{}`), ""); err != nil { |
| + if _, err := fx.rel.Put(ctx, runs.ResultKey(release.OpsAccount, "shop", id), []byte(`{}`), ""); err != nil { |
| t.Fatal(err) |
| } |
| for i := 0; i < 3; i++ { |
| fx.srv.runSweep(ctx, time.Now().Add(48*time.Hour)) |
| } |
| - if left, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "titogo", id)); len(left) == 0 { |
| + if left, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "shop", id)); len(left) == 0 { |
| t.Fatal("a stray was deleted by a store that cannot say how old it is") |
| } |
| } |
| @@ -318,11 +318,11 @@ func TestRunSweepLeavesAnUnreadableRequestAlone(t *testing.T) { |
| fx := runFixture(t) |
| ctx := context.Background() |
| id := "run_hhhhhhhhhhhhhhhhhhhhhhhhhh" |
| - if _, err := fx.rel.Put(ctx, runs.RequestKey(release.OpsAccount, "titogo", id), bytes.Repeat([]byte("x"), 8), ""); err != nil { |
| + if _, err := fx.rel.Put(ctx, runs.RequestKey(release.OpsAccount, "shop", id), bytes.Repeat([]byte("x"), 8), ""); err != nil { |
| t.Fatal(err) |
| } |
| fx.srv.runSweep(ctx, time.Now().Add(48*time.Hour)) |
| - if left, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "titogo", id)); len(left) == 0 { |
| + if left, _ := fx.rel.List(ctx, runs.Prefix(release.OpsAccount, "shop", id)); len(left) == 0 { |
| t.Fatal("a directory whose request could not be read was deleted") |
| } |
| } |
| @@ -334,7 +334,7 @@ func TestRunSweepLostRunRowSaysLostWhenAPollGotThereFirst(t *testing.T) { |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Minute))) |
| lost := runs.Result{Interrupted: runs.InterruptedLost, Box: "box-1", Ended: time.Now().Add(2 * time.Hour)} |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, lost); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, lost); err != nil { |
| t.Fatal(err) |
| } |
| if p := fx.page(t, id, 0); p.Result == nil { |
| @@ -356,7 +356,7 @@ func TestRunSweepWritesTheRowOfAFinishedRunNobodyFollowed(t *testing.T) { |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| ended := time.Now() |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, runs.Result{Exit: 2, Ended: ended}); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, runs.Result{Exit: 2, Ended: ended}); err != nil { |
| t.Fatal(err) |
| } |
| fx.transition(t, provision.RunFinish(id)) |
| @@ -380,7 +380,7 @@ func TestRunSweepWritesTheRowOfALostRunItsSweepDiedOn(t *testing.T) { |
| id := fx.startRun(t) |
| fx.transition(t, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Minute))) |
| lost := runs.Result{Interrupted: runs.InterruptedLost, Box: "box-1", Ended: time.Now()} |
| - if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "titogo", id, lost); err != nil { |
| + if err := runs.WriteResult(context.Background(), fx.rel, release.OpsAccount, "shop", id, lost); err != nil { |
| t.Fatal(err) |
| } |
| fx.transition(t, provision.RunFinish(id)) |
| @@ -395,7 +395,7 @@ func TestRunSweepWritesTheRowOfALostRunItsSweepDiedOn(t *testing.T) { |
| func TestRunSweepHousekeepingPhasesSkipOffPasses(t *testing.T) { |
| fx := runFixture(t) |
| ctx := context.Background() |
| - old := runs.Request{Schema: 1, ID: "run_cccccccccccccccccccccccccc", Account: release.OpsAccount, App: "titogo", Host: runTestHost, RequestedAt: time.Now().Add(-25 * time.Hour)} |
| + old := runs.Request{Schema: 1, ID: "run_cccccccccccccccccccccccccc", Account: release.OpsAccount, App: "shop", Host: runTestHost, RequestedAt: time.Now().Add(-25 * time.Hour)} |
| fx.putRunJSON(t, runs.RequestKey(old.Account, old.App, old.ID), old) |
| fx.startRun(t) |
| fx.srv.runSweepPass(ctx, time.Now().Add(2*time.Minute), false) |
diff --git a/internal/host/runs_test.go b/internal/host/runs_test.go| index 2282f0d2c..2bd35d3ec 100644 |
| --- a/internal/host/runs_test.go |
| +++ b/internal/host/runs_test.go |
| @@ -21,10 +21,10 @@ import ( |
| "github.com/carlosframework/platform/internal/runs" |
| ) |
| -const runHost = "acme.go.tito.io" |
| +const runHost = "acme.example.com" |
| func runRecord() provision.Record { |
| - return provision.Record{Schema: 1, Host: runHost, Slug: "acme", App: "titogo", Account: "bab", Region: "ie", Channel: "stable", CreatedAt: time.Now().UTC()} |
| + return provision.Record{Schema: 1, Host: runHost, Slug: "acme", App: "shop", Account: "bab", Region: "ie", Channel: "stable", CreatedAt: time.Now().UTC()} |
| } |
| func runOwnedRoute(host string) func(string) (*registry.Route, error) { |
| @@ -32,7 +32,7 @@ func runOwnedRoute(host string) func(string) (*registry.Route, error) { |
| if h != host { |
| return nil, nil |
| } |
| - return ®istry.Route{Host: host, Kind: "instance", Hibernate: true, Socket: "/run/x.sock", Provisioned: true, App: "titogo", Account: "bab"}, nil |
| + return ®istry.Route{Host: host, Kind: "instance", Hibernate: true, Socket: "/run/x.sock", Provisioned: true, App: "shop", Account: "bab"}, nil |
| } |
| } |
| @@ -80,7 +80,7 @@ func testWorker(s release.Store, routes func(string) (*registry.Route, error), b |
| func currentRun(t *testing.T, s release.Store) *provision.RunState { |
| t.Helper() |
| - rec, err := provision.GetRecord(context.Background(), s, "bab", "titogo", runHost) |
| + rec, err := provision.GetRecord(context.Background(), s, "bab", "shop", runHost) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -136,7 +136,7 @@ func TestRunsWorkerNeverPicksACancelledOrExpiredRun(t *testing.T) { |
| for _, mut := range []func(string) func(*provision.Record) error{provision.RunCancelTransition, provision.RunExpire} { |
| s := release.NewDirStore(t.TempDir()) |
| rec, id := queueRun(t, s, time.Now().Add(time.Minute)) |
| - if _, err := provision.SetRecordRun(context.Background(), s, "bab", "titogo", runHost, mut(id)); err != nil { |
| + if _, err := provision.SetRecordRun(context.Background(), s, "bab", "shop", runHost, mut(id)); err != nil { |
| t.Fatal(err) |
| } |
| var l execLog |
| @@ -151,11 +151,11 @@ func TestRunsWorkerNeverPicksACancelledOrExpiredRun(t *testing.T) { |
| func TestRunsWorkerClosesOutARunPickedUnderAnEarlierBoot(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| _, id := queueRun(t, s, time.Now().Add(time.Minute)) |
| - got, err := provision.SetRecordRun(context.Background(), s, "bab", "titogo", runHost, provision.RunPick(id, "box-1", "boot-old", time.Now().Add(time.Hour))) |
| + got, err := provision.SetRecordRun(context.Background(), s, "bab", "shop", runHost, provision.RunPick(id, "box-1", "boot-old", time.Now().Add(time.Hour))) |
| if err != nil { |
| t.Fatal(err) |
| } |
| - if _, err := s.Put(context.Background(), runs.ChunkKey("bab", "titogo", id, 4, runs.StreamOut), []byte("x"), ""); err != nil { |
| + if _, err := s.Put(context.Background(), runs.ChunkKey("bab", "shop", id, 4, runs.StreamOut), []byte("x"), ""); err != nil { |
| t.Fatal(err) |
| } |
| var l execLog |
| @@ -163,7 +163,7 @@ func TestRunsWorkerClosesOutARunPickedUnderAnEarlierBoot(t *testing.T) { |
| if l.count() != 0 { |
| t.Fatal("a run picked before an agent restart was run again") |
| } |
| - res, err := runs.ReadResult(context.Background(), s, "bab", "titogo", id) |
| + res, err := runs.ReadResult(context.Background(), s, "bab", "shop", id) |
| if err != nil || res == nil || res.Interrupted != runs.InterruptedAgentRestart || res.LastSeq != 4 || res.Box != "box-1" { |
| t.Fatalf("result %+v, %v", res, err) |
| } |
| @@ -179,11 +179,11 @@ func TestRunsWorkerForwardsACancelToItsRun(t *testing.T) { |
| w := testWorker(s, runOwnedRoute(runHost), "box-1", "boot-1", &l) |
| h := newRunHandle() |
| w.active[id] = h |
| - got, err := provision.SetRecordRun(context.Background(), s, "bab", "titogo", runHost, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| + got, err := provision.SetRecordRun(context.Background(), s, "bab", "shop", runHost, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| if err != nil { |
| t.Fatal(err) |
| } |
| - if got, err = provision.SetRecordRun(context.Background(), s, "bab", "titogo", runHost, provision.RunCancelTransition(id)); err != nil { |
| + if got, err = provision.SetRecordRun(context.Background(), s, "bab", "shop", runHost, provision.RunCancelTransition(id)); err != nil { |
| t.Fatal(err) |
| } |
| w.consider(context.Background(), *got) |
| @@ -246,13 +246,13 @@ func putJSONObject(t *testing.T, s release.Store, key string, v any) { |
| func TestRunsWorkerLeavesARunAnotherBoxPicked(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| _, id := queueRun(t, s, time.Now().Add(time.Minute)) |
| - got, err := provision.SetRecordRun(context.Background(), s, "bab", "titogo", runHost, provision.RunPick(id, "box-2", "boot-old", time.Now().Add(time.Hour))) |
| + got, err := provision.SetRecordRun(context.Background(), s, "bab", "shop", runHost, provision.RunPick(id, "box-2", "boot-old", time.Now().Add(time.Hour))) |
| if err != nil { |
| t.Fatal(err) |
| } |
| var l execLog |
| testWorker(s, runOwnedRoute(runHost), "box-1", "boot-new", &l).consider(context.Background(), *got) |
| - if res, err := runs.ReadResult(context.Background(), s, "bab", "titogo", id); err != nil || res != nil { |
| + if res, err := runs.ReadResult(context.Background(), s, "bab", "shop", id); err != nil || res != nil { |
| t.Fatalf("a box wrote a result for a run another box picked: %+v, %v", res, err) |
| } |
| if r := currentRun(t, s); l.count() != 0 || r.State != provision.RunPicked || r.Box != "box-2" { |
| @@ -266,13 +266,13 @@ func TestRunsWorkerLeavesARunAnotherBoxPicked(t *testing.T) { |
| func TestRunsWorkerLeavesItsOwnRunUnderThisBoot(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| _, id := queueRun(t, s, time.Now().Add(time.Minute)) |
| - got, err := provision.SetRecordRun(context.Background(), s, "bab", "titogo", runHost, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| + got, err := provision.SetRecordRun(context.Background(), s, "bab", "shop", runHost, provision.RunPick(id, "box-1", "boot-1", time.Now().Add(time.Hour))) |
| if err != nil { |
| t.Fatal(err) |
| } |
| var l execLog |
| testWorker(s, runOwnedRoute(runHost), "box-1", "boot-1", &l).consider(context.Background(), *got) |
| - if res, err := runs.ReadResult(context.Background(), s, "bab", "titogo", id); err != nil || res != nil { |
| + if res, err := runs.ReadResult(context.Background(), s, "bab", "shop", id); err != nil || res != nil { |
| t.Fatalf("a run of this boot was closed out as interrupted: %+v, %v", res, err) |
| } |
| if r := currentRun(t, s); l.count() != 0 || r.State != provision.RunPicked { |
| @@ -317,7 +317,7 @@ func TestRunsWorkerLeavesARequestThatDoesNotMatchItsRecord(t *testing.T) { |
| "another id": func(r *runs.Request) { r.ID = "run_bbbbbbbbbbbbbbbbbbbbbbbbbb" }, |
| "another account": func(r *runs.Request) { r.Account = "other" }, |
| "another app": func(r *runs.Request) { r.App = "other" }, |
| - "another host": func(r *runs.Request) { r.Host = "other.go.tito.io" }, |
| + "another host": func(r *runs.Request) { r.Host = "other.example.com" }, |
| } { |
| s := release.NewDirStore(t.TempDir()) |
| rec, id := queueRun(t, s, time.Now().Add(time.Minute)) |
| @@ -376,7 +376,7 @@ type lostAnswer struct { |
| } |
| func (l *lostAnswer) Put(ctx context.Context, key string, body []byte, ifMatch string) (string, error) { |
| - if key != provision.RecordKey("bab", "titogo", runHost) { |
| + if key != provision.RecordKey("bab", "shop", runHost) { |
| return l.Store.Put(ctx, key, body, ifMatch) |
| } |
| if l.land { |
diff --git a/internal/provision/reconcile_test.go b/internal/provision/reconcile_test.go| index 6d6080a95..89c09984a 100644 |
| --- a/internal/provision/reconcile_test.go |
| +++ b/internal/provision/reconcile_test.go |
| @@ -3557,12 +3557,16 @@ func TestWithHostHoldLockIsExclusivePerHost(t *testing.T) { |
| // mints, and none out of scope. |
| func TestReconcileHandsRunsToRunSeen(t *testing.T) { |
| s, sqid := setup(t) |
| - withRun := acmeRecord(sqid) |
| + shopRecord := func(host, slug string) Record { |
| + rec := acmeRecord(sqid) |
| + rec.Host, rec.Slug, rec.App, rec.Pool = host, slug, "shop", "shared" |
| + return rec |
| + } |
| + withRun := shopRecord("acme.example.com", "acme") |
| withRun.ActiveRun = &RunState{ID: "run_abcdefghijklmnopqrstuvwxyz", State: RunQueued, Deadline: time.Now().Add(time.Minute)} |
| - plain := acmeRecord(sqid) |
| - plain.Host, plain.Slug = "plain.go.tito.io", "plain" |
| - away := acmeRecord(sqid) |
| - away.Host, away.Slug, away.Region = "away.go.tito.io", "away", "uk" |
| + plain := shopRecord("plain.example.com", "plain") |
| + away := shopRecord("away.example.com", "away") |
| + away.Region = "uk" |
| away.ActiveRun = withRun.ActiveRun |
| for _, rec := range []Record{withRun, plain, away} { |
| if err := CreateRecord(ctx, s, rec); err != nil { |
| @@ -3570,13 +3574,13 @@ func TestReconcileHandsRunsToRunSeen(t *testing.T) { |
| } |
| } |
| var seen []string |
| - cfg := ReconcileConfig{Region: "ie", Pools: []string{"tito"}, DataDir: "/data", RunSeen: func(rec Record) { |
| + cfg := ReconcileConfig{Region: "ie", Pools: []string{"shared"}, DataDir: "/data", RunSeen: func(rec Record) { |
| seen = append(seen, rec.Host+":"+rec.ActiveRun.ID) |
| }} |
| if err := Reconcile(ctx, s, regWith(t), cfg); err != nil { |
| t.Fatal(err) |
| } |
| - if len(seen) != 1 || seen[0] != "acme.go.tito.io:run_abcdefghijklmnopqrstuvwxyz" { |
| + if len(seen) != 1 || seen[0] != "acme.example.com:run_abcdefghijklmnopqrstuvwxyz" { |
| t.Fatalf("RunSeen saw %q", seen) |
| } |
| } |
diff --git a/internal/runs/chunker_test.go b/internal/runs/chunker_test.go| index d7937c13e..3c688e6bf 100644 |
| --- a/internal/runs/chunker_test.go |
| +++ b/internal/runs/chunker_test.go |
| @@ -16,7 +16,7 @@ const tid = "run_abcdefghijklmnopqrstuvwxyz" |
| func chunksOf(t *testing.T, s release.Store) []string { |
| t.Helper() |
| - keys, err := ListChunks(context.Background(), s, "bab", "titogo", tid, 0, 0) |
| + keys, err := ListChunks(context.Background(), s, "bab", "shop", tid, 0, 0) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -26,7 +26,7 @@ func chunksOf(t *testing.T, s release.Store) []string { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - _, stream, _ := ParseChunkKey(k, OutPrefix("bab", "titogo", tid)) |
| + _, stream, _ := ParseChunkKey(k, OutPrefix("bab", "shop", tid)) |
| out = append(out, stream+":"+string(raw)) |
| } |
| return out |
| @@ -34,7 +34,7 @@ func chunksOf(t *testing.T, s release.Store) []string { |
| func TestChunkerKeepsReadOrderAcrossStreams(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| - c := newChunker(context.Background(), s, "bab", "titogo", tid, time.Hour, MaxOutputBytes) |
| + c := newChunker(context.Background(), s, "bab", "shop", tid, time.Hour, MaxOutputBytes) |
| io.WriteString(c.Stream(StreamOut), "a") |
| io.WriteString(c.Stream(StreamErr), "b") |
| io.WriteString(c.Stream(StreamOut), "c") |
| @@ -50,7 +50,7 @@ func TestChunkerKeepsReadOrderAcrossStreams(t *testing.T) { |
| func TestChunkerFlushesOnTheTickAndAtTheSizeLimit(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| - c := newChunker(context.Background(), s, "bab", "titogo", tid, 20*time.Millisecond, MaxOutputBytes) |
| + c := newChunker(context.Background(), s, "bab", "shop", tid, 20*time.Millisecond, MaxOutputBytes) |
| io.WriteString(c.Stream(StreamOut), "tick") |
| deadline := time.Now().Add(2 * time.Second) |
| for len(chunksOf(t, s)) == 0 && time.Now().Before(deadline) { |
| @@ -59,9 +59,9 @@ func TestChunkerFlushesOnTheTickAndAtTheSizeLimit(t *testing.T) { |
| if got := chunksOf(t, s); len(got) != 1 || got[0] != "o:tick" { |
| t.Fatalf("after a tick: %q", got) |
| } |
| - c2 := newChunker(context.Background(), s, "bab", "titogo", "run_bbbbbbbbbbbbbbbbbbbbbbbbbb", time.Hour, MaxOutputBytes) |
| + c2 := newChunker(context.Background(), s, "bab", "shop", "run_bbbbbbbbbbbbbbbbbbbbbbbbbb", time.Hour, MaxOutputBytes) |
| io.WriteString(c2.Stream(StreamOut), strings.Repeat("x", ChunkBytes+1)) |
| - keys, _ := ListChunks(context.Background(), s, "bab", "titogo", "run_bbbbbbbbbbbbbbbbbbbbbbbbbb", 0, 0) |
| + keys, _ := ListChunks(context.Background(), s, "bab", "shop", "run_bbbbbbbbbbbbbbbbbbbbbbbbbb", 0, 0) |
| if len(keys) != 1 { |
| t.Fatalf("a full chunk must flush at once: %q", keys) |
| } |
| @@ -73,7 +73,7 @@ func TestChunkerFlushesOnTheTickAndAtTheSizeLimit(t *testing.T) { |
| func TestChunkerStopsAtTheCapAndSaysSo(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| - c := newChunker(context.Background(), s, "bab", "titogo", tid, time.Hour, 10) |
| + c := newChunker(context.Background(), s, "bab", "shop", tid, time.Hour, 10) |
| n, err := io.WriteString(c.Stream(StreamOut), "0123456789abcdef") |
| if n != 16 || err != nil { |
| t.Fatalf("a write past the cap must not fail the stream: %d %v", n, err) |
| @@ -108,7 +108,7 @@ func (f *failingStore) Put(ctx context.Context, key string, body []byte, ifMatch |
| func TestChunkerRetriesAFailedPut(t *testing.T) { |
| s := &failingStore{Store: release.NewDirStore(t.TempDir()), fail: 2} |
| - c := newChunker(context.Background(), s, "bab", "titogo", tid, time.Hour, MaxOutputBytes) |
| + c := newChunker(context.Background(), s, "bab", "shop", tid, time.Hour, MaxOutputBytes) |
| io.WriteString(c.Stream(StreamOut), "once") |
| last, _, err := c.Close() |
| if err != nil || last != 1 { |
| @@ -122,7 +122,7 @@ func TestChunkerRetriesAFailedPut(t *testing.T) { |
| func TestChunkerGivesUpWhenItsContextEnds(t *testing.T) { |
| ctx, cancel := context.WithCancel(context.Background()) |
| s := &failingStore{Store: release.NewDirStore(t.TempDir()), fail: 1 << 30} |
| - c := newChunker(ctx, s, "bab", "titogo", tid, time.Hour, MaxOutputBytes) |
| + c := newChunker(ctx, s, "bab", "shop", tid, time.Hour, MaxOutputBytes) |
| go func() { time.Sleep(50 * time.Millisecond); cancel() }() |
| io.WriteString(c.Stream(StreamOut), strings.Repeat("x", ChunkBytes)) |
| _, truncated, err := c.Close() |
| @@ -154,7 +154,7 @@ func (d *dyingStore) Put(ctx context.Context, key string, body []byte, ifMatch s |
| func TestChunkerReportsTheLastSeqThatLanded(t *testing.T) { |
| ctx, cancel := context.WithCancel(context.Background()) |
| s := &dyingStore{Store: release.NewDirStore(t.TempDir()), ok: 1} |
| - c := newChunker(ctx, s, "bab", "titogo", tid, time.Hour, MaxOutputBytes) |
| + c := newChunker(ctx, s, "bab", "shop", tid, time.Hour, MaxOutputBytes) |
| go func() { time.Sleep(50 * time.Millisecond); cancel() }() |
| io.WriteString(c.Stream(StreamOut), strings.Repeat("x", ChunkBytes)) // chunk 1 lands |
| io.WriteString(c.Stream(StreamOut), strings.Repeat("y", ChunkBytes)) // chunk 2 gives up |
| @@ -173,7 +173,7 @@ func TestChunkerGivingUpMidWriteDoesNotHang(t *testing.T) { |
| ctx, cancel := context.WithCancel(context.Background()) |
| cancel() |
| s := &failingStore{Store: release.NewDirStore(t.TempDir()), fail: 1 << 30} |
| - c := newChunker(ctx, s, "bab", "titogo", tid, time.Hour, MaxOutputBytes) |
| + c := newChunker(ctx, s, "bab", "shop", tid, time.Hour, MaxOutputBytes) |
| done := make(chan struct{}) |
| var last int64 |
| var truncated bool |
| @@ -198,7 +198,7 @@ func TestChunkerGivingUpMidWriteDoesNotHang(t *testing.T) { |
| func TestChunkerRejoinsEachStreamWhenBothWriteAtOnce(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| - c := newChunker(context.Background(), s, "bab", "titogo", tid, 2*time.Millisecond, MaxOutputBytes) |
| + c := newChunker(context.Background(), s, "bab", "shop", tid, 2*time.Millisecond, MaxOutputBytes) |
| want := map[string]string{} |
| var wg sync.WaitGroup |
| for _, stream := range []string{StreamOut, StreamErr} { |
| @@ -243,10 +243,10 @@ func TestChunkerRefusesAnInvalidRunAtConstruction(t *testing.T) { |
| acct, app, id string |
| want error |
| }{ |
| - {"bab", "titogo", "run_../../x", ErrBadID}, |
| - {"bab", "titogo", "", ErrBadID}, |
| + {"bab", "shop", "run_../../x", ErrBadID}, |
| + {"bab", "shop", "", ErrBadID}, |
| {"bab", "../other", tid, ErrBadApp}, |
| - {"../bab", "titogo", tid, ErrBadApp}, |
| + {"../bab", "shop", tid, ErrBadApp}, |
| } { |
| c := NewChunker(context.Background(), s, tc.acct, tc.app, tc.id) |
| n, err := io.WriteString(c.Stream(StreamOut), "x") |
| @@ -264,7 +264,7 @@ func TestChunkerRefusesAnInvalidRunAtConstruction(t *testing.T) { |
| func TestChunkerRefusesAnUnknownStream(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| - c := newChunker(context.Background(), s, "bab", "titogo", tid, time.Hour, MaxOutputBytes) |
| + c := newChunker(context.Background(), s, "bab", "shop", tid, time.Hour, MaxOutputBytes) |
| io.WriteString(c.Stream("../x"), "bad") |
| _, _, err := c.Close() |
| if err == nil { |
| @@ -277,7 +277,7 @@ func TestChunkerRefusesAnUnknownStream(t *testing.T) { |
| func TestChunkerDropsWritesAfterClose(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| - c := newChunker(context.Background(), s, "bab", "titogo", tid, time.Hour, MaxOutputBytes) |
| + c := newChunker(context.Background(), s, "bab", "shop", tid, time.Hour, MaxOutputBytes) |
| io.WriteString(c.Stream(StreamOut), "a") |
| last, _, _ := c.Close() |
| io.WriteString(c.Stream(StreamOut), "late") |
diff --git a/internal/runs/runs_test.go b/internal/runs/runs_test.go| index 012d682bd..4b88a0c10 100644 |
| --- a/internal/runs/runs_test.go |
| +++ b/internal/runs/runs_test.go |
| @@ -24,19 +24,19 @@ func TestIDsAndKeys(t *testing.T) { |
| t.Errorf("%q accepted", bad) |
| } |
| } |
| - if got := Prefix("bab", "titogo", id); got != "apps/bab/titogo/runs/"+id+"/" { |
| + if got := Prefix("bab", "shop", id); got != "apps/bab/shop/runs/"+id+"/" { |
| t.Errorf("Prefix = %q", got) |
| } |
| - k := ChunkKey("bab", "titogo", id, 17, StreamErr) |
| - if k != OutPrefix("bab", "titogo", id)+"00000017-e" { |
| + k := ChunkKey("bab", "shop", id, 17, StreamErr) |
| + if k != OutPrefix("bab", "shop", id)+"00000017-e" { |
| t.Errorf("ChunkKey = %q", k) |
| } |
| - seq, stream, ok := ParseChunkKey(k, OutPrefix("bab", "titogo", id)) |
| + seq, stream, ok := ParseChunkKey(k, OutPrefix("bab", "shop", id)) |
| if !ok || seq != 17 || stream != StreamErr { |
| t.Errorf("ParseChunkKey = %d %q %v", seq, stream, ok) |
| } |
| - for _, bad := range []string{OutPrefix("bab", "titogo", id) + "00000017-x", OutPrefix("bab", "titogo", id) + "17-o", "elsewhere"} { |
| - if _, _, ok := ParseChunkKey(bad, OutPrefix("bab", "titogo", id)); ok { |
| + for _, bad := range []string{OutPrefix("bab", "shop", id) + "00000017-x", OutPrefix("bab", "shop", id) + "17-o", "elsewhere"} { |
| + if _, _, ok := ParseChunkKey(bad, OutPrefix("bab", "shop", id)); ok { |
| t.Errorf("ParseChunkKey(%q) accepted", bad) |
| } |
| } |
| @@ -95,35 +95,35 @@ func TestStoreHelpers(t *testing.T) { |
| ctx := context.Background() |
| s := release.NewDirStore(t.TempDir()) |
| id := "run_abcdefghijklmnopqrstuvwxyz" |
| - if r, err := ReadResult(ctx, s, "bab", "titogo", id); r != nil || err != nil { |
| + if r, err := ReadResult(ctx, s, "bab", "shop", id); r != nil || err != nil { |
| t.Fatalf("absent result = %v, %v", r, err) |
| } |
| for seq := int64(1); seq <= 5; seq++ { |
| - if _, err := s.Put(ctx, ChunkKey("bab", "titogo", id, seq, StreamOut), []byte("x"), ""); err != nil { |
| + if _, err := s.Put(ctx, ChunkKey("bab", "shop", id, seq, StreamOut), []byte("x"), ""); err != nil { |
| t.Fatal(err) |
| } |
| } |
| - keys, err := ListChunks(ctx, s, "bab", "titogo", id, 2, 2) |
| + keys, err := ListChunks(ctx, s, "bab", "shop", id, 2, 2) |
| if err != nil || len(keys) != 2 || !strings.HasSuffix(keys[0], "00000003-o") { |
| t.Fatalf("ListChunks = %q, %v", keys, err) |
| } |
| - if last, err := LastChunkSeq(ctx, s, "bab", "titogo", id); err != nil || last != 5 { |
| + if last, err := LastChunkSeq(ctx, s, "bab", "shop", id); err != nil || last != 5 { |
| t.Fatalf("LastChunkSeq = %d, %v", last, err) |
| } |
| first := Result{Exit: 3, LastSeq: 5} |
| - if err := WriteResult(ctx, s, "bab", "titogo", id, first); err != nil { |
| + if err := WriteResult(ctx, s, "bab", "shop", id, first); err != nil { |
| t.Fatal(err) |
| } |
| - if err := WriteResult(ctx, s, "bab", "titogo", id, Result{Interrupted: InterruptedLost}); err != nil { |
| + if err := WriteResult(ctx, s, "bab", "shop", id, Result{Interrupted: InterruptedLost}); err != nil { |
| t.Fatalf("a second result is not an error: %v", err) |
| } |
| - if r, err := ReadResult(ctx, s, "bab", "titogo", id); err != nil || r.Exit != 3 || r.Interrupted != "" { |
| + if r, err := ReadResult(ctx, s, "bab", "shop", id); err != nil || r.Exit != 3 || r.Interrupted != "" { |
| t.Fatalf("the first result must win: %+v, %v", r, err) |
| } |
| - if err := DeleteRun(ctx, s, "bab", "titogo", id); err != nil { |
| + if err := DeleteRun(ctx, s, "bab", "shop", id); err != nil { |
| t.Fatal(err) |
| } |
| - if left, _ := s.List(ctx, Prefix("bab", "titogo", id)); len(left) != 0 { |
| + if left, _ := s.List(ctx, Prefix("bab", "shop", id)); len(left) != 0 { |
| t.Fatalf("DeleteRun left %q", left) |
| } |
| } |
| @@ -180,7 +180,7 @@ func TestMintIDIsRandomAndValid(t *testing.T) { |
| } |
| func TestParseChunkKeyIsCanonicalOnly(t *testing.T) { |
| - out := OutPrefix("bab", "titogo", "run_abcdefghijklmnopqrstuvwxyz") |
| + out := OutPrefix("bab", "shop", "run_abcdefghijklmnopqrstuvwxyz") |
| for _, name := range []string{"+0000017-o", "-0000017-o", "0000000-o", "00000000-o", " 0000017-o", "0x000017-o", "0000017 -o"} { |
| if _, _, ok := ParseChunkKey(out+name, out); ok { |
| t.Errorf("ParseChunkKey(%q) accepted", name) |
| @@ -191,30 +191,30 @@ func TestParseChunkKeyIsCanonicalOnly(t *testing.T) { |
| func TestStoreHelpersRefuseAnIdThatIsNotOne(t *testing.T) { |
| ctx := context.Background() |
| s := release.NewDirStore(t.TempDir()) |
| - if _, err := s.Put(ctx, "apps/bab/titogo/runs/keep", []byte("x"), ""); err != nil { |
| + if _, err := s.Put(ctx, "apps/bab/shop/runs/keep", []byte("x"), ""); err != nil { |
| t.Fatal(err) |
| } |
| for _, id := range []string{"", "..", "../x", "run_x/../..", "run_abcdefghijklmnopqrstuvwxyz/"} { |
| - if _, err := ReadRequest(ctx, s, "bab", "titogo", id); !errors.Is(err, ErrBadID) { |
| + if _, err := ReadRequest(ctx, s, "bab", "shop", id); !errors.Is(err, ErrBadID) { |
| t.Errorf("ReadRequest(%q) = %v", id, err) |
| } |
| - if _, err := ReadResult(ctx, s, "bab", "titogo", id); !errors.Is(err, ErrBadID) { |
| + if _, err := ReadResult(ctx, s, "bab", "shop", id); !errors.Is(err, ErrBadID) { |
| t.Errorf("ReadResult(%q) = %v", id, err) |
| } |
| - if err := WriteResult(ctx, s, "bab", "titogo", id, Result{}); !errors.Is(err, ErrBadID) { |
| + if err := WriteResult(ctx, s, "bab", "shop", id, Result{}); !errors.Is(err, ErrBadID) { |
| t.Errorf("WriteResult(%q) = %v", id, err) |
| } |
| - if _, err := ListChunks(ctx, s, "bab", "titogo", id, 0, 0); !errors.Is(err, ErrBadID) { |
| + if _, err := ListChunks(ctx, s, "bab", "shop", id, 0, 0); !errors.Is(err, ErrBadID) { |
| t.Errorf("ListChunks(%q) = %v", id, err) |
| } |
| - if _, err := LastChunkSeq(ctx, s, "bab", "titogo", id); !errors.Is(err, ErrBadID) { |
| + if _, err := LastChunkSeq(ctx, s, "bab", "shop", id); !errors.Is(err, ErrBadID) { |
| t.Errorf("LastChunkSeq(%q) = %v", id, err) |
| } |
| - if err := DeleteRun(ctx, s, "bab", "titogo", id); !errors.Is(err, ErrBadID) { |
| + if err := DeleteRun(ctx, s, "bab", "shop", id); !errors.Is(err, ErrBadID) { |
| t.Errorf("DeleteRun(%q) = %v", id, err) |
| } |
| } |
| - if left, _ := s.List(ctx, "apps/bab/titogo/runs/"); len(left) != 1 { |
| + if left, _ := s.List(ctx, "apps/bab/shop/runs/"); len(left) != 1 { |
| t.Fatalf("a refused delete touched the store: %q", left) |
| } |
| } |
| @@ -231,7 +231,7 @@ func TestStoreHelpersRefuseAnAccountOrAppThatIsNotOne(t *testing.T) { |
| t.Fatal(err) |
| } |
| before, _ := s.List(ctx, "") |
| - for _, c := range [][2]string{{"bab/titogo", "x"}, {"bab", "../x"}, {"bab", "../../y"}, {"", "titogo"}, {"bab", ""}, {"bab", "a/b"}, {"..", "x"}, {"BAB", "x"}, {"bab", "x\n"}} { |
| + for _, c := range [][2]string{{"bab/shop", "x"}, {"bab", "../x"}, {"bab", "../../y"}, {"", "shop"}, {"bab", ""}, {"bab", "a/b"}, {"..", "x"}, {"BAB", "x"}, {"bab", "x\n"}} { |
| acct, app := c[0], c[1] |
| if _, err := ReadRequest(ctx, s, acct, app, id); !errors.Is(err, ErrBadApp) { |
| t.Errorf("ReadRequest(%q, %q) = %v", acct, app, err) |
| @@ -263,24 +263,24 @@ func TestDeleteRunKeepsTheMarkerAndRequestUntilTheRestIsGone(t *testing.T) { |
| ctx := context.Background() |
| inner := release.NewDirStore(t.TempDir()) |
| id, _ := MintID() |
| - for _, k := range []string{AuditedKey("bab", "titogo", id), RequestKey("bab", "titogo", id), ResultKey("bab", "titogo", id), ChunkKey("bab", "titogo", id, 1, StreamOut)} { |
| + for _, k := range []string{AuditedKey("bab", "shop", id), RequestKey("bab", "shop", id), ResultKey("bab", "shop", id), ChunkKey("bab", "shop", id, 1, StreamOut)} { |
| if _, err := inner.Put(ctx, k, []byte("x"), ""); err != nil { |
| t.Fatal(err) |
| } |
| } |
| - s := &failDelete{Store: inner, fail: ResultKey("bab", "titogo", id)} |
| - if err := DeleteRun(ctx, s, "bab", "titogo", id); err == nil { |
| + s := &failDelete{Store: inner, fail: ResultKey("bab", "shop", id)} |
| + if err := DeleteRun(ctx, s, "bab", "shop", id); err == nil { |
| t.Fatal("a failed delete must be returned") |
| } |
| - left, _ := inner.List(ctx, Prefix("bab", "titogo", id)) |
| + left, _ := inner.List(ctx, Prefix("bab", "shop", id)) |
| if len(left) != 3 { // result, request, audited |
| t.Fatalf("left %q, want result.json, request.json and audited", left) |
| } |
| s.fail = "" |
| - if err := DeleteRun(ctx, s, "bab", "titogo", id); err != nil { |
| + if err := DeleteRun(ctx, s, "bab", "shop", id); err != nil { |
| t.Fatal(err) |
| } |
| - if left, _ := inner.List(ctx, Prefix("bab", "titogo", id)); len(left) != 0 { |
| + if left, _ := inner.List(ctx, Prefix("bab", "shop", id)); len(left) != 0 { |
| t.Fatalf("left %q", left) |
| } |
| } |
diff --git a/internal/runs/stage_linux_test.go b/internal/runs/stage_linux_test.go| index 0554598c8..8c4ea72eb 100644 |
| --- a/internal/runs/stage_linux_test.go |
| +++ b/internal/runs/stage_linux_test.go |
| @@ -21,11 +21,11 @@ import ( |
| func stagedRequest(t *testing.T, s release.Store, files map[string]string) Request { |
| t.Helper() |
| - req := Request{ID: tid, Account: "bab", App: "titogo"} |
| + req := Request{ID: tid, Account: "bab", App: "shop"} |
| for name, body := range files { |
| sum := sha256.Sum256([]byte(body)) |
| req.Files = append(req.Files, File{Name: name, Size: int64(len(body)), SHA256: hex.EncodeToString(sum[:])}) |
| - if _, err := s.Put(context.Background(), InputKey("bab", "titogo", tid, name), []byte(body), ""); err != nil { |
| + if _, err := s.Put(context.Background(), InputKey("bab", "shop", tid, name), []byte(body), ""); err != nil { |
| t.Fatal(err) |
| } |
| } |
| @@ -59,7 +59,7 @@ func TestStageFilesWritesTheUploads(t *testing.T) { |
| func TestStageFilesMakesTheDirectoryWithNoFiles(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| inst := t.TempDir() |
| - dir, err := StageFiles(context.Background(), s, inst, Request{ID: tid, Account: "bab", App: "titogo"}) |
| + dir, err := StageFiles(context.Background(), s, inst, Request{ID: tid, Account: "bab", App: "shop"}) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -148,7 +148,7 @@ func TestStageFilesRefusesASymlinkedRunRoot(t *testing.T) { |
| if err := os.Symlink(outside, filepath.Join(inst, DirName)); err != nil { |
| t.Fatal(err) |
| } |
| - _, err := StageFiles(context.Background(), s, inst, Request{ID: tid, Account: "bab", App: "titogo"}) |
| + _, err := StageFiles(context.Background(), s, inst, Request{ID: tid, Account: "bab", App: "shop"}) |
| if !errors.Is(err, instancefs.ErrSymlink) { |
| t.Fatalf("err %v, want ErrSymlink", err) |
| } |
| @@ -178,7 +178,7 @@ func TestStageFilesRefusesASymlinkedRunDirectory(t *testing.T) { |
| func TestStageFilesRefusesANameThatIsNotPlain(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| - req := Request{ID: tid, Account: "bab", App: "titogo", Files: []File{{Name: "../x", Size: 1}}} |
| + req := Request{ID: tid, Account: "bab", App: "shop", Files: []File{{Name: "../x", Size: 1}}} |
| if _, err := StageFiles(context.Background(), s, t.TempDir(), req); err == nil { |
| t.Fatal("a path name was staged (spec §7: checked again by the agent)") |
| } |
| @@ -187,7 +187,7 @@ func TestStageFilesRefusesANameThatIsNotPlain(t *testing.T) { |
| func TestStageFilesRefusesAnIDThatIsNotARunID(t *testing.T) { |
| s := release.NewDirStore(t.TempDir()) |
| inst := t.TempDir() |
| - if _, err := StageFiles(context.Background(), s, inst, Request{ID: "../x", Account: "bab", App: "titogo"}); err == nil { |
| + if _, err := StageFiles(context.Background(), s, inst, Request{ID: "../x", Account: "bab", App: "shop"}); err == nil { |
| t.Fatal("a bad run id was staged") |
| } |
| if err := RemoveRunDir(inst, ".."); err == nil { |
| @@ -335,12 +335,12 @@ func (c *countingStore) Open(ctx context.Context, key string) (io.ReadCloser, st |
| func TestStageFilesBoundsTheReadByTheRecordedSize(t *testing.T) { |
| inner := release.NewDirStore(t.TempDir()) |
| big := make([]byte, 1<<20) |
| - if _, err := inner.Put(context.Background(), InputKey("bab", "titogo", tid, "a.csv"), big, ""); err != nil { |
| + if _, err := inner.Put(context.Background(), InputKey("bab", "shop", tid, "a.csv"), big, ""); err != nil { |
| t.Fatal(err) |
| } |
| s := &countingStore{Store: inner} |
| sum := sha256.Sum256(big[:3]) |
| - req := Request{ID: tid, Account: "bab", App: "titogo", |
| + req := Request{ID: tid, Account: "bab", App: "shop", |
| Files: []File{{Name: "a.csv", Size: 3, SHA256: hex.EncodeToString(sum[:])}}} |
| inst := t.TempDir() |
| if _, err := StageFiles(context.Background(), s, inst, req); err == nil { |