diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-11-28 04:53:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-11-28 04:53:29 +0000 |
commit | 17c93e2be4ad7b3af0cd6878bdd5d8a4a3e6da99 (patch) | |
tree | 3e0c96613972e8bb4afdeeb97a034806363ddfa9 /tests/k6/data.js | |
parent | Releasing debian version 1.18.1-1. (diff) | |
download | netdata-17c93e2be4ad7b3af0cd6878bdd5d8a4a3e6da99.tar.xz netdata-17c93e2be4ad7b3af0cd6878bdd5d8a4a3e6da99.zip |
Merging upstream version 1.19.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/k6/data.js | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/tests/k6/data.js b/tests/k6/data.js deleted file mode 100644 index fb4e087ee..000000000 --- a/tests/k6/data.js +++ /dev/null @@ -1,67 +0,0 @@ -import http from "k6/http"; -import { log, check, group, sleep } from "k6"; -import { Rate } from "k6/metrics"; - -// A custom metric to track failure rates -var failureRate = new Rate("check_failure_rate"); - -// Options -export let options = { - stages: [ - // Linearly ramp up from 1 to 20 VUs during first 30s - { target: 20, duration: "30s" }, - // Hold at 50 VUs for the next 1 minute - { target: 20, duration: "1m" }, - // Linearly ramp down from 50 to 0 VUs over the last 10 seconds - { target: 0, duration: "10s" } - ], - thresholds: { - // We want the 95th percentile of all HTTP request durations to be less than 500ms - "http_req_duration": ["p(95)<500"], - // Requests with the fast tag should finish even faster - "http_req_duration{fast:yes}": ["p(99)<250"], - // Thresholds based on the custom metric we defined and use to track application failures - "check_failure_rate": [ - // Global failure rate should be less than 1% - "rate<0.01", - // Abort the test early if it climbs over 5% - { threshold: "rate<=0.05", abortOnFail: true }, - ], - }, -}; - -function rnd(min, max) { - min = Math.ceil(min); - max = Math.floor(max); - return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive -} - -// Main function -export default function () { - // Control what the data request asks for - let charts = [ "example.random" ] - let chartmin = 0; - let chartmax = charts.length - 1; - let aftermin = 60; - let aftermax = 3600; - let beforemin = 3503600; - let beforemax = 3590000; - let pointsmin = 300; - let pointsmax = 3600; - - group("Requests", function () { - // Execute multiple requests in parallel like a browser, to fetch data for the charts. The one taking the longes is the data request. - let resps = http.batch([ - ["GET", "http://localhost:19999/api/v1/info", { tags: { fast: "yes" } }], - ["GET", "http://localhost:19999/api/v1/charts", { tags: { fast: "yes" } }], - ["GET", "http://localhost:19999/api/v1/data?chart="+charts[rnd(chartmin,chartmax)]+"&before=-"+rnd(beforemin,beforemax)+"&after=-"+rnd(aftermin,aftermax)+"&points="+rnd(pointsmin,pointsmax)+"&format=json&group=average>ime=0&options=ms%7Cflip%7Cjsonwrap%7Cnonzero&_="+rnd(1,1000000000000), { }], - ["GET", "http://localhost:19999/api/v1/alarms", { tags: { fast: "yes" } }] - ]); - // Combine check() call with failure tracking - failureRate.add(!check(resps, { - "status is 200": (r) => r[0].status === 200 && r[1].status === 200 - })); - }); - - sleep(Math.random() * 2 + 1); // Random sleep between 1s and 3s -} |