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
27 changes: 0 additions & 27 deletions lib/executor/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ import (
"go.k6.io/k6/lib/types"
)

const (
// maxConcurrentVUs is an arbitrary limit for sanity checks.
// It prevents running an exaggeratedly large number of concurrent VUs which may lead to an out-of-memory.
maxConcurrentVUs int = 100_000_000
)

func sumStagesDuration(stages []Stage) (result time.Duration) {
for _, s := range stages {
result += s.Duration.TimeDuration()
Expand All @@ -39,27 +33,6 @@ func getStagesUnscaledMaxTarget(unscaledStartValue int64, stages []Stage) int64
return result
}

// validateTargetShifts validates the VU Target shifts.
// It will append an error for any VU target that is larger than the maximum value allowed.
// Each Stage needs a Target value. The stages array can be empty. The Targes could be negative.
func validateTargetShifts(startVUs int64, stages []Stage) []error {
var errors []error

if startVUs > int64(maxConcurrentVUs) {
errors = append(errors, fmt.Errorf(
"the startVUs exceed max limit of %d", maxConcurrentVUs))
}

for i := 0; i < len(stages); i++ {
if stages[i].Target.Int64 > int64(maxConcurrentVUs) {
errors = append(errors, fmt.Errorf(
"target for stage %d exceeds max limit of %d", i+1, maxConcurrentVUs))
}
}

return errors
}

// A helper function to avoid code duplication
func validateStages(stages []Stage) []error {
var errors []error
Expand Down
32 changes: 31 additions & 1 deletion lib/executor/ramping_vus.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ import (
"go.k6.io/k6/metrics"
)

const rampingVUsType = "ramping-vus"
const (
rampingVUsType = "ramping-vus"

// maxConcurrentVUs is an arbitrary limit for sanity checks.
// It prevents running an exaggeratedly large number of concurrent VUs which may lead to an out-of-memory.
maxConcurrentVUs int = 100_000_000
)

func init() {
lib.RegisterExecutorConfigType(
Expand Down Expand Up @@ -710,3 +716,27 @@ func waiter(ctx context.Context, start time.Time) func(offset time.Duration) boo
return false
}
}

// validateTargetShifts validates the VU Target shifts.
// It will append an error for any VU target that is larger than the maximum value allowed.
// Each Stage needs a Target value. The stages array can be empty. The Targes could be negative.
//
// TODO: after https://github.com/grafana/k6/issues/1499 this validation
// function could be useless.
func validateTargetShifts(startVUs int64, stages []Stage) []error {
var errors []error

if startVUs > int64(maxConcurrentVUs) {
errors = append(errors, fmt.Errorf(
"the startVUs exceed max limit of %d", maxConcurrentVUs))
}

for i := 0; i < len(stages); i++ {
if stages[i].Target.Int64 > int64(maxConcurrentVUs) {
errors = append(errors, fmt.Errorf(
"target for stage %d exceeds max limit of %d", i+1, maxConcurrentVUs))
}
}

return errors
}
Loading