oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package thintest
2
3import (
4 "testing"
5 "time"
6
7 "amadan.net/oficina/equipo/internal/wire"
8)
9
10// Whole-branch fix 1, #5: an outbound pack declared past the bound (an
11// older worker, which does not measure it first) fails the step
12// durably, workspace_too_large with Needs you and Retry, whether the
13// worker's done came first or not; nothing is published.
14func TestOutboundPackOversizeIsWorkspaceTooLarge(t *testing.T) {
15 for _, doneFirst := range []bool{true, false} {
16 name := "running"
17 if doneFirst {
18 name = "done first"
19 }
20 t.Run(name, func(t *testing.T) {
21 r := newMacRig(t)
22 w := r.newMacEngineer("Mac A", wire.EngineeringReady)
23 base, cand := sha(1), sha(0xb6)
24 task, d := r.macDispatch(w, "iOS huge commit", base)
25 if !w.lease(d.StepID, d.Attempt) {
26 t.Fatal("start refused")
27 }
28 w.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepRunning, CandidateSHA: cand, Phase: wire.OutcomeCommitted, OutcomePhase: wire.OutcomeCommitted, Findings: []wire.Finding{}})
29 _, body := w.expect(wire.FrameSendPack)
30 h := body.(*wire.SendPackCommand).Transfer
31 if doneFirst {
32 w.send(wire.FrameStep, workerDone(d, cand, wire.OutcomeCommitted))
33 }
34 big := chunk(h, []byte("PACK huge"))
35 big.Total = wire.MaxTransferChunks + 1
36 w.send(wire.FrameBlob, big)
37 if !doneFirst {
38 _, body = w.expect(wire.FrameCancelStep)
39 if c := body.(*wire.CancelStepCommand); c.StepID != d.StepID || c.Attempt != d.Attempt {
40 t.Fatalf("cancel %+v", c)
41 }
42 w.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepCancelled, Reason: "withdrawn", Termination: true, TerminationKind: wire.TerminationProcessGroup, Findings: []wire.Finding{}})
43 }
44 s := r.engineeringStep(task)
45 if s.State != wire.StepFailed || s.Reason != wire.ReasonWorkspaceTooLarge || !s.Terminated || s.Pushed || r.needsYou(task) != wire.NeedsRetry {
46 t.Fatalf("oversize %+v needs %q", s, r.needsYou(task))
47 }
48 r.primary.none(wire.FramePublish, 50*time.Millisecond)
49 if n := r.relayed(r.primary); n != 0 {
50 t.Fatalf("%d chunks reached the primary", n)
51 }
52 // A restart keeps it.
53 r.restartMac(w)
54 if s := r.engineeringStep(task); s.State != wire.StepFailed || s.Reason != wire.ReasonWorkspaceTooLarge || r.needsYou(task) != wire.NeedsRetry {
55 t.Fatalf("after a restart %+v needs %q", s, r.needsYou(task))
56 }
57 })
58 }
59}
60