Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion internal/infra/vegeta/engine/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func RunSingle(ctx context.Context, plan *domain.TestPlan, config *domain.TestCo
if res.Error != "" || res.Code >= 400 || res.Code == 0 {
intervalErrors.Add(1)
if intervalErrors.Load() == 1 {
log.Printf("[DEBUG] First error encountered: code=%d, err=%s, url=%s", res.Code, res.Error, res.URL)
log.Printf("[DEBUG] Error sample: code=%d, err=%s, url=%s", res.Code, res.Error, res.URL)
}
}

Expand Down
10 changes: 7 additions & 3 deletions internal/infra/vegeta/engine/stateful.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ func (a *StatefulAttacker) Attack(ctx context.Context, plan *domain.TestPlan, gl

go func() {
defer close(results)
// httpCtx: preserved before the duration timeout is applied.
// HTTP requests use this so in-flight requests are not forcibly
// cancelled when the test duration expires; they complete naturally.
httpCtx := ctx
var cancel context.CancelFunc
if a.dur > 0 {
ctx, cancel = context.WithTimeout(ctx, a.dur)
Expand Down Expand Up @@ -1399,7 +1403,7 @@ func (a *StatefulAttacker) Attack(ctx context.Context, plan *domain.TestPlan, gl
if bodyStr != "" {
bodyReader = strings.NewReader(bodyStr)
}
reqCtx := ctx
reqCtx := httpCtx // use httpCtx: not bound to duration timeout
var cancel context.CancelFunc
for _, p := range sampler.PreProcessors {
if st, ok := p.(*domain.SampleTimeout); ok {
Expand Down Expand Up @@ -1427,7 +1431,7 @@ func (a *StatefulAttacker) Attack(ctx context.Context, plan *domain.TestPlan, gl
}
select {
case results <- failRes:
case <-ctx.Done():
case <-httpCtx.Done():
return
}
continue
Expand Down Expand Up @@ -1608,7 +1612,7 @@ func (a *StatefulAttacker) Attack(ctx context.Context, plan *domain.TestPlan, gl

select {
case results <- res:
case <-ctx.Done():
case <-httpCtx.Done(): // only drop result on explicit stop, not duration expiry
return
}

Expand Down
Loading