Skip to content

Commit

Permalink
Rename the user-facing config options
Browse files Browse the repository at this point in the history
This handles the executor configuration parts of #1425, without actually changing the Go type names or structure yet.
  • Loading branch information
na-- committed Jun 9, 2020
1 parent 0839be8 commit 08070ca
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 118 deletions.
6 changes: 3 additions & 3 deletions cmd/config_consolidation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
},
}}, exp{derivationError: true}, nil,
},
{opts{fs: defaultConfig(`{"execution": {}}`)}, exp{logWarning: true}, verifyOneIterPerOneVU},
{opts{fs: defaultConfig(`{"scenarios": {}}`)}, exp{logWarning: true}, verifyOneIterPerOneVU},
// Test if environment variable shortcuts are working as expected
{opts{env: []string{"K6_VUS=5", "K6_ITERATIONS=15"}}, exp{}, verifySharedIters(I(5), I(15))},
{opts{env: []string{"K6_VUS=10", "K6_DURATION=20s"}}, exp{}, verifyConstLoopingVUs(I(10), 20*time.Second)},
Expand Down Expand Up @@ -316,8 +316,8 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase {
{
opts{
fs: defaultConfig(`{
"execution": { "someKey": {
"type": "constant-looping-vus", "vus": 10, "duration": "60s", "gracefulStop": "10s",
"scenarios": { "someKey": {
"executor": "constant-vus", "vus": 10, "duration": "60s", "gracefulStop": "10s",
"startTime": "70s", "env": {"test": "mest"}, "exec": "someFunc"
}}}`),
env: []string{"K6_ITERATIONS=25"},
Expand Down
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ a commandline interface for interacting with it.`,
executorConfigs := execScheduler.GetExecutorConfigs()
maxDuration, _ := lib.GetEndOffset(plan)

fprintf(stdout, " execution: %s\n", ui.ValueColor.Sprintf(
fprintf(stdout, " scenarios: %s\n", ui.ValueColor.Sprintf(
"(%.2f%%) %d executors, %d max VUs, %s max duration (incl. graceful stop):",
conf.ExecutionSegment.FloatLength()*100, len(executorConfigs),
lib.GetMaxPossibleVUs(plan), maxDuration),
Expand Down
16 changes: 8 additions & 8 deletions core/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,9 @@ func TestEmittedMetricsWhenScalingDown(t *testing.T) {
export let options = {
systemTags: ["iter", "vu", "url"],
execution: {
scenarios: {
we_need_hard_stop_and_ramp_down: {
type: "variable-looping-vus",
executor: "ramping-vus",
// Start with 2 VUs for 4 seconds and then quickly scale down to 1 for the next 4s and then quit
startVUs: 2,
stages: [
Expand Down Expand Up @@ -818,9 +818,9 @@ func TestMetricsEmission(t *testing.T) {
let testCounter = new Counter("testcounter");
export let options = {
execution: {
scenarios: {
we_need_hard_stop: {
type: "constant-looping-vus",
executor: "constant-vus",
vus: 4,
duration: "1s",
gracefulStop: "0s",
Expand Down Expand Up @@ -871,9 +871,9 @@ func TestMinIterationDurationInSetupTeardownStage(t *testing.T) {
export let options = {
minIterationDuration: "2s",
execution: {
scenarios: {
we_need_hard_stop: {
type: "constant-looping-vus",
executor: "constant-vus",
vus: 2,
duration: "1.9s",
gracefulStop: "0s",
Expand All @@ -889,9 +889,9 @@ func TestMinIterationDurationInSetupTeardownStage(t *testing.T) {
export let options = {
minIterationDuration: "2s",
execution: {
scenarios: {
we_need_hard_stop: {
type: "constant-looping-vus",
executor: "constant-vus",
vus: 2,
duration: "1.9s",
gracefulStop: "0s",
Expand Down
40 changes: 20 additions & 20 deletions core/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ func TestExecutionSchedulerRunNonDefault(t *testing.T) {
{"defaultOK", `export default function () {}`, ""},
{"nonDefaultOK", `
export let options = {
execution: {
scenarios: {
per_vu_iters: {
type: "per-vu-iterations",
executor: "per-vu-iterations",
vus: 1,
iterations: 1,
exec: "nonDefault",
Expand Down Expand Up @@ -170,9 +170,9 @@ func TestExecutionSchedulerRunEnv(t *testing.T) {
let errors = new Counter("errors");
export let options = {
execution: {
scenarios: {
executor: {
type: "%[1]s",
executor: "%[1]s",
gracefulStop: "0.5s",
%[2]s
}
Expand All @@ -193,7 +193,7 @@ func TestExecutionSchedulerRunEnv(t *testing.T) {
duration: "0.5s",
preAllocatedVUs: 1,
maxVUs: 2,`,
"constant-looping-vus": `
"constant-vus": `
vus: 1,
duration: "0.5s",`,
"externally-controlled": `
Expand All @@ -205,13 +205,13 @@ func TestExecutionSchedulerRunEnv(t *testing.T) {
"shared-iterations": `
vus: 1,
iterations: 1,`,
"variable-arrival-rate": `
"ramping-arrival-rate": `
startRate: 1,
timeUnit: "0.5s",
preAllocatedVUs: 1,
maxVUs: 2,
stages: [ { target: 1, duration: "0.5s" } ],`,
"variable-looping-vus": `
"ramping-vus": `
startVUs: 1,
stages: [ { target: 1, duration: "0.5s" } ],`,
}
Expand Down Expand Up @@ -275,9 +275,9 @@ func TestExecutionSchedulerRunCustomTags(t *testing.T) {
import http from "k6/http";
export let options = {
execution: {
scenarios: {
executor: {
type: "%s",
executor: "%s",
gracefulStop: "0.5s",
%s
}
Expand All @@ -295,7 +295,7 @@ func TestExecutionSchedulerRunCustomTags(t *testing.T) {
duration: "0.5s",
preAllocatedVUs: 1,
maxVUs: 2,`,
"constant-looping-vus": `
"constant-vus": `
vus: 1,
duration: "0.5s",`,
"externally-controlled": `
Expand All @@ -307,13 +307,13 @@ func TestExecutionSchedulerRunCustomTags(t *testing.T) {
"shared-iterations": `
vus: 1,
iterations: 1,`,
"variable-arrival-rate": `
"ramping-arrival-rate": `
startRate: 5,
timeUnit: "0.5s",
preAllocatedVUs: 1,
maxVUs: 2,
stages: [ { target: 10, duration: "1s" } ],`,
"variable-looping-vus": `
"ramping-vus": `
startVUs: 1,
stages: [ { target: 1, duration: "0.5s" } ],`,
}
Expand Down Expand Up @@ -397,9 +397,9 @@ func TestExecutionSchedulerRunCustomConfigNoCrossover(t *testing.T) {
export let options = {
// Required for WS tests
hosts: { 'httpbin.local': '127.0.0.1' },
execution: {
scenarios: {
scenario1: {
type: 'per-vu-iterations',
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
gracefulStop: '0s',
Expand All @@ -409,7 +409,7 @@ func TestExecutionSchedulerRunCustomConfigNoCrossover(t *testing.T) {
tags: { testtag1: 'scenario1' },
},
scenario2: {
type: 'shared-iterations',
executor: 'shared-iterations',
vus: 1,
iterations: 1,
gracefulStop: '1s',
Expand All @@ -420,7 +420,7 @@ func TestExecutionSchedulerRunCustomConfigNoCrossover(t *testing.T) {
tags: { testtag2: 'scenario2' },
},
scenario3: {
type: 'per-vu-iterations',
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
gracefulStop: '1s',
Expand Down Expand Up @@ -1210,19 +1210,19 @@ func TestNewExecutionSchedulerHasWork(t *testing.T) {
export let options = {
executionSegment: "3/4:1",
executionSegmentSequence: "0,1/4,2/4,3/4,1",
execution: {
scenarios: {
shared_iters1: {
type: "shared-iterations",
executor: "shared-iterations",
vus: 3,
iterations: 3,
},
shared_iters2: {
type: "shared-iterations",
executor: "shared-iterations",
vus: 4,
iterations: 4,
},
constant_arr_rate: {
type: "constant-arrival-rate",
executor: "constant-arrival-rate",
rate: 3,
timeUnit: "1s",
duration: "20s",
Expand Down
4 changes: 2 additions & 2 deletions js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ func TestSetupDataIsolation(t *testing.T) {
var Counter = require("k6/metrics").Counter;
exports.options = {
execution: {
scenarios: {
shared_iters: {
type: "shared-iterations",
executor: "shared-iterations",
vus: 5,
iterations: 500,
},
Expand Down
2 changes: 2 additions & 0 deletions lib/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func (arc *Archive) getFs(name string) afero.Fs {
// 83193f8a96e06a190325b838b2cc451119d6b836. This basically means k6 v0.24.0 and
// surrounding master commits. We filter these out by the value of the k6version
// property, saved in the metadata.json since the previous to the above commit.
//
//TODO: delete? now that execution has been renamed to scenarios, this isn't needed
func CleanUpWrongMetadataJSON(data []byte) ([]byte, error) {
var tmpArc map[string]interface{}
if err := json.Unmarshal(data, &tmpArc); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion lib/executor/base_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const executorNameErr = "the executor name should contain only numbers, latin le
// BaseConfig contains the common config fields for all executors
type BaseConfig struct {
Name string `json:"-"` // set via the JS object key
Type string `json:"type"`
Type string `json:"executor"`
StartTime types.NullDuration `json:"startTime"`
GracefulStop types.NullDuration `json:"gracefulStop"`
Env map[string]string `json:"env"`
Expand Down
2 changes: 1 addition & 1 deletion lib/executor/constant_looping_vus.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/loadimpact/k6/ui/pb"
)

const constantLoopingVUsType = "constant-looping-vus"
const constantLoopingVUsType = "constant-vus"

func init() {
lib.RegisterExecutorConfigType(
Expand Down
Loading

0 comments on commit 08070ca

Please sign in to comment.