Created
July 19, 2017 19:14
-
-
Save nareddyt/c2f782b9f6eebd2e7cc15bcc558af255 to your computer and use it in GitHub Desktop.
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
'use strict' | |
const autocannon = require('autocannon'); | |
let jsf = require('json-schema-faker'); | |
let schema = { | |
type: 'object', | |
properties: { | |
id: -1, | |
Info: { | |
foo: 'bar', | |
zap: 'zah', | |
Address: { | |
name: 'James', | |
street: 'Spear Street', | |
number: '125', | |
city: 'San Fransisco' | |
}, | |
Dog: { | |
type: 'string', | |
chance: { | |
weighted: [ | |
['poodle', 'Golden Retreiver', 'Black Lab'], | |
[1, 1, 3] | |
] | |
} | |
} | |
}, | |
John: { | |
First: 'John', | |
Last: { | |
type: 'string', | |
chance: {'last': {}} | |
}, | |
Friends: { | |
type: 'array', | |
minItems: 2, | |
maxItems: 5, | |
items: { | |
First: { | |
type: 'string', | |
chance: {'first': {}} | |
}, | |
Last: { | |
type: 'string', | |
chance: {'last': {}} | |
}, | |
Age: 52 | |
} | |
} | |
} | |
}, | |
required: ['id', 'Info', 'John'], | |
}; | |
const instance = autocannon({ | |
headers: { | |
'Authorization': 'Bearer dotUZ92uyrjxGhbuy5VpUVqVUPdEZkx86wNlHfgE1LrTtOsxZvkcCqngaUzLgkJGio68KcWMGhtHFhXAd40V6B', | |
'Content-Type': 'application/json' | |
}, | |
url: 'https://ingestion-iog7rg5sc3lf.dev.sfdc-matrix.net/streams/teju_endpoint001/teju_ic001/event', | |
body: JSON.stringify(schema), | |
method: 'POST', | |
pipelining: 2, | |
duration: 300, | |
overallRate: 50000, | |
connections: 1000, | |
// setupClient: setupClient | |
}, (err, result) => handleResults(result)); | |
// results passed to the callback are the same as those emitted from the done events | |
instance.on('done', handleResults) | |
instance.on('response', handleResponse) | |
function handleResponse(client, statusCode, resBytes, responseTime) { | |
jsf.resolve(schema).then(function (sample) { | |
client.setBody(JSON.stringify(sample)); | |
}); | |
} | |
function handleResults(result) { | |
console.log(result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment