From e9162632f3972dacad056ce9112483979a78a740 Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Fri, 10 Oct 2025 22:21:12 +0200 Subject: [PATCH] Added K6 tests, Added Lighthouse test result --- docs/Testresults/20251010_QA_K6_16VUs30s.txt | 23 +++++++ docs/Testresults/20251010_QA_Lighthouse.html | 65 ++++++++++++++++++++ tests/k6/loadtest.js | 37 +++++++++++ 3 files changed, 125 insertions(+) create mode 100644 docs/Testresults/20251010_QA_K6_16VUs30s.txt create mode 100644 docs/Testresults/20251010_QA_Lighthouse.html create mode 100644 tests/k6/loadtest.js diff --git a/docs/Testresults/20251010_QA_K6_16VUs30s.txt b/docs/Testresults/20251010_QA_K6_16VUs30s.txt new file mode 100644 index 0000000..d7c6f3e --- /dev/null +++ b/docs/Testresults/20251010_QA_K6_16VUs30s.txt @@ -0,0 +1,23 @@ + █ TOTAL RESULTS + + checks_total.......: 2016 65.329201/s + checks_succeeded...: 100.00% 2016 out of 2016 + checks_failed......: 0.00% 0 out of 2016 + + ✓ authorized request succeeded + + HTTP + http_req_duration..............: avg=13.38ms min=4.54ms med=11.01ms max=993.51ms p(90)=18.27ms p(95)=21.24ms + { expected_response:true }...: avg=13.38ms min=4.54ms med=11.01ms max=993.51ms p(90)=18.27ms p(95)=21.24ms + http_req_failed................: 0.00% 0 out of 4044 + http_reqs......................: 4044 131.047267/s + + EXECUTION + iteration_duration.............: avg=27.16ms min=14.2ms med=20.91ms max=1s p(90)=34ms p(95)=38.13ms + iterations.....................: 2016 65.329201/s + vus............................: 16 min=16 max=16 + vus_max........................: 16 min=16 max=16 + + NETWORK + data_received..................: 73 MB 2.4 MB/s + data_sent......................: 2.0 MB 66 kB/s \ No newline at end of file diff --git a/docs/Testresults/20251010_QA_Lighthouse.html b/docs/Testresults/20251010_QA_Lighthouse.html new file mode 100644 index 0000000..4836c91 --- /dev/null +++ b/docs/Testresults/20251010_QA_Lighthouse.html @@ -0,0 +1,65 @@ + + + + + + + + Lighthouse Report + + + + + +
+ + + + + + diff --git a/tests/k6/loadtest.js b/tests/k6/loadtest.js new file mode 100644 index 0000000..c027a80 --- /dev/null +++ b/tests/k6/loadtest.js @@ -0,0 +1,37 @@ +import http from 'k6/http'; +import { check } from 'k6'; + +export let options = { + vus: 16, // number of virtual users + duration: '30s', // test duration +}; +export default function () { + let environment = "http://localhost:5275"; + let username = "admin"; + let password = "admin"; + // Step 1: login, disable redirect following + let loginRes = http.post( + environment + '/Home/Login', + { Username: username, Password: password }, + { redirects: 0 } + ); + + // Step 2: extract the auth cookie manually + const setCookieHeader = loginRes.headers['Set-Cookie']; + + // Use a regex to extract the cookie value + const match = setCookieHeader.match(/\.AspNetCore\.Cookies=([^;]+)/); + const authCookie = match ? match[1] : null; + + if (!authCookie) { + throw new Error('Login failed: no auth cookie found'); + } + + // Step 3: use it on a protected page + const headers = { Cookie: `.AspNetCore.Cookies=${authCookie}` }; + const res = http.get(environment + '/Home/Assets', { headers }); + + check(res, { + 'authorized request succeeded': (r) => r.status === 200, + }); +}