Skip to content

Commit

Permalink
Merge pull request #30 from mozilla-services/add-load-tests
Browse files Browse the repository at this point in the history
Import load tests from Reading List
  • Loading branch information
leplatrem committed Jun 10, 2015
2 parents 6392b08 + efd348a commit de09bc7
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
- TOX_ENV=py34
- TOX_ENV=flake8
- TOX_ENV=docs
- ACTION=loadtest
before_script:
- psql -c "CREATE DATABASE testdb ENCODING 'UTF8' TEMPLATE template0;" -U postgres
before_install:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ clean:
find . -name '__pycache__' -type d -exec rm -fr {} \;

loadtest-check: install
$(VENV)/bin/cliquet --ini loadtests/server.ini migrate > kinto.log &&\
$(VENV)/bin/pserve loadtests/server.ini > kinto.log & PID=$$! && \
rm kinto.log || cat kinto.log; \
sleep 1 && cd loadtests && \
Expand Down
2 changes: 1 addition & 1 deletion app.wsgi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ except ImportError:
import logging.config
import os

from readinglist import main
from kinto import main

here = os.path.dirname(__file__)

Expand Down
20 changes: 20 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,23 @@ IRC channel
===========

Join ``#storage`` on ``irc.mozilla.org``!


Run load tests
==============

From the :file:`loadtests` folder:

::

make test SERVER_URL=http://localhost:8888


Run a particular type of action instead of random:

::

LOAD_ACTION=batch_create make test SERVER_URL=http://localhost:8888

(*See loadtests source code for an exhaustive list of available actions and
their respective randomness.*)
51 changes: 51 additions & 0 deletions loadtests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
SERVER_URL = https://kinto.stage.mozaws.net:443
VIRTUALENV=virtualenv
VENV := $(shell echo $${VIRTUAL_ENV-.venv})
PYTHON=$(VENV)/bin/python

TEST_SUITE = loadtest.TestBasic.test_all

# Hackety-hack around OSX system python bustage.
# The need for this should go away with a future osx/xcode update.
ARCHFLAGS = -Wno-error=unused-command-line-argument-hard-error-in-future
INSTALL = ARCHFLAGS=$(ARCHFLAGS) $(VENV)/bin/pip install

.PHONY: install clean bench megabench

$(PYTHON):
$(VIRTUALENV) $(VENV)


# Build virtualenv, to ensure we have all the dependencies.
.env.install: $(PYTHON)
$(INSTALL) git+git://github.com/mozilla-services/loads.git >> loadtest.log && \
rm loadtest.log || cat loadtest.log
touch $@

install: .env.install

# Clean all the things installed by `make build`.
clean:
rm -rf .venv *.pyc .env.install

# Run a single test from the venv machine, for sanity-checking.
test: install
$(VENV)/bin/loads-runner --config=./config/test.ini --server-url=$(SERVER_URL) $(TEST_SUITE)

# Run a bench of 20 concurrent users.
bench:
$(VENV)/bin/loads-runner --config=./config/bench.ini --server-url=$(SERVER_URL) $(TEST_SUITE)

# Run a much bigger bench, by submitting to broker in AWS.
megabench:
$(VENV)/bin/loads-runner --config=./config/megabench.ini --user-id=$(USER) --server-url=$(SERVER_URL) $(TEST_SUITE)

smoke:
$(VENV)/bin/loads-runner --config=./config/smoke.ini --user-id=$(USER) --server-url=$(SERVER_URL) $(TEST_SUITE)

# Purge any currently-running loadtest runs.
purge:
$(VENV)/bin/loads-runner --config=./config/megabench.ini --purge-broker

attach:
$(VENV)/bin/loads-runner --config=./config/megabench.ini --attach
5 changes: 5 additions & 0 deletions loadtests/config/bench.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[loads]
users = 20
duration = 600
no-dns-resolve = true
include_file = loadtest/*.py
12 changes: 12 additions & 0 deletions loadtests/config/megabench.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[loads]
users = 20
duration = 1800
include_file = loadtest
config/*
python-dep = konfig
agents = 5
detach = true
observer = irc
ssh = ubuntu@loads.services.mozilla.com
no-dns-resolve = true
broker = tcp://172.31.44.86:7780
16 changes: 16 additions & 0 deletions loadtests/config/smoke.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[loads]
no-dns-resolve = true
include_file = loadtest
config/*
python-dep = konfig
smoke = True
test_dir = .

# Bearer token on stable.dev.lcip.org kinto@restmail.net
# token = 82ab7abb4bf90ffaa85a3d1fca169824fa14072016298e2c2671a49a96e2ff5d

# Bearer token on accounts.stage.mozaws.net kinto@restmail.net
token = 05aa9446c83ba39ebf2a4e14477089fd1ff30fd49cce202a5b4d75d0a1ed1cf1

# Bearer token on accounts.firefox.com kinto@restmail.net
# token = 78aeadbe1d6fad8f92fb94ebed287db1afee7a06d2c775684e6322e1e787e89a
5 changes: 5 additions & 0 deletions loadtests/config/test.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[loads]
hits = 100
users = 3
no-dns-resolve = true
include_file = loadtest

0 comments on commit de09bc7

Please sign in to comment.