diff --git a/bin/minigun b/bin/minigun index c257bc5db2..c6a1de8a84 100755 --- a/bin/minigun +++ b/bin/minigun @@ -23,6 +23,11 @@ program 'Set content-type (defaults to application/json)') .action(commands.quick); +program + .command('report ') + .description('Create a report from a JSON file created by "minigun run"') + .action(commands.report); + program .command('dino') .description('Show dinosaur of the day') diff --git a/lib/commands/index.js b/lib/commands/index.js index b2ad558ba2..15b73e8a69 100644 --- a/lib/commands/index.js +++ b/lib/commands/index.js @@ -3,5 +3,6 @@ module.exports = { run: require('./run'), quick: require('./quick'), - dino: require('./dino') + dino: require('./dino'), + report: require('./report') }; diff --git a/lib/commands/report.js b/lib/commands/report.js new file mode 100644 index 0000000000..e2445a5ff4 --- /dev/null +++ b/lib/commands/report.js @@ -0,0 +1,25 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var l = require('lodash'); +var openfile = require('open'); + +module.exports = report; + +function report(jsonReportPath) { + var data = JSON.parse(fs.readFileSync(jsonReportPath, 'utf-8')); + var templateFn = path.join( + path.dirname(__filename), + '../report/index.html.ejs'); + var template = fs.readFileSync(templateFn, 'utf-8'); + var compiledTemplate = l.template(template); + var html = compiledTemplate({report: JSON.stringify(data, null, 2)}); + var reportFilename = jsonReportPath + '.html'; + fs.writeFileSync( + reportFilename, + html, + {encoding: 'utf-8', flag: 'w'}); + console.log('Report generated: %s', reportFilename); + openfile(reportFilename); +} diff --git a/lib/report/index.html.ejs b/lib/report/index.html.ejs new file mode 100644 index 0000000000..0c095b8587 --- /dev/null +++ b/lib/report/index.html.ejs @@ -0,0 +1,428 @@ + + + + Minigun report + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+

Test run on date

+
+
+ +
+
+

Summary

+ + + + + + + + + + + + + + + + +
Test duration0 sec
Scenarios created0
Requests completed0
+ +
+ +
+
+ Codes + +

+ + +
+
+
+ +
+
+ Errors + +

+ + +
+
+
+
+ +
+
+

Charts

+
+
+ +
+
+
+ + + +
+ +
+ +
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+

Raw report data

+

This is the raw JSON stats output that the report was generated from.

+
+
+
+
+ + + + + diff --git a/package.json b/package.json index f20c91cddf..17cbb6074e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minigun", - "version": "0.0.12", + "version": "0.0.13", "description": "Load-testing for HTTP-based applications", "main": "./bin/minigun", "scripts": { @@ -38,7 +38,8 @@ "csv-parse": "^0.1.1", "debug": "^2.2.0", "lodash": "^3.9.1", - "minigun-core": "latest" + "minigun-core": "latest", + "open": "0.0.5" }, "devDependencies": { "eslint": "^0.21.2",