@@ -110,6 +110,12 @@ func writeFile(t *testing.T, name, content string) string {
110110 return p
111111}
112112
113+ // localArgs puts labTimingArgs in front of args, for a run that expects real
114+ // answers from an in-process DNS server (#289).
115+ func localArgs (args ... string ) []string {
116+ return append (slices .Clone (labTimingArgs ), args ... )
117+ }
118+
113119const e2eWords = "www\n mail\n api\n dev\n shop\n blog\n "
114120
115121func TestE2ESimulateJSON (t * testing.T ) {
@@ -511,8 +517,8 @@ func TestE2EResolverPool(t *testing.T) {
511517 wl := writeFile (t , "wl.txt" , e2eWords )
512518 list := writeFile (t , "resolvers.txt" , "# pool\n " + r1 + "\n " + r2 + "\n " )
513519 stats := filepath .Join (t .TempDir (), "run.json" )
514- code , _ := runCLI (t , "" , "-dns-server" , trusted , "-r" , list , "-type" , "A" , "-progress=false" ,
515- "-stats" , stats , "-w" , wl , "example.com" )
520+ code , _ := runCLI (t , "" , append ( localArgs ( "-dns-server" , trusted , "-r" , list , "-type" , "A" , "-progress=false" ,
521+ "-stats" , stats , "-w" , wl ) , "example.com" ) ... )
516522 if code != 0 {
517523 t .Fatalf ("exit %d" , code )
518524 }
@@ -562,7 +568,7 @@ func TestE2EDiff(t *testing.T) {
562568 t .Parallel ()
563569 dir := t .TempDir ()
564570 zone := writeFile (t , "now.zone" , "www A 192.0.2.10\n mail A 192.0.2.20\n dev A 192.0.2.30\n extra A 192.0.2.40\n legacy TIMEOUT\n " )
565- lab := []string {"-simulate-zone" , zone , "-timeout" , "200" , "- progress=false" }
571+ lab := append ( []string {"-simulate-zone" , zone , "-progress=false" }, labSlowTimingArgs ... )
566572 run := func (words string , extra ... string ) (int , string ) {
567573 wl := writeFile (t , "wl.txt" , words )
568574 return runCLI (t , "" , append (append (append ([]string {}, lab ... ), extra ... ), "-w" , wl , "lab.example" )... )
@@ -671,8 +677,8 @@ func TestE2EPermute(t *testing.T) {
671677 })
672678 wl := writeFile (t , "wl.txt" , "api\n www\n " )
673679 stats := filepath .Join (t .TempDir (), "run.json" )
674- code , out := runCLI (t , "" , "-dns-server" , srv .Addr , "-type" , "A" , "-progress=false" , "-permute" ,
675- "-format" , "jsonl" , "-stats" , stats , "-w" , wl , "example.com" )
680+ code , out := runCLI (t , "" , append ( localArgs ( "-dns-server" , srv .Addr , "-type" , "A" , "-progress=false" , "-permute" ,
681+ "-format" , "jsonl" , "-stats" , stats , "-w" , wl ) , "example.com" ) ... )
676682 if code != 0 {
677683 t .Fatalf ("exit %d" , code )
678684 }
@@ -742,8 +748,8 @@ func TestE2EInconclusive(t *testing.T) {
742748 dir := t .TempDir ()
743749 incon , stats := filepath .Join (dir , "incon.txt" ), filepath .Join (dir , "run.json" )
744750 before := srv .QueriesFor ("down.example.com" , dnsmessage .TypeA )
745- args := [] string { "-dns-server" , srv .Addr , "-type" , "A" , "-progress=false" , "-no-abort" ,
746- "-inconclusive" , incon , "-stats" , stats , "-w" , wl , "example.com" }
751+ args := append ( localArgs ( "-dns-server" , srv .Addr , "-type" , "A" , "-progress=false" , "-no-abort" ,
752+ "-inconclusive" , incon , "-stats" , stats , "-w" , wl ) , "example.com" )
747753 if retry {
748754 args = append ([]string {"-retry-inconclusive" }, args ... )
749755 }
@@ -800,8 +806,8 @@ func TestE2EInternalAddresses(t *testing.T) {
800806 })
801807 wl := writeFile (t , "wl.txt" , "www\n intranet\n lo\n nope\n " )
802808 stats := filepath .Join (t .TempDir (), "run.json" )
803- code , out := runCLI (t , "" , "-dns-server" , srv .Addr , "-type" , "A" , "-progress=false" ,
804- "-format" , "jsonl" , "-stats" , stats , "-w" , wl , "example.com" )
809+ code , out := runCLI (t , "" , append ( localArgs ( "-dns-server" , srv .Addr , "-type" , "A" , "-progress=false" ,
810+ "-format" , "jsonl" , "-stats" , stats , "-w" , wl ) , "example.com" ) ... )
805811 if code != 0 {
806812 t .Fatalf ("exit %d" , code )
807813 }
@@ -833,7 +839,7 @@ func TestE2EInternalAddresses(t *testing.T) {
833839 t .Errorf ("report internal_addresses: %s (err %v), want 2" , raw , err )
834840 }
835841
836- _ , text := runCLI (t , "" , "-dns-server" , srv .Addr , "-type" , "A" , "-progress=false" , "-show-records" , "-w" , wl , "example.com" )
842+ _ , text := runCLI (t , "" , append ( localArgs ( "-dns-server" , srv .Addr , "-type" , "A" , "-progress=false" , "-show-records" , "-w" , wl ) , "example.com" ) ... )
837843 for _ , line := range strings .Split (strings .TrimSpace (text ), "\n " ) {
838844 hasMarker := strings .Contains (line , " INTERNAL=" )
839845 if strings .HasPrefix (line , "www." ) == hasMarker {
@@ -866,7 +872,7 @@ func TestE2ETakeoverProviders(t *testing.T) {
866872 })
867873 wl := writeFile (t , "wl.txt" , "docs\n www\n " )
868874 scan := func (extra ... string ) (int , string ) {
869- args := append ([] string { "-dns-server" , srv .Addr , "-type" , "A,CNAME" , "-progress=false" , "-show-records" , "-w" , wl } , extra ... )
875+ args := append (localArgs ( "-dns-server" , srv .Addr , "-type" , "A,CNAME" , "-progress=false" , "-show-records" , "-w" , wl ) , extra ... )
870876 return runCLI (t , "" , append (args , "example.com" )... )
871877 }
872878 if _ , out := scan (); strings .Contains (out , "TAKEOVER?" ) {
@@ -921,10 +927,13 @@ func TestE2EResume(t *testing.T) {
921927 }
922928
923929 // Interrupted run: -rate 20 makes 40 names take ~2s; interrupt once
924- // three results are out, whatever the runner's speed (#260).
930+ // three results are out, whatever the runner's speed (#260). One worker
931+ // takes its rate slot only after the previous lookup, so a stalled
932+ // process cannot run the rest in a burst before the interrupt is handled,
933+ // as many workers holding slots reserved up front could (#289).
925934 signals := make (chan os.Signal , 1 )
926935 code , first := runCLIUntilLines (t , 3 , func () { signals <- os .Interrupt }, runArgs {signals : signals ,
927- args : append (append ([]string {}, base ... ), "-rate" , "20" , "-state" , statePath , "-o" , outPath , "example.com" )})
936+ args : append (append ([]string {}, base ... ), "-t" , "1" , "- rate" , "20" , "-state" , statePath , "-o" , outPath , "example.com" )})
928937 if code != 130 {
929938 t .Fatalf ("interrupted run: exit %d, want 130" , code )
930939 }
0 commit comments