Merge pull request #445 from err931/fix-broken-loadtest

Fix broken loadtest
This commit is contained in:
Mike Cao 2021-01-29 16:54:18 -08:00 committed by GitHub
commit 13b81bc650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,6 @@ const options = {
const message = JSON.stringify(mockPageView()); const message = JSON.stringify(mockPageView());
options.headers['Content-Length'] = message.length; options.headers['Content-Length'] = message.length;
options.headers['Content-Type'] = 'application/json'; options.headers['Content-Type'] = 'application/json';
options.headers['user-agent'] = 'User-Agent: Mozilla/5.0 LoadTest';
options.body = message; options.body = message;
options.path = '/api/collect'; options.path = '/api/collect';
const request = client(options, callback); const request = client(options, callback);
@ -95,7 +94,6 @@ loadtest.loadTest(options, (error, results) => {
if (results.errorCodes && Object.keys(results.errorCodes).length) { if (results.errorCodes && Object.keys(results.errorCodes).length) {
console.log(chalk.redBright('*'), chalk.red('Error Codes:'), results.errorCodes); console.log(chalk.redBright('*'), chalk.red('Error Codes:'), results.errorCodes);
} }
// console.log(results);
}); });
/** /**
@ -121,6 +119,9 @@ function mockPageView(
// If you pass in --verbose, this function is called // If you pass in --verbose, this function is called
function statusCallback(error, result, latency) { function statusCallback(error, result, latency) {
if (error) {
return console.error(chalk.redBright(error));
}
console.log( console.log(
chalk.yellowBright(`\n## req #${result.requestIndex + 1} of ${latency.totalRequests}`), chalk.yellowBright(`\n## req #${result.requestIndex + 1} of ${latency.totalRequests}`),
); );