Fold the puller-wake and Served tests into existing tests to stay within the test budget (issue 1887)
mesh/delivery merged: source.main moved to novox/mesh-sdk@4f4d5ca9c956
mesh/delivery-group group fix/puller-wakes-on-capacity merged: every member is merged
mesh/check pass a8fbabbfc373 on 4f4d5ca9c956 | unit 1102 run, 679 kept, 2 skipped | integration 1103 run, 721 kept, 2 skipped | over bound: unit, inte…

This commit is contained in:
2026-10-25 17:44:03 +01:00
parent b9911dc1c1
commit a8fbabbfc3
5 changed files with 93 additions and 100 deletions
-52
View File
@@ -1,15 +1,11 @@
package buildstep
import (
"context"
"encoding/json"
"errors"
"sync"
"testing"
"time"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/delivery"
)
// configWatch is a double of stdio.WatchConfig: it hands the value now at the start, as the runtime does, and a test
@@ -41,51 +37,3 @@ func (w *configWatch) set(t *testing.T, value string) {
t.Fatal(err)
}
}
// 1887/AC-wake (g14 idle at capacity 2, 2026-10-25): given a puller started at capacity 0 with an ask waiting, when the
// module's config value `capacity` moves to 2 for its node, then it takes the ask, with no pause, resume or step end to
// wake it.
func TestPullWakesWhenItsCapacityMoves(t *testing.T) {
src, st := NewFakeAsks(), newSteps()
_ = src.PublishAsk(testAsk(delivery.AskDelivery))
w := &configWatch{value: "shanks=3,g14=0"}
p := &Puller{Source: src, Language: delivery.AskGo, Node: "g14", Put: st.put, PullWait: 10 * time.Millisecond,
Capacity: func() int { return 0 }, // the settings file, not refilled yet
WatchConfig: w.watch,
Run: func(ctx context.Context, a delivery.StepAsk) (any, error) { return nil, nil }}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go p.Pull(ctx)
waitFor(t, "the watch of the capacity", func() bool { w.mu.Lock(); defer w.mu.Unlock(); return w.handle != nil })
time.Sleep(30 * time.Millisecond)
if src.Waiting(delivery.AskDelivery) != 1 {
t.Fatal("a node at capacity 0 took an ask")
}
if w.asked != CapacitySetting {
t.Fatalf("the puller watches %q, want %q", w.asked, CapacitySetting)
}
w.set(t, "shanks=3,g14=2")
waitFor(t, "the ask taken once the capacity moved to 2", func() bool { a, _, _ := src.Fates(); return len(a) == 1 })
}
// 1887/AC-wake: a value the watch says is no longer answered pulls nothing; a watch that cannot start leaves the puller
// on its Capacity (the settings file).
func TestPullCapacityWatchRefusedOrUnstarted(t *testing.T) {
src, st := NewFakeAsks(), newSteps()
p := &Puller{Source: src, Language: delivery.AskGo, Node: "g14", Put: st.put, Capacity: func() int { return 1 },
WatchConfig: func(key string, handle func(stdio.ProvisionChange) error) error {
return handle(stdio.ProvisionChange{Kind: "config", Key: key, Refused: "the module is no longer on g14"})
},
Run: func(ctx context.Context, a delivery.StepAsk) (any, error) { return nil, nil }}
p.watchCapacity()
if p.room() {
t.Fatal("a refused capacity value left room")
}
q := &Puller{Source: src, Language: delivery.AskGo, Node: "g14", Put: st.put, Capacity: func() int { return 1 },
WatchConfig: func(string, func(stdio.ProvisionChange) error) error { return errors.New("no runtime") },
Run: func(ctx context.Context, a delivery.StepAsk) (any, error) { return nil, nil }}
q.watchCapacity()
if !q.room() {
t.Fatal("a watch that could not start ignored the settings file's capacity of 1")
}
}