forked from oaeproject/OAE-model-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_suites.js
63 lines (59 loc) · 2 KB
/
run_suites.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var general = require("./api/general.js");
var getAvailableSuites = function(){
return general.getFileListForFolder("./suites");
}
exports.runSuites = function(datamodel, runid, SERVER_URL, callback){
runid = runid || 0;
var registeredSuites = getAvailableSuites();
var suites = [];
var suitesToWrite = {};
for (var s = 0; s < registeredSuites.length; s++){
var suite = require("./suites/" + registeredSuites[s]).Suite(datamodel, SERVER_URL);
suites.push(suite);
suitesToWrite[suite.id] = {
"title": suite.title,
"threshold": suite.threshold,
"target": suite.target,
"elements": []
}
for (var e = 0; e < suite.elements.length; e++){
var element = suite.elements[e];
suitesToWrite[suite.id].elements.push({
"id": element.id,
"title": element.title,
"targetAverage": element.targetAverage,
"upperLimitAverage": element.upperLimitAverage,
"tolerance": element.tolerance,
"weight": element.weight
});
}
}
// Write the suites.json file
general.writeFile("./results/suites.json", JSON.stringify(suitesToWrite));
// Run the suite
var run = {};
run.users = 0;
for (var b = 0; b < datamodel.length; b++){
run.users += datamodel[b].users.length;
}
run.results = {};
var currentSuite = -1;
var runSuite = function(){
currentSuite++;
if (currentSuite < suites.length){
var suite = suites[currentSuite];
suite.run(function(results){
run.results[suite.id] = results;
runSuite();
});
} else {
// Write the run file
general.writeFile("./results/run" + runid + ".json", JSON.stringify(run));
callback();
}
}
runSuite();
}
exports.clearResults = function(){
general.removeFilesInFolder("./results");
}