-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the whole project: Add scenarios and helper js files and mak…
…e things dynamic
- Loading branch information
1 parent
d952353
commit 10da813
Showing
3 changed files
with
136 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
export const usersCapacityCalPhases = (scenario) => { | ||
let totalDuration = 0; | ||
let phases = []; | ||
let totalPhasesDuration = 0; | ||
|
||
for (let i = 0; i < scenario.length; i++) { | ||
totalDuration += parseDuration(scenario[i].duration); | ||
if (scenario[i].usersCapacityCalcRef) { | ||
let phaseStart = totalDuration - parseDuration(scenario[i].duration); | ||
let phaseEnd = totalDuration; | ||
let phaseTarget = scenario[i].target; | ||
phases.push({ phaseStart, phaseEnd, phaseTarget }); | ||
totalPhasesDuration += parseDuration(scenario[i].duration); | ||
} | ||
} | ||
|
||
let isConfigured = phases.length > 0; | ||
|
||
let totalPhasesDurationInMinutes = totalPhasesDuration / 60; | ||
|
||
console.log("USERs CAPACITY CALCs CONFIGs:"); | ||
|
||
if (isConfigured) { | ||
phases.forEach((phase, index) => { | ||
console.log( | ||
`Phase ${index + 1} starts at ${phase.phaseStart} seconds and ends at ${ | ||
phase.phaseEnd | ||
} seconds with a target of ${phase.phaseTarget} VUs` | ||
); | ||
}); | ||
console.log( | ||
`Total duration of users capacity phases is: ${totalPhasesDurationInMinutes} minutes` | ||
); | ||
} else { | ||
console.log( | ||
"This scenario is not configured for user capacity calculation." | ||
); | ||
} | ||
|
||
return { phases, isConfigured, totalPhasesDurationInMinutes }; | ||
}; | ||
|
||
const parseDuration = (duration) => { | ||
let time = parseInt(duration.slice(0, -1)); | ||
let unit = duration.slice(-1); | ||
switch (unit) { | ||
case "s": | ||
return time; | ||
case "m": | ||
return time * 60; | ||
case "h": | ||
return time * 3600; | ||
default: | ||
return 0; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export let scenario_1min = [ | ||
// Unreliable scenario. Just for quick test | ||
{ duration: "30s", target: 100 }, | ||
{ duration: "3s", target: 0 }, | ||
]; | ||
|
||
export let scenario_15min = [ | ||
{ duration: "30s", target: 100 }, // warm-up (below normal load) | ||
{ duration: `10s`, target: 100 }, | ||
{ duration: "20s", target: 500 }, // normal load | ||
{ duration: "20s", target: 500 }, | ||
{ duration: "50s", target: 1000 }, | ||
{ duration: "20s", target: 1300 }, // high load (below the breaking point) | ||
{ duration: "90s", target: 2000 }, | ||
{ duration: "10m", target: 2000, usersCapacityCalcRef: true }, // Stress load (around the breaking point) | ||
{ duration: "60s", target: 0 }, // scale down (recovery stage) | ||
]; | ||
|
||
export let scenario_36min = [ | ||
{ duration: "2m", target: 100 }, // Warm-up | ||
{ duration: "2m", target: 500 }, // Increase to normal load | ||
{ duration: "2m", target: 1000 }, // Increase to high load | ||
{ duration: "2m", target: 1500 }, // Gradual increase | ||
{ duration: "2m", target: 2000 }, // Gradual increase to peak load | ||
{ duration: "20m", target: 2000, usersCapacityCalcRef: true }, // Steady-state peak load (Stress Load) | ||
{ duration: "2m", target: 1000 }, // Gradual decrease | ||
{ duration: "2m", target: 500 }, // Decrease to normal load | ||
{ duration: "2m", target: 0 }, // Cool-down and recovery | ||
]; | ||
|
||
export let scenario_65min = [ | ||
{ duration: "2m", target: 100 }, // Warm-up | ||
{ duration: "5m", target: 100 }, // Steady-state below normal load | ||
|
||
{ duration: "2m", target: 500 }, // Increase to normal load | ||
{ duration: "5m", target: 500 }, // Steady-state normal load | ||
|
||
{ duration: "2m", target: 1000 }, // Increase to high load | ||
{ duration: "10m", target: 1000 }, // Steady-state high load | ||
|
||
{ duration: "2m", target: 1500 }, // Gradual increase | ||
{ duration: "10m", target: 1500 }, // Steady-state | ||
|
||
{ duration: "2m", target: 2000 }, // Peak load | ||
{ duration: "20m", target: 2000, usersCapacityCalcRef: true }, // Steady-state peak load | ||
|
||
{ duration: "5m", target: 0 }, // Cool-down and recovery | ||
]; |