93 lines
2.9 KiB
JavaScript
93 lines
2.9 KiB
JavaScript
let k6 = require("k6");
|
|
let utils = require("./utils.js");
|
|
|
|
let modules = [];
|
|
let datas = [];
|
|
let splitFiles = __ENV.PIVOT_FILE.split("*");
|
|
|
|
for (let i = 0; i < splitFiles.length; i++) {
|
|
let file = "/testRunner/tests/BestPracticeWorkbook/" + splitFiles[i];
|
|
let fileText = "";
|
|
if (!String(file).endsWith(".json")) {
|
|
modules[file] = require(file);
|
|
} else {
|
|
fileText = open(file).replace(/(\r\n|\n|\r)/gm, "");
|
|
}
|
|
|
|
datas.push({ fileName: file, text: fileText });
|
|
}
|
|
|
|
module.exports.options = {
|
|
teardownTimeout: "2m0s",
|
|
stages: [
|
|
// { duration: "0m0s", target: 1 },
|
|
// { duration: "0m10s", target: 1 },
|
|
// { duration: "0m0s", target: 5 },
|
|
// { duration: "3m0s", target: 5 },
|
|
// { duration: "0m0s", target: 10 },
|
|
// { duration: "3m0s", target: 10 },
|
|
// { duration: "0m0s", target: 20 },
|
|
// { duration: "3m0s", target: 20 },
|
|
// { duration: "0m0s", target: 30 },
|
|
// { duration: "3m0s", target: 30},
|
|
// { duration: "0m0s", target: 40 },
|
|
// { duration: "3m0s", target: 40 },
|
|
// { duration: "0m0s", target: 50 },
|
|
// { duration: "3m0s", target: 50 },
|
|
// { duration: "0m0s", target: 75 },
|
|
// { duration: "5m0s", target: 75 },
|
|
// { duration: "0m0s", target: 100 },
|
|
// { duration: "5m0s", target: 100 },
|
|
// { duration: "0m0s", target: 150 },
|
|
// { duration: "5m0s", target: 150 },
|
|
// { duration: "0m0s", target: 200 },
|
|
// { duration: "5m0s", target: 200 },
|
|
// { duration: "0m0s", target: 250 },
|
|
// { duration: "5m0s", target: 250 },
|
|
// { duration: "0m0s", target: 300 },
|
|
// { duration: "5m0s", target: 300 },
|
|
// { duration: "0m0s", target: 350 },
|
|
// { duration: "5m0s", target: 350 },
|
|
{ duration: "0m0s", target: 450 },
|
|
{ duration: "5m0s", target: 450 },
|
|
{ duration: "0m0s", target: 550 },
|
|
{ duration: "5m0s", target: 550 },
|
|
{ duration: "0m0s", target: 650 },
|
|
{ duration: "5m0s", target: 650 },
|
|
{ duration: "0m0s", target: 750 },
|
|
{ duration: "5m0s", target: 750 },
|
|
{ duration: "0m0s", target: 850 },
|
|
{ duration: "5m0s", target: 850 },
|
|
{ duration: "0m0s", target: 1000 },
|
|
{ duration: "5m0s", target: 1000 },
|
|
{ duration: "0m0s", target: 1500 },
|
|
{ duration: "5m0s", target: 1500 },
|
|
{ duration: "0m0s", target: 2000 },
|
|
{ duration: "5m0s", target: 2000 },
|
|
],
|
|
};
|
|
|
|
export function setup() {
|
|
console.log("setting up token");
|
|
return utils.generateToken();
|
|
}
|
|
|
|
module.exports.default = function run(token) {
|
|
let clone = [];
|
|
Object.assign(clone, datas);
|
|
|
|
while (clone.length > 0) {
|
|
let ran = Math.floor(Math.random() * clone.length);
|
|
let currentItems = clone.splice(ran, Math.floor(Math.random() * 3 + 1));
|
|
|
|
k6.sleep(Math.round(Math.random() * 20 + 1));
|
|
|
|
for (let i = 0; i < currentItems.length; i++) {
|
|
k6.group(currentItems[i].fileName.substring(7), function () {
|
|
utils.runHttp(currentItems[i], token);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|