Skip to content

Commit 300979e

Browse files
TMHSDigitalclaude
andcommitted
Test: give lab 3's unreliable case a burst a slow run keeps (#289)
Lab 3 refuses past 40 queries in a wall-clock second. The unreliable case scanned the lab's own 30 words, about 60 queries, which a loaded machine can spread over two seconds and so stay under the limit, making the verdict degraded instead. The case now scans lab 3 with 150 names, about 300 queries: more than a fifth are refused unless the run takes over 6 s, and the run stays under the reliability guard's 200 lookups, so it is not aborted. The paced case still uses the lab's words. Verified: the test passes 10 times in a row, and go test ./... -count=1 passed five times in a row beside a second copy of the suite (the background copy also passed). Fixes #289 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3e0ed5b commit 300979e

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎internal/cli/lab_test.go‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package cli
22

33
import (
4+
"cmp"
45
"encoding/json"
6+
"fmt"
57
"maps"
68
"os"
79
"path/filepath"
@@ -100,19 +102,32 @@ func TestE2ELabs(t *testing.T) {
100102
// TestE2ELabVerdicts checks the run-quality verdicts of the failure labs.
101103
func TestE2ELabVerdicts(t *testing.T) {
102104
t.Parallel()
105+
// Lab 3 refuses past 40 queries in a wall-clock second. Its own 30 words
106+
// send about 60 queries, which a loaded machine can spread over two
107+
// seconds and so stay under the limit (#289). 150 names send about 300,
108+
// more than a fifth of them refused unless the run takes over 6 s, and
109+
// stay under the reliability guard's 200 lookups, so it does not abort.
110+
var burst strings.Builder
111+
burst.WriteString("www\nmail\napi\ntest\n")
112+
for i := range 146 {
113+
fmt.Fprintf(&burst, "filler%d\n", i)
114+
}
115+
burstWords := writeFile(t, "burst.txt", burst.String())
103116
for _, c := range []struct {
104117
zone, verdict string
118+
words string // the -w file; empty for the labs' own words
105119
args []string
106120
}{
107121
// One attempt: a retry lands in a later one-second window and gets
108122
// answered, which on a slow machine turns the verdict into degraded.
109-
{zone: "lab3-rate-limit.zone", verdict: "unreliable", args: []string{"-timeout", "5000", "-attempts", "1"}},
123+
{zone: "lab3-rate-limit.zone", verdict: "unreliable", words: burstWords, args: []string{"-timeout", "5000", "-attempts", "1"}},
110124
{zone: "lab3-rate-limit.zone", verdict: "complete", args: append([]string{"-rate", "30"}, labTimingArgs...)},
111125
{zone: "lab5-failures.zone", verdict: "degraded", args: labSlowTimingArgs},
112126
} {
113127
t.Run(c.zone+strings.Join(c.args, ""), func(t *testing.T) {
114128
stats := filepath.Join(t.TempDir(), "run.json")
115-
args := append([]string{"-progress=false", "-w", "examples/labs/words.txt", "-stats", stats,
129+
words := cmp.Or(c.words, "examples/labs/words.txt")
130+
args := append([]string{"-progress=false", "-w", words, "-stats", stats,
116131
"-simulate-zone", filepath.Join("examples", "labs", c.zone)}, c.args...)
117132
if code, out := runCLI(t, "", append(args, "lab.example")...); code != 0 {
118133
t.Fatalf("exit %d\n%s", code, out)

0 commit comments

Comments
 (0)