I’ve been using k6 for load testing, and I’ve encountered an issue with my load testing script. In my script, I’m using multiple scenarios to simulate different API requests, including a scenario called ‘createUser’ with 5 virtual users. However, when I r
import { createUser } from '../Scenario/createUser.js';
export function runDynamicLoadTests() {
const scenarios = [
{ name: "createUser", scenario: createUser, vus: 5, duration: "10s" },
// Add more scenarios as needed
];
const results = [];
// Iterate through scenarios and run them
for (const scenario of scenarios) {
console.log(`Running load test for scenario: ${scenario.name}`);
// Run the scenario with the specified VUs and duration
const res = scenario.scenario({
vus: scenario.vus,
duration: scenario.duration,
});
results.push(res);
}
console.log(results);
// Aggregate and report results if needed
console.log(`Total VUs: ${__VU}`);
}
Response : ✓ Status code is 200 - Login Successful
checks.........................: 100.00% ✓ 2 ✗ 0
data_received..................: 8.0 kB 1.4 kB/s
data_sent......................: 919 B 160 B/s
http_req_blocked...............: avg=562.95ms min=0s med=562.95ms max=1.12s p(90)=1.01s p(95)=1.06s
http_req_connecting............: avg=141.78ms min=0s med=141.78ms max=283.56ms p(90)=255.2ms p(95)=269.38ms
http_req_duration..............: avg=2.3s min=1.4s med=2.3s max=3.19s p(90)=3.01s p(95)=3.1s
{ expected_response:true }...: avg=2.3s min=1.4s med=2.3s max=3.19s p(90)=3.01s p(95)=3.1s
http_req_failed................: 0.00% ✓ 0 ✗ 2
http_req_receiving.............: avg=113.5µs min=100µs med=113.5µs max=127µs p(90)=124.3µs p(95)=125.65µs
http_req_sending...............: avg=554.5µs min=263µs med=554.5µs max=846µs p(90)=787.7µs p(95)=816.84µs
http_req_tls_handshaking.......: avg=341.01ms min=0s med=341.01ms max=682.02ms p(90)=613.82ms p(95)=647.92ms
http_req_waiting...............: avg=2.3s min=1.4s med=2.3s max=3.19s p(90)=3.01s p(95)=3.1s
http_reqs......................: 2 0.348624/s
iteration_duration.............: avg=5.73s min=5.73s med=5.73s max=5.73s p(90)=5.73s p(95)=5.73s
iterations.....................: 1 0.174312/s
vus............................: 1 min=1 max=1
vus_max........................: 1 min=1 max=1