-
-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding individual status code statistics table #347
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0c54331
Adding individual status code statistics table
maxfortun 80c8446
Adding unit test for status code statistics table
maxfortun 17a93a2
Adding unit test for status code statistics table
maxfortun 8ee79d5
Adding unit test for status code statistics table
maxfortun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
|
@@ -2,6 +2,14 @@ | |
|
||
const autocannon = require('../autocannon') | ||
const exampleResult = require('./fixtures/example-result.json') | ||
const crossArgv = require('cross-argv') | ||
|
||
const resultStr = autocannon.printResult(exampleResult) | ||
let opts = null | ||
|
||
if (process.argv.length > 2) { | ||
const args = crossArgv(process.argv.slice(2)) | ||
opts = autocannon.parseArguments(args) | ||
} | ||
|
||
const resultStr = autocannon.printResult(exampleResult, opts) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this change to the tests is actually being used anywhere. Can you please confirm? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like I forgot to add a file. |
||
process.stderr.write(resultStr) |
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,61 @@ | ||
'use strict' | ||
|
||
const test = require('tap').test | ||
const split = require('split2') | ||
const path = require('path') | ||
const childProcess = require('child_process') | ||
|
||
test('should stdout (print) the result', (t) => { | ||
const lines = [ | ||
/.*/, | ||
/Stat.*2\.5%.*50%.*97\.5%.*99%.*Avg.*Stdev.*Max.*$/, | ||
/.*/, | ||
/Latency.*$/, | ||
/$/, | ||
/.*/, | ||
/Stat.*1%.*2\.5%.*50%.*97\.5%.*Avg.*Stdev.*Min.*$/, | ||
/.*/, | ||
/Req\/Sec.*$/, | ||
/.*/, | ||
/Bytes\/Sec.*$/, | ||
/.*/, | ||
/.*/, | ||
/Code.*Count.*$/, | ||
/.*/, | ||
/200.*500.*$/, | ||
/.*/, | ||
/302.*0.*$/, | ||
/.*/, | ||
/401.*0.*$/, | ||
/.*/, | ||
/403.*0.*$/, | ||
/.*/, | ||
/$/, | ||
/Req\/Bytes counts sampled once per second.*$/, | ||
/$/, | ||
/.* requests in ([0-9]|\.)+s, .* read/ | ||
] | ||
|
||
t.plan(lines.length * 2) | ||
|
||
const child = childProcess.spawn(process.execPath, [path.join(__dirname, 'printResult-process.js'), '--renderStatusCodes', 'http://127.0.0.1'], { | ||
cwd: __dirname, | ||
env: process.env, | ||
stdio: ['ignore', 'pipe', 'pipe'], | ||
detached: false | ||
}) | ||
|
||
t.tearDown(() => { | ||
child.kill() | ||
}) | ||
|
||
child | ||
.stderr | ||
.pipe(split()) | ||
.on('data', (line) => { | ||
const regexp = lines.shift() | ||
t.ok(regexp, 'we are expecting this line') | ||
t.ok(regexp.test(line), 'line matches ' + regexp) | ||
}) | ||
.on('end', t.end) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason to not use the object values as the count, instead of having an object with a single property
count
? It would be more consistent with how the other stats are aggregatedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simoneb , you are absolutely right, there are many ways this could be improved. I was not certain of how far I can mod the code and still remain within the original author's intent. My goal was
additive
change only without impacting any of the existing functionality. If you believe that you can take this further, please do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as
object with a single property
, I envision that there may be other attributes aggregated about each individual statusCode, other than a count, and thus wanted to provide a harness for that. An example could be request timing average per code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxfortun on the overall approach let's hear what @mcollina thinks. On the count property, if it's not necessary, I'd say avoid it