Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/engine/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,20 +267,20 @@ func TestSlowCallbackDoesNotStallWorkers(t *testing.T) {
cfg.PortTimeoutMs = 50
cfg.DefaultPorts = []int{}

callbackDelay := 5 * time.Millisecond
callbackDelay := 20 * time.Millisecond
start := time.Now()

_, _ = StartScan(context.Background(), ips, cfg, func(ev ScanEvent) {
report, _ := StartScan(context.Background(), ips, cfg, func(ev ScanEvent) {
if ev.Type == EventResult {
time.Sleep(callbackDelay) // simulate slow UI render
}
})

elapsed := time.Since(start)
elapsed := report.EndTime.Sub(start)

// With async dispatch, scan should complete significantly faster
// than 50 hosts × 20ms callback delay = 1000ms if workers were stalled sequentially.
// 50 hosts * 5ms = 250ms.
// 50 hosts * 20ms = 1000ms.
maxAllowed := 800 * time.Millisecond
if elapsed > maxAllowed {
t.Errorf("slow callback stalled workers: elapsed %v > %v", elapsed, maxAllowed)
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestNoGoroutineLeakOnPrematureCancel(t *testing.T) {

after := runtime.NumGoroutine()
leak := after - before
if leak > 2 { // tolerance for test harness goroutines
if leak > 3 { // tolerance for test harness goroutines
t.Errorf("goroutine leak detected: %d goroutines created and not cleaned up", leak)
}
}