qlik-stex
Version:
Qlik Sense Scalability Tools extension for testing multi apps scenarions ex. saas
98 lines (89 loc) • 2.8 kB
JavaScript
var fs = require('fs');
const optionDefinitions = [
{ name: 'applist', alias: 'a', type: String },
{ name: 'scenario', alias: 's', type: String },
{ name: 'help', alias: 'q', type: Boolean }
]
const commandLineArgs = require('command-line-args')
const cla = commandLineArgs(optionDefinitions)
var log_folder = "..\\Results\\";
//create simple scenario in scalability tool and copy and paste this
var scheduler = `{
"apiVersion": "1.0",
"settings": {
"logFolder": "",
"failureBehavior": "IgnoreNContinue",
"maxDurationHours": 48,
"customOrder": []
},
"scheduledTasks":[]
}`;
var task = {
"id": 0,
"name": "app_name",
"type": "SDKExerciserTask",
"isEnabled": true,
"settings": {
"scriptFile": "..\\Scenario\\Kleos.json",
"app": "app_id",
"concurrentUsers": 1,
"rampupSeconds": 1.0,
"iterations": 1,
"durationSeconds": -1,
"server": "wkewnpvm0031",
"virtualProxy": "hdr",
"header": "X-Qlik-User",
"usernamePrefix": "Exerciser",
"instanceNumber": 1,
"ssl": true,
"sdkExerciserPath": "..\\SDKExerciser\\Nov2017\\",
"appMode": "Open",
"newUserForEachIteration": false,
"afterIterationWait": "NoWait",
"afterIterationWaitTime": 0,
"maxNumberOfErrors": -1
},
"triggerType": "TimeOffset",
"triggerSettings": {
"hours": 0,
"minutes": 0,
"seconds": 1
}
};
if(cla.help)
{
console.log('-a input text file name with Qlik app IDs list, ex: apps.txt')
console.log('-c output JSON file name with scenario, ex: scenario.json');
}
else if(cla.applist !=='' && typeof cla.applist !== 'undefined' && cla.scenario !=='' && typeof cla.scenario !== 'undefined')
{
fs.readFile(cla.applist, function(err, data) {
if(err) throw err;
var array = data.toString().split("\n");
//for(i in array) {
//console.log(array[i]);
//}
var task_order =[];
var appid = "";
for(var x in array){
task.id = Number(x)+1;
task.name = "QST";
appid = array[x];
task.settings.app = appid.trim();
task_order.push(task.id);
var obj = JSON.parse(scheduler);
obj['scheduledTasks'].push(task);
scheduler = JSON.stringify(obj);
}
scheduler = JSON.parse(scheduler);
scheduler.settings.logFolder = log_folder
scheduler.settings.customOrder = task_order;
fs.writeFile(cla.scenario, JSON.stringify(scheduler,null,"\t"), function(err, data) {
console.log("File " + cla.scenario + " created. Validate it at https://jsonlint.com/");
});
});
}
else
{
console.log('Missing parameters, please use -q option to get help')
}