Pipelines page: each step's waited and ran, not the asked time as its start (design 47 H2, H-A-516) #351
@@ -69,13 +69,15 @@ func changedWithin(ctx context.Context, p *Pipelines, what string, since uint64)
|
||||
// and links each delivery to its pipeline by its source revision.
|
||||
func TestThePipelinesPage(t *testing.T) {
|
||||
started, ended := t0, t0.Add(3*60e9)
|
||||
taken := t0.Add(160e9) // a build node took the step 2m40s after its ask, and it ran 20s (design 47 H2 H-A-516)
|
||||
runner := &fakeRunner{rows: map[string][]seat.PipelineRow{}, shows: map[string]seat.ShowAnswer{
|
||||
"main.12": {Pipeline: seat.Pipeline{Pipeline: "main.12", Branch: "main", Source: 9, Revision: 12, Outcome: seat.PipelineOutcomeFailed,
|
||||
Started: &started, Ended: &ended, Movers: []seat.Mover{{Module: "alpha", Fingerprint: "src2:aa", Version: "0.1.4"}, {Module: "beta", Fingerprint: "src2:bb"}}},
|
||||
Movers: []seat.MoverRow{{Module: "alpha", Outcome: seat.MoverRowOutcomePassed},
|
||||
{Module: "beta", Outcome: seat.MoverRowOutcomeFailed, Failed: &seat.FailedStep{Step: "unit", Artifact: "beta:program", Outcome: "could not run", Why: "no build node"}}}},
|
||||
"main.12/beta": {Pipeline: seat.Pipeline{Pipeline: "main.12", Branch: "main", Source: 9, Revision: 12, Outcome: seat.PipelineOutcomeFailed,
|
||||
Steps: []seat.StepResult{{Module: "beta", Step: "unit", Artifact: "beta:program", Seat: "node-build-go", Node: "n1", Outcome: "could not run", Started: &started, Ended: &ended, Why: "no build node"}}}},
|
||||
Steps: []seat.StepResult{{Module: "beta", Step: "unit", Artifact: "beta:program", Seat: "node-build-go", Node: "n1", Outcome: "could not run", AskedAt: &started, Started: &started, TakenAt: &taken, Ended: &ended, Why: "no build node"},
|
||||
{Module: "beta", Step: "lint", Artifact: "beta:program", Seat: "node-build-go", Outcome: "could not run", AskedAt: &started, Ended: &ended}}}},
|
||||
}}
|
||||
runner.setRows("main", seat.PipelineRow{Pipeline: "main.12", Source: 9, Revision: 12, Started: &started, Outcome: seat.PipelineOutcomeFailed, MoverCount: 2,
|
||||
Steps: map[string]int64{"passed": 5, "failed": 1, "could not run": 1, "waiting for a build node": 2}})
|
||||
@@ -118,8 +120,25 @@ func TestThePipelinesPage(t *testing.T) {
|
||||
{"a pipeline's page is its mover rows, each linking its steps", func() string { return web("/pipelines/show?pipeline=main.12") }, []string{
|
||||
`<a href="/pipelines/show?mover=alpha&pipeline=main.12">alpha</a></td><td>src2:aa</td><td>0.1.4</td><td>passed</td>`,
|
||||
"<td>unit beta:program: could not run: no build node</td>", `changes?pipeline=main.12\u0026since=`}},
|
||||
{"a mover's page is its steps", func() string { return web("/pipelines/show?pipeline=main.12&mover=beta") }, []string{
|
||||
"<td>unit beta:program</td><td>node-build-go</td><td>n1</td><td>could not run</td>", "<td>no build node</td>"}},
|
||||
{"a mover's page is its steps, each asked, taken and ended, how long it waited and how long it ran", func() string {
|
||||
return web("/pipelines/show?pipeline=main.12&mover=beta")
|
||||
}, []string{"<th>ASKED</th><th>TAKEN</th><th>ENDED</th><th>WAITED</th><th>RAN</th>",
|
||||
"<td>unit beta:program</td><td>node-build-go</td><td>n1</td><td>could not run</td><td>" + since(started) + "</td><td>" + since(taken) + "</td><td>" + since(ended) + "</td><td>2m40s</td><td>20s</td><td>no build node</td>",
|
||||
"<td>lint beta:program</td><td>node-build-go</td><td></td><td>could not run</td><td>" + since(started) + "</td><td></td><td>" + since(ended) + "</td><td>3m0s</td><td></td>"}},
|
||||
{"the terminal view's mover splits each step's waiting from its running", func() string {
|
||||
a, err := p.Show("main.12", "beta", "")
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return text(func(b *bytes.Buffer) { PipelineTable(b, a, "beta") })
|
||||
}, []string{"STEPS OF beta", "OUTCOME ASKED TAKEN ENDED WAITED RAN WHY", "could not run " + since(started) + " " + since(taken) + " " + since(ended) + " 2m40s 20s no build node"}},
|
||||
{"a step still waiting counts its wait to now, one running its run", func() string {
|
||||
now := t0.Add(400e9)
|
||||
w1, r1 := waitedRan(seat.StepResult{AskedAt: &started}, now)
|
||||
w2, r2 := waitedRan(seat.StepResult{AskedAt: &started, TakenAt: &taken}, now)
|
||||
w3, r3 := waitedRan(seat.StepResult{Ended: &ended}, now)
|
||||
return fmt.Sprintf("waiting %s/%s; running %s/%s; never asked %q/%q", w1, r1, w2, r2, w3, r3)
|
||||
}, []string{`waiting 6m40s/; running 2m40s/4m0s; never asked ""/""`}},
|
||||
{"the terminal view's pipeline names each mover's fingerprint, version and failed step", func() string {
|
||||
a, err := p.Show("main.12", "", "")
|
||||
if err != nil {
|
||||
@@ -229,7 +248,7 @@ func TestThePipelinesPage(t *testing.T) {
|
||||
if err := AskPipelines(path, "", 0, "main.12", "beta", "", false, func(_ PipelinesPage, a *seat.ShowAnswer) bool { show = a; return true }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(show.Pipeline.Steps) != 1 || show.Pipeline.Steps[0].Node != "n1" {
|
||||
if len(show.Pipeline.Steps) != 2 || show.Pipeline.Steps[0].Node != "n1" {
|
||||
t.Fatalf("the mover's steps on the socket = %+v", show)
|
||||
}
|
||||
if err := AskPipelines(path, "", 0, "main.99", "", "", false, func(PipelinesPage, *seat.ShowAnswer) bool { return true }); err == nil || !strings.Contains(err.Error(), "no pipeline main.99") {
|
||||
|
||||
@@ -25,9 +25,34 @@ var PipelinesHead = append([]string{"PIPELINE", "REVISION", "SOURCE", "STARTED",
|
||||
// MoversHead is the head of one pipeline's mover rows, StepsHead of one mover's steps (design 47 H2 H-A-467 (2)).
|
||||
var (
|
||||
MoversHead = []string{"MOVER", "FINGERPRINT", "VERSION", "OUTCOME", "FAILED STEP"}
|
||||
StepsHead = []string{"STEP", "SEAT", "NODE", "OUTCOME", "STARTED", "ENDED", "WHY"}
|
||||
StepsHead = []string{"STEP", "SEAT", "NODE", "OUTCOME", "ASKED", "TAKEN", "ENDED", "WAITED", "RAN", "WHY"}
|
||||
)
|
||||
|
||||
// waitedRan is how long a step waited, from its ask's asked-at to the time a build node took it, and how long it ran, from
|
||||
// that taking to its end (design 47 H2 H-A-516); a step not yet taken or not yet ended counts to now, and a step that ended
|
||||
// untaken only waited.
|
||||
func waitedRan(s seat.StepResult, now time.Time) (waited, ran string) {
|
||||
until := now
|
||||
if s.Ended != nil {
|
||||
until = *s.Ended
|
||||
}
|
||||
took := until
|
||||
if s.TakenAt != nil {
|
||||
took = *s.TakenAt
|
||||
ran = "0s"
|
||||
if until.After(took) {
|
||||
ran = until.Sub(took).Round(time.Second).String()
|
||||
}
|
||||
}
|
||||
if s.AskedAt != nil {
|
||||
waited = "0s"
|
||||
if took.After(*s.AskedAt) {
|
||||
waited = took.Sub(*s.AskedAt).Round(time.Second).String()
|
||||
}
|
||||
}
|
||||
return waited, ran
|
||||
}
|
||||
|
||||
func upper(in []string) []string {
|
||||
out := make([]string, len(in))
|
||||
for i, s := range in {
|
||||
@@ -89,15 +114,18 @@ func MoverRowsText(a seat.ShowAnswer) [][]string {
|
||||
return out
|
||||
}
|
||||
|
||||
// StepsText is one mover's steps as show with the mover answers them.
|
||||
// StepsText is one mover's steps as show with the mover answers them: per step the time it was asked, the time a build
|
||||
// node took it and the time it ended, with how long it waited and how long it ran (design 47 H2 H-A-516).
|
||||
func StepsText(a seat.ShowAnswer) [][]string {
|
||||
now := time.Now()
|
||||
var out [][]string
|
||||
for _, s := range a.Pipeline.Steps {
|
||||
step := s.Step
|
||||
if s.Artifact != "" {
|
||||
step += " " + s.Artifact
|
||||
}
|
||||
out = append(out, []string{step, s.Seat, s.Node, s.Outcome, timeOf(s.Started), timeOf(s.Ended), s.Why})
|
||||
waited, ran := waitedRan(s, now)
|
||||
out = append(out, []string{step, s.Seat, s.Node, s.Outcome, timeOf(s.AskedAt), timeOf(s.TakenAt), timeOf(s.Ended), waited, ran, s.Why})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user