summaryrefslogtreecommitdiffstats
path: root/bitbake
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:58:08 +0100
commitce2336ddc7efa60e919f69eb7d23e562e5d867a4 (patch)
treee0e2e68a9dc631af2bd1fa739eb80ab910d6d671 /bitbake
parent5b8c5ea151b1189d50ffa4f8004fa869d790bbf2 (diff)
downloadpoky-ce2336ddc7efa60e919f69eb7d23e562e5d867a4.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: fa4b483c7077637427c7fac5da23ae5de27f554d) Signed-off-by: Ionut Chisanovici <ionutx.chisanovici@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-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