Step 10 parks on an unstamped build again; the waking park is tested
Fable's fix-review notes on oficina/alta #1 (APPROVED at a829ee8): /api/version answering rastrillo's unstamped "dev" parks version-unstamped once more, and TestServingParksAsleepAndUnstamped covers it and the instance-waking park (a box reporting the instance not awake). Removing either park fails the test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+48
−3
console/fakeconsole/fakeconsole.go+18 −2provision/review_test.go+28 −0provision/steps.go+2 −1
CI passed — run details
diff --git a/console/fakeconsole/fakeconsole.go b/console/fakeconsole/fakeconsole.go| index c1e667f..502d6a5 100644 |
| --- a/console/fakeconsole/fakeconsole.go |
| +++ b/console/fakeconsole/fakeconsole.go |
| @@ -76,6 +76,8 @@ type Console struct { |
| Roster string |
| // ServingName overrides the box's serving report per app. |
| ServingName map[string]string |
| + // VersionAnswer overrides what an app's /api/version answers. |
| + VersionAnswer map[string]string |
| // NoTeamProbe: the roster-mode app serves no /api/team (Docs' main |
| // today). |
| NoTeamProbe bool |
| @@ -94,7 +96,7 @@ type Console struct { |
| func New(account, scope string) *Console { |
| priv, _ := ecdh.P256().GenerateKey(rand.Reader) |
| c := &Console{Account: account, Scope: scope, tokens: map[string]string{}, priv: priv, envs: map[string]map[string]*bundle{}, instances: map[string]*inst{}, domains: map[string]*claim{}, |
| - MailPrefix: map[string]string{}, Relay: map[string]bool{}, Versions: map[string]string{}, DomainPolls: 1, Roster: "ok", SecretWrites: map[string]int{}, ServingName: map[string]string{}} |
| + MailPrefix: map[string]string{}, Relay: map[string]bool{}, Versions: map[string]string{}, DomainPolls: 1, Roster: "ok", SecretWrites: map[string]int{}, ServingName: map[string]string{}, VersionAnswer: map[string]string{}} |
| c.srv = httptest.NewServer(http.HandlerFunc(c.serve)) |
| return c |
| } |
| @@ -264,6 +266,16 @@ func (c *Console) servingName(i *inst) string { |
| return i.serving |
| } |
| +// SetAsleep marks an instance's box report asleep (not awake), as a |
| +// hibernated or starting instance reports. |
| +func (c *Console) SetAsleep(host string, asleep bool) { |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + if i, ok := c.instances[host]; ok { |
| + i.asleep = asleep |
| + } |
| +} |
| + |
| // SetDomainState moves a claim's state word. |
| func (c *Console) SetDomainState(host, state string) { |
| c.mu.Lock() |
| @@ -559,7 +571,11 @@ func (c *Console) Transport() http.RoundTripper { |
| case !ok || d.state != "live" || i == nil: |
| return nil, fmt.Errorf("fakeconsole: %s does not resolve", r.URL.Host) |
| case r.URL.Path == "/api/version": |
| - rec.WriteString(i.serving) |
| + if v, ok := c.VersionAnswer[i.app]; ok { |
| + rec.WriteString(v) |
| + } else { |
| + rec.WriteString(i.serving) |
| + } |
| case r.URL.Path == "/api/team" && i.app == "docs" && !c.NoTeamProbe: |
| b := c.envs[i.app][i.env] |
| _, token := b.vars["DOCS_TEAM_ROSTER_TOKEN"] |
diff --git a/provision/review_test.go b/provision/review_test.go| index 5c028cd..c30f4d6 100644 |
| --- a/provision/review_test.go |
| +++ b/provision/review_test.go |
| @@ -173,3 +173,31 @@ func TestUnansweredRequestAfterTheWindowParks(t *testing.T) { |
| t.Fatalf("%s %s", r.State, r.Code) |
| } |
| } |
| + |
| +// Fix review notes: step 10 parks while the box reports the instance not |
| +// awake, and while /api/version answers rastrillo's unstamped "dev". |
| +func TestServingParksAsleepAndUnstamped(t *testing.T) { |
| + h := newHarness(t) |
| + h.initialized() |
| + e := h.engine(nil) |
| + run, err := e.CreateTeam(h.ctx(), NewTeam{Label: "lagged", Name: "Lagged", Owner: ownerCanary, Apps: []string{"sheets"}}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + h.confirm(homeop.KindCreateTeam) |
| + route := RouteHost("lagged", "sheets", account) |
| + for i := 0; i < 10; i++ { |
| + _ = e.Advance(h.ctx(), run) |
| + h.con.Walk() |
| + h.con.SetAsleep(route, true) |
| + } |
| + if st, _, _ := h.store.Step(h.ctx(), "lagged", "sheets", StepServing); st.State != "parked" || st.Code != "instance-waking" { |
| + t.Fatalf("asleep: serving %s %s", st.State, st.Code) |
| + } |
| + h.con.SetAsleep(route, false) |
| + h.con.VersionAnswer["sheets"] = "dev" |
| + _ = e.Advance(h.ctx(), run) |
| + if st, _, _ := h.store.Step(h.ctx(), "lagged", "sheets", StepServing); st.State != "parked" || st.Code != "version-unstamped" { |
| + t.Fatalf("dev: serving %s %s", st.State, st.Code) |
| + } |
| +} |
diff --git a/provision/steps.go b/provision/steps.go| index 843878b..78240b7 100644 |
| --- a/provision/steps.go |
| +++ b/provision/steps.go |
| @@ -650,7 +650,8 @@ func (e *Engine) stepServing(ctx context.Context, p *pass, app App) error { |
| return park("version-unreachable") |
| } |
| version := strings.TrimSpace(string(body)) |
| - if version == "" { |
| + // "dev" is rastrillo's unstamped default: such a build names nothing. |
| + if version == "" || version == "dev" { |
| return park("version-unstamped") |
| } |
| // The two names need not agree: the box's is the release version |