diff --git a/internal/site/redfishwork/kinds_test.go b/internal/site/redfishwork/kinds_test.go index bc51f28a..7070dbad 100644 --- a/internal/site/redfishwork/kinds_test.go +++ b/internal/site/redfishwork/kinds_test.go @@ -27,6 +27,7 @@ import ( "go.datum.net/fleet/internal/bmcdiscovery" "go.datum.net/fleet/internal/redfish" "go.datum.net/fleet/internal/site" + "go.datum.net/fleet/internal/site/burnin" ) const ( @@ -178,6 +179,29 @@ func (l *lab) ServeHTTP(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(doc) } +// awaitSighting waits until the worker has stored a sighting of the console +// without the receipt at or after moved. A worker stores its first sighting +// at once and then at least every burnin.PersistEvery of store time, so a +// shorter move waits only for the first one. A move of exactly PersistEvery +// is stored because real time also passes between the polls. +func (l *lab) awaitSighting(moved time.Time) { + short := l.burnTime < burnin.PersistEvery + for deadline := time.Now().Add(10 * time.Second); ; time.Sleep(5 * time.Millisecond) { + var record burnin.Record + if _, err := l.store.GetRecord(device, burnin.Records, l.operation, &record); err != nil { + l.t.Error(err) + return + } + if short && !record.AbsentAt.IsZero() || !record.AbsentAt.Before(moved) { + return + } + if time.Now().After(deadline) { + l.t.Error("the worker never polled the console on the moved clock") + return + } + } +} + // boot runs the armed boot, as the server and the boot server would. func (l *lab) boot(target string) { time.Sleep(30 * time.Millisecond) @@ -199,10 +223,12 @@ func (l *lab) boot(target string) { l.mu.Lock() result := l.burnIn l.skew += l.burnTime + moved := time.Now().Add(l.skew) l.mu.Unlock() - // Let the worker poll the console once more on the moved clock - // before the receipt appears, as it would while a real burn-in ran. - time.Sleep(50 * time.Millisecond) + // Let the worker see the console without the receipt on the moved + // clock before the receipt appears, as it would while a real burn-in + // ran. A sleep alone races the worker's poll on a loaded machine. + l.awaitSighting(moved) line = fmt.Sprintf("FLEET-BURNIN:%s:%s", boot.Receipt, result) for range l.receipts - 1 { line += fmt.Sprintf("\nFLEET-BURNIN:%s:%s", boot.Receipt, result)