mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Merge pull request #109 from LD-Reborn/108-feature-add-lighthouse-and-k6-load-tests
108 feature add lighthouse and k6 load tests
This commit is contained in:
23
docs/Testresults/20251010_QA_K6_16VUs30s.txt
Normal file
23
docs/Testresults/20251010_QA_K6_16VUs30s.txt
Normal file
@@ -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
|
||||
65
docs/Testresults/20251010_QA_Lighthouse.html
Normal file
65
docs/Testresults/20251010_QA_Lighthouse.html
Normal file
File diff suppressed because one or more lines are too long
@@ -48,8 +48,8 @@ builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationSc
|
||||
builder.Services.AddResponseCompression(options =>
|
||||
{
|
||||
options.EnableForHttps = true;
|
||||
options.MimeTypes = new[]
|
||||
{
|
||||
options.MimeTypes =
|
||||
[
|
||||
"text/plain",
|
||||
"text/css",
|
||||
"application/javascript",
|
||||
@@ -58,7 +58,7 @@ builder.Services.AddResponseCompression(options =>
|
||||
"text/xml",
|
||||
"application/json",
|
||||
"image/svg+xml"
|
||||
};
|
||||
];
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
@@ -89,7 +89,22 @@ if (app.Environment.IsDevelopment())
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
OnPrepareResponse = ctx =>
|
||||
{
|
||||
string requestPath = ctx.Context.Request.Path.ToString();
|
||||
if (requestPath.EndsWith(".css") || requestPath.EndsWith(".js"))
|
||||
{
|
||||
ctx.Context.Response.GetTypedHeaders().CacheControl =
|
||||
new Microsoft.Net.Http.Headers.CacheControlHeaderValue()
|
||||
{
|
||||
Public = true,
|
||||
MaxAge = TimeSpan.FromDays(365)
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
app.UseResponseCompression();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
<div class="mb-4 d-flex flex-wrap gap-2">
|
||||
<button class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#createAssetModal">
|
||||
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createAssetModal">
|
||||
@T["Create asset"]
|
||||
</button>
|
||||
</div>
|
||||
@@ -231,7 +231,7 @@
|
||||
<div id="attributesContainer" class="d-flex flex-column gap-2">
|
||||
<!-- Dynamic attribute rows will appear here -->
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-success mt-3" id="addAttributeBtn">
|
||||
<button type="button" class="btn btn-sm btn-success mt-3" id="addAttributeBtn">
|
||||
➕ @T["Add Attribute"]
|
||||
</button>
|
||||
</div>
|
||||
@@ -280,7 +280,7 @@
|
||||
row.innerHTML = `
|
||||
<input type="text" class="form-control" placeholder="Attribute name" data-attr-name />
|
||||
<input type="text" class="form-control" placeholder="Attribute value" data-attr-value />
|
||||
<button type="button" class="btn btn-outline-danger btn-sm btn-remove-attribute">✖</button>
|
||||
<button type="button" class="btn btn-danger btn-sm btn-remove-attribute">✖</button>
|
||||
`;
|
||||
attributesContainer.appendChild(row);
|
||||
});
|
||||
@@ -407,7 +407,7 @@
|
||||
<h6 class="fw-bold mb-0">@T["Attributes"]</h6>
|
||||
</div>
|
||||
<div id="updateAttributesContainer" class="d-flex flex-column gap-2"></div>
|
||||
<button type="button" class="btn btn-sm btn-outline-success mt-3" id="updateAddAttributeBtn">
|
||||
<button type="button" class="btn btn-sm btn-success mt-3" id="updateAddAttributeBtn">
|
||||
➕ @T["Add Attribute"]
|
||||
</button>
|
||||
</div>
|
||||
@@ -457,7 +457,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
row.innerHTML = `
|
||||
<input type="text" class="form-control" placeholder="Attribute name" data-attr-name />
|
||||
<input type="text" class="form-control" placeholder="Attribute value" data-attr-value />
|
||||
<button type="button" class="btn btn-outline-danger btn-sm btn-remove-attribute">✖</button>
|
||||
<button type="button" class="btn btn-danger btn-sm btn-remove-attribute">✖</button>
|
||||
`;
|
||||
updateAttributesContainer.appendChild(row);
|
||||
});
|
||||
@@ -504,7 +504,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
row.innerHTML = `
|
||||
<input type="text" class="form-control" value="${attrName}" data-attr-name />
|
||||
<input type="text" class="form-control" value="${attrValue}" data-attr-value />
|
||||
<button type="button" class="btn btn-outline-danger btn-sm btn-remove-attribute">✖</button>
|
||||
<button type="button" class="btn btn-danger btn-sm btn-remove-attribute">✖</button>
|
||||
`;
|
||||
updateAttributesContainer.appendChild(row);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="container py-4">
|
||||
<h2 class="mb-3">@T["Overview"]</h2>
|
||||
<div class="mb-4 d-flex flex-wrap gap-2">
|
||||
<button class="btn btn-outline-primary">@T["Inventory asset"]</button>
|
||||
<button class="btn btn-outline-primary">@T["Create user"]</button>
|
||||
<button class="btn btn-primary">@T["Inventory asset"]</button>
|
||||
<button class="btn btn-primary">@T["Create user"]</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
|
||||
<div class="mb-4 d-flex flex-wrap gap-2">
|
||||
<button class="btn btn-outline-primary">Dummy button</button>
|
||||
<button class="btn btn-outline-secondary">Dummy button</button>
|
||||
<button class="btn btn-outline-danger">Dummy button</button>
|
||||
<button class="btn btn-primary">Dummy button</button>
|
||||
<button class="btn btn-secondary">Dummy button</button>
|
||||
<button class="btn btn-danger">Dummy button</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
<div class="mb-4 d-flex flex-wrap gap-2">
|
||||
<button class="btn btn-outline-primary">@T["Create location"]</button>
|
||||
<button class="btn btn-primary">@T["Create location"]</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
|
||||
<div class="mb-4 d-flex flex-wrap gap-2">
|
||||
<button class="btn btn-outline-primary">@T["Create user"]</button>
|
||||
<button class="btn btn-primary">@T["Create user"]</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -4,15 +4,17 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="description" content="Hardware asset management tool" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - Berufsschule_HAM</title>
|
||||
<script type="importmap"></script>
|
||||
@* <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> *@
|
||||
@* <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" asp-append-version="true"/> *@
|
||||
<link rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
|
||||
crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
|
||||
@* <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> *@
|
||||
<link rel="preload" href="~/css/site.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
|
||||
<noscript><link rel="stylesheet" href="~/css/site.css"></noscript>
|
||||
<link rel="stylesheet" href="~/Berufsschule_HAM.styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
<body data-bs-theme="dark">
|
||||
@@ -71,10 +73,10 @@
|
||||
© 2025 - Berufsschule_HAM
|
||||
</div>
|
||||
</footer>
|
||||
@* <script src="~/lib/jquery/dist/jquery.min.js"></script> *@
|
||||
@* <script src="~/lib/jquery/dist/jquery.min.js" defer></script> *@
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
|
||||
crossorigin="anonymous" defer></script>
|
||||
@* <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> *@
|
||||
@* <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js" defer></script> *@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
||||
crossorigin="anonymous" defer></script>
|
||||
<script src="~/js/site.js" asp-append-version="true" defer></script>
|
||||
|
||||
37
tests/k6/loadtest.js
Normal file
37
tests/k6/loadtest.js
Normal file
@@ -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,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user