Merge branch 'fix/47-G-shared-runs-runner' into fix/47-G-shared-runs
This commit is contained in:
+43
@@ -82,6 +82,12 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
||||
if _, err := events.CreateOrUpdateConsumer(ctx, jetstream.ConsumerConfig{Durable: "n1_" + module, AckPolicy: jetstream.AckExplicitPolicy}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// A durable consumer of the runner's step-ended in EVENTS, so an end said again is read as the stream keeps it (A-470q).
|
||||
stepEnds, err := events.CreateOrUpdateConsumer(ctx, jetstream.ConsumerConfig{Durable: "t109-step-ended",
|
||||
FilterSubject: "mesh.seat." + seat.Seat + ".event." + seat.EventStepEnded + ".>", AckPolicy: jetstream.AckExplicitPolicy})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: "ASKS", Subjects: []string{"mesh.seat.*.accept.>"}, Retention: jetstream.WorkQueuePolicy}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -329,6 +335,20 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
||||
if s := step(read(p3), "app:tools", "unit"); s.Outcome != seat.StepResultOutcomeWaitingForABuildNode || s.Ask != "" || s.Shared[0].Ask != unit.Ask {
|
||||
t.Fatalf("the tools' unit step = %+v; want it waiting for a build node, reading the program's run", s)
|
||||
}
|
||||
// Its wait has no bound (§647 as A-466y amends it): the state bounds holds no key for a queued ask, only drops' keys.
|
||||
boundsKV, err := js.KeyValue(ctx, module+"_bounds")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if ks, err := boundsKV.Keys(ctx); err != nil && err != jetstream.ErrNoKeysFound {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
for _, k := range ks {
|
||||
if !strings.HasPrefix(k, pipeline.DropBoundPrefix) {
|
||||
t.Errorf("the state bounds holds %s after the asks were put; want no bound of a queued ask", k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A runner restarted during a run takes it up again by its ask (§725): the run's end, heard after the restart, ends both.
|
||||
taken(unit.Ask)
|
||||
@@ -408,6 +428,29 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
||||
if s := step(p, "app:tools", "unit"); s.Outcome != seat.StepResultOutcomePassed || !s.Rerun {
|
||||
t.Errorf("the tools' unit step = %+v; want moved to passed, marked a rerun", s)
|
||||
}
|
||||
// The tools' unit step's ends, read from the stream: its first, failed, and its end said again by the move, passed.
|
||||
var toolEnds []string
|
||||
for {
|
||||
batch, err := stepEnds.FetchNoWait(100)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
n := 0
|
||||
for m := range batch.Messages() {
|
||||
n++
|
||||
var e seat.StepEvent
|
||||
if json.Unmarshal(m.Data(), &e) == nil && e.Pipeline == p3 && e.Result.Artifact == "app:tools" && e.Result.Step == "unit" {
|
||||
toolEnds = append(toolEnds, e.Result.Outcome)
|
||||
}
|
||||
_ = m.Ack()
|
||||
}
|
||||
if n == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(toolEnds) < 2 || toolEnds[0] != seat.StepResultOutcomeFailed || toolEnds[len(toolEnds)-1] != seat.StepResultOutcomePassed {
|
||||
t.Errorf("the tools' unit step-ended in EVENTS = %v; want its first end failed and the end said again passed, both kept", toolEnds)
|
||||
}
|
||||
if s := step(p, "app:program", "integration"); s.Outcome != seat.StepResultOutcomeAccepted {
|
||||
t.Errorf("the accepted step = %+v; want it accepted still", s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user