Skip to content

Commit

Permalink
Disable the execution mismatch check, but keep the warnings
Browse files Browse the repository at this point in the history
Full description of the issue and rationale for the change can be found here: #1007 (comment)
  • Loading branch information
na-- committed Jul 9, 2019
1 parent bdd417e commit 5af8e03
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 47 deletions.
29 changes: 1 addition & 28 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"fmt"
"os"
"path/filepath"
"reflect"
"strings"

"errors"
Expand Down Expand Up @@ -217,21 +216,6 @@ func getSharedIterationsExecution(iterations null.Int, duration types.NullDurati
return scheduler.ConfigMap{lib.DefaultSchedulerName: ds}
}

func checkExecutionMismatch(observedExecution, derivedExecution scheduler.ConfigMap, shortcutField string) error {
if observedExecution == nil {
return nil
}

// Work around the v0.24.0 archive metadata.js options that wrongly contain execution
if !reflect.DeepEqual(observedExecution, derivedExecution) {
errMsg := fmt.Sprintf("specifying both `%s` and `execution` is not supported", shortcutField)
return executionConflictConfigError(errMsg)
}

log.Warnf("ignoring the specified `execution` options because they match the ones derived from `%s`", shortcutField)
return nil
}

// This checks for conflicting options and turns any shortcut options (i.e. duration, iterations,
// stages) into the proper scheduler configuration
func deriveExecutionConfig(conf Config) (Config, error) {
Expand All @@ -244,9 +228,6 @@ func deriveExecutionConfig(conf Config) (Config, error) {
}

result.Execution = getSharedIterationsExecution(conf.Iterations, conf.Duration, conf.VUs)
if err := checkExecutionMismatch(conf.Execution, result.Execution, "iterations"); err != nil {
return conf, err
}
// TODO: maybe add a new flag that will be used as a shortcut to per-VU iterations?

case conf.Duration.Valid:
Expand All @@ -255,23 +236,15 @@ func deriveExecutionConfig(conf Config) (Config, error) {
log.Warnf("Specifying both duration and stages is deprecated and won't be supported in the future k6 versions")
}

derivedExecConfig := getConstantLoopingVUsExecution(conf.Duration, conf.VUs)
if err := checkExecutionMismatch(conf.Execution, derivedExecConfig, "duration"); err != nil {
return conf, err
}

if conf.Duration.Duration <= 0 {
//TODO: make this an executionConflictConfigError in the next version
log.Warnf("Specifying infinite duration in this way is deprecated and won't be supported in the future k6 versions")
} else {
result.Execution = derivedExecConfig
result.Execution = getConstantLoopingVUsExecution(conf.Duration, conf.VUs)
}

case len(conf.Stages) > 0: // stages isn't nil (not set) and isn't explicitly set to empty
result.Execution = getVariableLoopingVUsExecution(conf.Stages, conf.VUs)
if err := checkExecutionMismatch(conf.Execution, result.Execution, "stages"); err != nil {
return conf, err
}

default:
if conf.Execution != nil { // If someone set this, regardless if its empty
Expand Down
20 changes: 1 addition & 19 deletions cmd/config_consolidation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,24 +369,6 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
},
exp{}, verifySharedIters(I(12), I(25)),
},
{
opts{
fs: defaultConfig(`
{
"execution": {
"default": {
"type": "constant-looping-vus",
"vus": 10,
"duration": "60s"
}
},
"vus": 20,
"duration": "60s"
}`,
),
},
exp{derivationError: true}, nil,
},
{
opts{
fs: defaultConfig(`
Expand All @@ -403,7 +385,7 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
}`,
),
},
exp{logWarning: true}, verifyConstLoopingVUs(I(10), 60*time.Second),
exp{}, verifyConstLoopingVUs(I(10), 60*time.Second),
},
// Just in case, verify that no options will result in the same 1 vu 1 iter config
{opts{}, exp{}, verifyOneIterPerOneVU},
Expand Down

0 comments on commit 5af8e03

Please sign in to comment.