Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

volume data insertion and autocannon bench tests #456

Merged
merged 8 commits into from
Feb 16, 2018

Conversation

cianfoley-nearform
Copy link
Contributor

Should not affect main build as both files are standalone scripts

package.json has 3 new commands, I added 2 relevant ones for users to readme.md

@coveralls
Copy link

coveralls commented Feb 12, 2018

Coverage Status

Coverage remained the same at 96.277% when pulling 6208356 on volume-fixtures-and-autocannon into 0a500ec on master.

})
} else {
startBench()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not recommend to run both autocannon and the benchmark on the same process. Both things can easily saturate a process at 100% cpu. You might want to spin up a child process with the server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, just added for convenience and is configurable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry thought you meant udaru server... ignore my comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant udaru server, sorry. I know it’s a convenience, but it generates bad results. Spin it up using a child process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Matteo, I forked a child process now, I think I captured all cases to start up/shut down correctly etc. I've set server config variable to true as it's definitely convenient especially if it doesn't affect speed

@cianfoley-nearform
Copy link
Contributor Author

added in index to migration script to version 6

Copy link
Contributor

@dberesford dberesford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @cianfoley-nearform. I left some minor nits, should be good to merge after that

})
}

function loadTeams (callback, orgId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the node convention is to have the callback param last, i.e. (orgId, callback)

return policyTemplate
}

function loadPolicies (callback, startId, orgId, teamId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, callback should be last arg

}

// insert users and add them to teams in batches
function loadUsers (callback, startId, orgId, teamId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, callback last

}

function loadVolumeDataEnd (callback) {
/* moved to migration scripts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commented code can be fully removed

endTime = Date.now()
logInColour('loadVolumeData completed in ' + (endTime - startTime) + 'ms')

callback(null) // done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for null here, just callback()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think i fixed all those, thanks Damien

console.log('\nStopping instance of autocannon...')
instance.stop()

if (child != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than explicitly checking for null, a better check is if (child) instead, this is more the convention in node as it covers null and undefined


function onComplete (err, res) {
var shutDown = false
if (err != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use if (err)

}

if (shutDown) {
if (child != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again if (child)

const SUB_TEAM_MOD = 100 // 1 parent for every X-1 teams
const NUM_USERS_PER_TEAM = 100 // put this many users in each team
const NUM_POLICIES_PER_TEAM = 10 // :-|
// const CREATE_INDEX = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this dead code can be removed

count++
}

// console.log(policiesSql);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this dead code can be removed


child.stdout.on('data', (m) => {
var s = m.toString('utf8')
if (s.indexOf('Server started on:') !== -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the child process is logging heavily to stdout, this might create too much overhead.
A better approach might be to use use process.send()  and redirect stdout/stderr to /dev/null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, made that change, had to change server/start to send the message when forked as child, hope it's OK

var s = m.toString('utf8')
// child should send close event, no need to kill on error
// useful output if port being used for example
console.log('\x1b[31m', s, '\x1b[0m')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use the http://npmjs.com/chalk module for coloring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using chalk now, thanks for the heads up

colour = '\x1b[32m'
} else if (level === 'error') {
colour = '\x1b[31m'
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

color should be applied using chalk

Copy link
Contributor

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@dberesford dberesford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM also, thanks @cianfoley-nearform. Also thanks @mcollina for the code review, much appreciated

@cianfoley-nearform
Copy link
Contributor Author

cianfoley-nearform commented Feb 15, 2018 via email

@mihaidma
Copy link
Contributor

@cianfoley-nearform please rebase to solve the conflict changes and we can merge.

Meanwhile also a Hoek fix appeared, hapijs/hoek#230 (comment), we should include also this update to make a quick release.

@mihaidma mihaidma merged commit 978ea10 into master Feb 16, 2018
@mihaidma mihaidma deleted the volume-fixtures-and-autocannon branch February 16, 2018 11:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants