mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-06 12:33:16 -05:00
test(studio): widen the margin of the turn reap spec
The spec "a turn that stops beating is reaped, one that keeps beating is not" beat the live turn once and then made several store calls before the second reap with a 50 ms threshold. Under -race on a loaded runner those calls took longer than 50 ms, so the live turn counted as stale and the second reap found it. Use a 300 ms threshold, sleep twice that for the stale turn, and beat the live turn again right before the second reap. The assertions keep their meaning and the store is unchanged. Assisted-by: Claude:claude-sonnet-5-5
This commit is contained in:
1 file changed
+7
-3
@@ -600,15 +600,18 @@ func Run(newStore New) {
|
||||
})
|
||||
|
||||
It("a turn that stops beating is reaped, one that keeps beating is not", func() {
|
||||
// The margin is wide: on a loaded runner under -race a few store calls
|
||||
// can take longer than a tight threshold.
|
||||
const stale = 300 * time.Millisecond
|
||||
s := newStore()
|
||||
chat(s, "stale", "alice")
|
||||
chat(s, "alive", "alice")
|
||||
Expect(s.ClaimTurn(ctx(), "alice", "stale", "r-stale")).To(Succeed())
|
||||
Expect(s.ClaimTurn(ctx(), "alice", "alive", "r-alive")).To(Succeed())
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(2 * stale)
|
||||
Expect(s.TouchTurn(ctx(), "alice", "alive", "r-alive")).To(Succeed())
|
||||
|
||||
got, err := s.ReapTurns(ctx(), 50*time.Millisecond)
|
||||
got, err := s.ReapTurns(ctx(), stale)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(got).To(HaveLen(1), "reaped = %+v, want only the chat that stopped beating", got)
|
||||
Expect(got[0].ChatID).To(Equal("stale"))
|
||||
@@ -622,7 +625,8 @@ func Run(newStore New) {
|
||||
// The run that was reaped can no longer beat or release, and the chat is free.
|
||||
Expect(s.TouchTurn(ctx(), "alice", "stale", "r-stale")).To(MatchError(store.ErrNotClaimed), "TouchTurn on a reaped run")
|
||||
Expect(s.ClaimTurn(ctx(), "alice", "stale", "r-next")).To(Succeed(), "claim after reap")
|
||||
again, _ := s.ReapTurns(ctx(), 50*time.Millisecond)
|
||||
Expect(s.TouchTurn(ctx(), "alice", "alive", "r-alive")).To(Succeed())
|
||||
again, _ := s.ReapTurns(ctx(), stale)
|
||||
Expect(again).To(BeEmpty(), "a second reap found %+v", again)
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user