Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
Merge pull request #240 from mozilla-services/fix-loadtests
Browse files Browse the repository at this point in the history
Fix loadtests
  • Loading branch information
almet committed Apr 2, 2015
2 parents 51cef82 + 698ce3b commit 2cd4e8f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions loadtests/config/megabench.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
users = 20
duration = 1800
include_file = loadtest
config/*
python-dep = konfig
agents = 5
detach = true
observer = irc
Expand Down
4 changes: 3 additions & 1 deletion loadtests/config/smoke.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[loads]
no-dns-resolve = true
include_file = loadtest/*.py, config/*.ini
include_file = loadtest
config/*
python-dep = konfig
smoke = True

# Bearer token on stable.dev.lcip.org readinglist@restmail.net
Expand Down
2 changes: 1 addition & 1 deletion loadtests/config/test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
hits = 100
users = 3
no-dns-resolve = true
include_file = loadtest/*.py
include_file = loadtest
17 changes: 16 additions & 1 deletion loadtests/loadtest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def __init__(self, *args, **kwargs):
This method is called as many times as number of users.
"""
super(TestBasic, self).__init__(*args, **kwargs)
self.conf = Config(self.config['config']).get_map('loads')

self.conf = self._get_configuration()

if self.conf.get('smoke', False):
self.random_user = "test@restmail.net"
self.auth = RawAuth("Bearer %s" % self.conf.get('token'))
Expand All @@ -69,6 +71,19 @@ def __init__(self, *args, **kwargs):
# Create at least some records for this user
self.nb_initial_records = random.randint(3, 100)

def _get_configuration(self):
# Loads is removing the extra information contained in the ini files,
# so we need to parse it again.
config_file = self.config['config']
# When copying the configuration files, we lose the config/ prefix so,
# try to read from this folder in case the file doesn't exist.
if not os.path.isfile(config_file):
config_file = os.path.basename(config_file)
if not os.path.isfile(config_file):
msg = 'Unable to locate the configuration file, aborting.'
raise LookupError(msg)
return Config(config_file).get_map('loads')

def api_url(self, path):
return "{0}/v1/{1}".format(self.server_url, path)

Expand Down

0 comments on commit 2cd4e8f

Please sign in to comment.