From 4ac39a273056ecd1c61b175a69d25984ed225713 Mon Sep 17 00:00:00 2001 From: Alex Hyett Date: Wed, 27 Sep 2023 14:05:58 +0100 Subject: [PATCH] Add check to tests --- tests/load-test.js | 5 +++-- tests/soak-test.js | 5 +++-- tests/spike-test.js | 5 +++-- tests/stress-test.js | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/load-test.js b/tests/load-test.js index 59aa94b..c8c42ec 100644 --- a/tests/load-test.js +++ b/tests/load-test.js @@ -1,5 +1,5 @@ import http from 'k6/http'; -import { sleep } from 'k6'; +import { sleep, check } from 'k6'; import { SharedArray } from 'k6/data'; var hostname = __ENV.HOSTNAME; @@ -33,6 +33,7 @@ const dates = new SharedArray('dates', function () { export default () => { const randomDate = dates[Math.floor(Math.random() * dates.length)]; - http.get(`http://${hostname}/age/${randomDate}`); + const res = http.get(`http://${hostname}/age/${randomDate}`); + check(res, { '200': (r) => r.status === 200 }); sleep(1); }; \ No newline at end of file diff --git a/tests/soak-test.js b/tests/soak-test.js index 136a4f6..5a27295 100644 --- a/tests/soak-test.js +++ b/tests/soak-test.js @@ -1,5 +1,5 @@ import http from 'k6/http'; -import { sleep } from 'k6'; +import { sleep, check } from 'k6'; import { SharedArray } from 'k6/data'; var hostname = __ENV.HOSTNAME; @@ -30,6 +30,7 @@ const dates = new SharedArray('dates', function () { export default () => { const randomDate = dates[Math.floor(Math.random() * dates.length)]; - http.get(`http://${hostname}/age/${randomDate}`); + const res = http.get(`http://${hostname}/age/${randomDate}`); + check(res, { '200': (r) => r.status === 200 }); sleep(1); }; \ No newline at end of file diff --git a/tests/spike-test.js b/tests/spike-test.js index 5519063..5aedb5b 100644 --- a/tests/spike-test.js +++ b/tests/spike-test.js @@ -1,5 +1,5 @@ import http from 'k6/http'; -import { sleep } from 'k6'; +import { sleep, check } from 'k6'; import { SharedArray } from 'k6/data'; var hostname = __ENV.HOSTNAME; @@ -34,6 +34,7 @@ const dates = new SharedArray('dates', function () { export default () => { const randomDate = dates[Math.floor(Math.random() * dates.length)]; - http.get(`http://${hostname}/age/${randomDate}`); + const res = http.get(`http://${hostname}/age/${randomDate}`); + check(res, { '200': (r) => r.status === 200 }); sleep(1); }; \ No newline at end of file diff --git a/tests/stress-test.js b/tests/stress-test.js index 1aee852..d39e8a4 100644 --- a/tests/stress-test.js +++ b/tests/stress-test.js @@ -1,5 +1,5 @@ import http from 'k6/http'; -import { sleep } from 'k6'; +import { sleep, check } from 'k6'; import { SharedArray } from 'k6/data'; var hostname = __ENV.HOSTNAME; @@ -34,6 +34,7 @@ const dates = new SharedArray('dates', function () { export default () => { const randomDate = dates[Math.floor(Math.random() * dates.length)]; - http.get(`http://${hostname}/age/${randomDate}`); + const res = http.get(`http://${hostname}/age/${randomDate}`); + check(res, { '200': (r) => r.status === 200 }); sleep(1); }; \ No newline at end of file