B4: the bed watches the reserved bucket for the release's delete, never polls
Review r1 finding 3: the wait for the reservation's delete slept between reads; it now watches the module's keys and ends on their delete. Builds: design 47 H2 H-A-551
This commit is contained in:
@@ -765,20 +765,27 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for deadline := time.Now().Add(20 * time.Second); ; time.Sleep(50 * time.Millisecond) {
|
||||
keys, err := reservations.ListKeysFiltered(b.ctx, versions.NameFilter("disk-load"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
held := 0
|
||||
for range keys.Keys() {
|
||||
held++
|
||||
}
|
||||
if held == 0 {
|
||||
break
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("disk-load holds %d reservations 20 s after its version-released of %s, want none", held, reserved.Version)
|
||||
// Watched, never polled: the watch gives the keys standing, then a nil, then each change (the delete of the release).
|
||||
w, err := reservations.WatchFiltered(b.ctx, []string{versions.NameFilter("disk-load")})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = w.Stop() }()
|
||||
held, caughtUp := map[string]bool{}, false
|
||||
timeout := time.After(20 * time.Second)
|
||||
for !caughtUp || len(held) > 0 {
|
||||
select {
|
||||
case e := <-w.Updates():
|
||||
switch {
|
||||
case e == nil:
|
||||
caughtUp = true
|
||||
case e.Operation() == jetstream.KeyValuePut:
|
||||
held[e.Key()] = true
|
||||
default:
|
||||
delete(held, e.Key())
|
||||
}
|
||||
case <-timeout:
|
||||
t.Fatalf("disk-load holds %v 20 s after its version-released of %s, want none", held, reserved.Version)
|
||||
}
|
||||
}
|
||||
fifth := "src2:" + strings.Repeat("7", 64)
|
||||
|
||||
Reference in New Issue
Block a user