-
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
verifyBody
to customize the mismatch rules for response b…
…ody (#443) * feat: add verifyBody to customize mismatch rule * docs: add `verify-body` doc & samples * test: add `verifyBody` unit tests Co-authored-by: chenguanyu <chengaunyu@sogou-inc.com>
- Loading branch information
1 parent
928e44f
commit 8d5aa97
Showing
12 changed files
with
153 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,4 +134,5 @@ build/Release | |
|
||
profile-* | ||
|
||
.devcontainer | ||
.devcontainer | ||
.history |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
|
||
const http = require('http') | ||
const path = require('path') | ||
const autocannon = require('../autocannon') | ||
|
||
const server = http.createServer(handle) | ||
|
||
server.listen(0, startBench) | ||
|
||
function handle (req, res) { | ||
res.end('hello world') | ||
} | ||
|
||
function startBench () { | ||
const url = 'http://localhost:' + server.address().port | ||
|
||
autocannon({ | ||
url: url, | ||
connections: 1000, | ||
duration: 10, | ||
workers: 2, | ||
verifyBody: path.join(__dirname, 'helpers', 'verify-body') | ||
}, finishedBench) | ||
|
||
function finishedBench (err, res) { | ||
console.log('finished bench', err, res) | ||
} | ||
} |
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,31 @@ | ||
'use strict' | ||
|
||
const http = require('http') | ||
const autocannon = require('../autocannon') | ||
|
||
const server = http.createServer(handle) | ||
|
||
server.listen(0, startBench) | ||
|
||
function handle (req, res) { | ||
res.end('hello world') | ||
} | ||
|
||
function startBench () { | ||
const url = 'http://localhost:' + server.address().port | ||
|
||
autocannon({ | ||
url: url, | ||
connections: 1000, | ||
duration: 10, | ||
verifyBody: verifyBody | ||
}, finishedBench) | ||
|
||
function verifyBody (body) { | ||
return body.indexOf('<html>') > -1 | ||
} | ||
|
||
function finishedBench (err, res) { | ||
console.log('finished bench', err, res) | ||
} | ||
} |
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,5 @@ | ||
'use strict' | ||
|
||
module.exports = (body) => { | ||
return true | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (body) => { | ||
return false | ||
} |
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