-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate threshold configuration before starting the execution
This commit makes sure that the threshold configuration (as passed in the script exported options for instance) is valid, before starting the execution. A valid threshold must pass the following assertion: - Its expression is syntaxically correct and is parsable - It applies to a metrics that's known to k6, either builtin or custom - Its expression's aggregation method is valid for the metric it applies to Threshold validation will be made in the context of the `run`, `cloud`, `archive`, `inspect`, and `archive` commands. If a threshold definition is invalid, the k6 program will exit with a status code of 104. ref #2330
- Loading branch information
Showing
10 changed files
with
102 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const options = { | ||
thresholds: { | ||
http_reqs: ["foo>0"], // Counter | ||
}, | ||
}; | ||
|
||
export default function () { | ||
console.log( | ||
"asserting that a malformed threshold fails with exit code 104 (Invalid config)" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const options = { | ||
thresholds: { | ||
// non existing is neither registered, nor a builtin metric. | ||
// k6 should catch that. | ||
"non existing": ["rate>0"], | ||
}, | ||
}; | ||
|
||
export default function () { | ||
console.log( | ||
"asserting that a threshold over a non-existing metric fails with exit code 104 (Invalid config)" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const options = { | ||
thresholds: { | ||
// http_reqs is a Counter metric. As such, it supports | ||
// only the 'count' and 'rate' operations. Thus, 'value' | ||
// being a Gauge's metric aggregation method, the threshold | ||
// configuration evaluation should fail. | ||
http_reqs: ["value>0"], | ||
}, | ||
}; | ||
|
||
export default function () { | ||
console.log( | ||
"asserting that a threshold applying a method over a metric not supporting it fails with exit code 104 (Invalid config)" | ||
); | ||
} |