-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from thekemkid/rate-limiting
added rate limiting options
- Loading branch information
Showing
6 changed files
with
149 additions
and
76 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
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,32 @@ | ||
'use strict' | ||
|
||
const test = require('tap').test | ||
const run = require('../lib/run') | ||
const helper = require('./helper') | ||
const server = helper.startServer() | ||
|
||
test('run should only send the expected number of requests per second', (t) => { | ||
t.plan(6) | ||
|
||
run({ | ||
url: `http://localhost:${server.address().port}`, | ||
connections: 2, | ||
overallRate: 10, | ||
amount: 40 | ||
}, (err, res) => { | ||
t.error(err) | ||
t.equal(res.duration, 4, 'should have take 4 seconds to send 10 requests per seconds') | ||
t.equal(res.requests.average, 10, 'should have sent 10 requests per second on average') | ||
}) | ||
|
||
run({ | ||
url: `http://localhost:${server.address().port}`, | ||
connections: 2, | ||
connectionRate: 10, | ||
amount: 40 | ||
}, (err, res) => { | ||
t.error(err) | ||
t.equal(res.duration, 2, 'should have taken 2 seconds to send 10 requests per connection with 2 connections') | ||
t.equal(res.requests.average, 20, 'should have sent 20 requests per second on average with two connections') | ||
}) | ||
}) |