Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Locust.io load testing script #1188

Merged
merged 2 commits into from
Mar 9, 2017
Merged

Add Locust.io load testing script #1188

merged 2 commits into from
Mar 9, 2017

Conversation

monfresh
Copy link
Contributor

@monfresh monfresh commented Mar 8, 2017

Why: To document and share the scripts we use.

**Why**: To document and share the scripts we use.
fancy_echo "Upgrading %s ..." "$1"
brew upgrade "$@"
else
fancy_echo "Already using the latest version of %s. Skipping ..." "$1"
Copy link
Contributor

Choose a reason for hiding this comment

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

I have not seen this fancy_echo/printf pattern before in bash, why not just interpolate?

"Already using the latest version of $1. Skipping ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I grabbed it from the laptop script. It adds a newline before and after the text. So, instead of manually adding the newlines every time you need them, you can use the helper method.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it!

bin/load_test Outdated
brew_install_or_upgrade 'libevent'
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv locust && \
workon locust && \
Copy link
Contributor

Choose a reason for hiding this comment

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

What about indenting these lines that are a continuation via \?

mkvirtualenv locust && \
  workon locust && \
  pip install -r scripts/load_testing/requirements.txt && \
  ...

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 idea.


# capture email confirmation link on resulting page
dom = pyquery.PyQuery(resp.content)
link = dom.find('a')[2].attrib['href']
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add an ID or something to this href in our app so it's less brittle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great idea!


# visit enter passcode page and submit pre-filled OTP
dom = pyquery.PyQuery(resp.content)
auth_token = dom.find('input[name="authenticity_token"]')[0].attrib['value']
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we repeat the authenticity token blurb a few times, WDYT of a helper function for authenticity token?

def authenticity_token(dom):
  return dom.find('input[name="authenticity_token"]')[0].attrib['value']

data = {
  'code': otp_code,
  'authenticity_token': authenticity_token(dom),
  'commit': 'Submit'
}

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 idea

@monfresh
Copy link
Contributor Author

monfresh commented Mar 8, 2017

Addressed feedback here: 39c6c17

PTAL

Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM! thanks

@monfresh monfresh merged commit 59e34df into master Mar 9, 2017
@monfresh monfresh deleted the mb-load-testing branch March 9, 2017 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants