summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
authorIonut Chisanovici <ionutx.chisanovici@intel.com>2014-05-28 15:52:26 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-06-20 14:03:58 +0100
commit457091dc5650d92b2d6bc99cc37b4f1118606a0e (patch)
tree705b421ab785a85699fbe689713dced7859b1d46 /bitbake/lib/toaster
parent7ccbea9ea54c82041cf7b2299c88024adfc87036 (diff)
downloadpoky-457091dc5650d92b2d6bc99cc37b4f1118606a0e.tar.gz
bitbake: toaster: Add performance testing script
This is implemented as a django management command. For the moment the 'manage.py perf' command will track the toaster 'gui' urls http response code and load time. To use it: 1. do your toaster builds 2. ensure toaster is started 1. cd bitbake/lib/toaster 2. ln -s ../../../build/toaster.sqlite 3. ./manage.py perf (Bitbake rev: 4a1fc6851d21500150715f0e8fa03c0b228ec5f2) Signed-off-by: Ionut Chisanovici <ionutx.chisanovici@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r--bitbake/lib/toaster/toastermain/management/commands/perf.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastermain/management/commands/perf.py b/bitbake/lib/toaster/toastermain/management/commands/perf.py
new file mode 100644
index 0000000000..d28f26ab16
--- /dev/null
+++ b/bitbake/lib/toaster/toastermain/management/commands/perf.py
@@ -0,0 +1,53 @@
1from django.core.management.base import BaseCommand
2from django.test.client import Client
3import os, sys, re
4import requests
5import toastermain.settings as settings
6
7class Command(BaseCommand):
8 help = "Test the response time for all toaster urls"
9
10 def handle(self, *args, **options):
11 root_urlconf = __import__(settings.ROOT_URLCONF)
12 patterns = root_urlconf.urls.urlpatterns
13 global full_url
14 for pat in patterns:
15 if pat.__class__.__name__ == 'RegexURLResolver':
16 url_root_res = str(pat).split('^')[1].replace('>', '')
17 if 'gui' in url_root_res:
18 for url_patt in pat.url_patterns:
19 full_url = self.get_full_url(url_patt, url_root_res)
20 info = self.url_info(full_url)
21 status_code = info[0]
22 load_time = info[1]
23 print 'Trying \'' + full_url + '\', ' + str(status_code) + ', ' + str(load_time)
24
25 def get_full_url(self, url_patt, url_root_res):
26 full_url = str(url_patt).split('^')[1].replace('$>', '').replace('(?P<file_path>(?:/[', '/bin/busybox').replace('.*', '')
27 full_url = str(url_root_res + full_url)
28 full_url = re.sub('\(\?P<.*?>\\\d\+\)', '1', full_url)
29 full_url = 'http://localhost:8000/' + full_url
30 return full_url
31
32 def url_info(self, full_url):
33 client = Client()
34 info = []
35 try:
36 resp = client.get(full_url, follow = True)
37 except Exception as e_status_code:
38 self.error('Url: %s, error: %s' % (full_url, e_status_code))
39 resp = type('object', (), {'status_code':0, 'content': str(e_status_code)})
40 status_code = resp.status_code
41 info.append(status_code)
42 try:
43 req = requests.get(full_url)
44 except Exception as e_load_time:
45 self.error('Url: %s, error: %s' % (full_url, e_load_time))
46 load_time = req.elapsed
47 info.append(load_time)
48 return info
49
50 def error(self, *args):
51 for arg in args:
52 print >>sys.stderr, arg,
53 print >>sys.stderr