Merge lp:~doanac/qa-dashboard/smoke-pull-test into lp:qa-dashboard

Proposed by Andy Doan
Status: Merged
Approved by: Joe Talbott
Approved revision: 696
Merged at revision: 696
Proposed branch: lp:~doanac/qa-dashboard/smoke-pull-test
Merge into: lp:qa-dashboard
Diff against target: 86 lines (+62/-1)
2 files modified
smokeng/management/commands/jenkins_pull_smokeng.py (+1/-1)
smokeng/tests.py (+61/-0)
To merge this branch: bzr merge lp:~doanac/qa-dashboard/smoke-pull-test
Reviewer Review Type Date Requested Status
Joe Talbott Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+197640@code.launchpad.net

Commit message

add some unit testing for the smoke pull script

validates job pattern matching, extract_data, and utah log discovery

Description of the change

I'm about to add the ability to parse multiple utah results from a single jenkins job. To set the stage for that, I wanted to first add some simple unit-testing to help validate the areas in-which I'll be changing code.

This change adds some testing on our smoke pull script.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:696
http://s-jenkins.ubuntu-ci:8080/job/dashboard-ci/273/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/dashboard-ci/273/rebuild

review: Approve (continuous-integration)
Revision history for this message
Joe Talbott (joetalbott) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'smokeng/management/commands/jenkins_pull_smokeng.py'
2--- smokeng/management/commands/jenkins_pull_smokeng.py 2013-12-02 16:37:50 +0000
3+++ smokeng/management/commands/jenkins_pull_smokeng.py 2013-12-04 03:49:14 +0000
4@@ -289,9 +289,9 @@
5
6 logs = []
7
8+ utah_log_regex = re.compile(ur'^(clientlogs\/|)utah.*.yaml')
9 for artifact in artifacts:
10 path = artifact['relativePath']
11- utah_log_regex = re.compile(ur'^(clientlogs\/|)utah.*.yaml')
12 logging.debug(path)
13 if utah_log_regex.match(path):
14 logs.append(artifact)
15
16=== modified file 'smokeng/tests.py'
17--- smokeng/tests.py 2013-11-21 16:58:17 +0000
18+++ smokeng/tests.py 2013-12-04 03:49:14 +0000
19@@ -392,6 +392,67 @@
20 self.assertFalse(self.command._has_media_info(self.build))
21
22
23+class TestPullScript(TestCase):
24+ def testJobNames(self):
25+ '''ensure the job_regex matches everything it should.'''
26+ good = [
27+ 'trusty-touch-mako-smoke-dropping-letters-app-autopilot',
28+ 'saucy-touch_ro-maguro-smoke-master',
29+ 'precise-server-amd64-smoke-default',
30+ 'trusty-desktop-i386-smoke-default',
31+ ]
32+ bad = [
33+ 'foo-touch_ro-maguro-smoke-master', # no such release
34+ 'trusty-touch_ro-maguro-smoke', # no test defined
35+ 'trusty-desktop-i386-smoke-static_validation',
36+ ]
37+
38+ for x in good:
39+ self.assertIsNotNone(Command.job_regex.match(x))
40+ for x in bad:
41+ self.assertIsNone(Command.job_regex.match(x))
42+
43+ def _extract_matches(self, name, expected):
44+ c = Command()
45+ c.extract_data(name)
46+ self.assertDictEqual(expected, c.install_data)
47+
48+ def testExtractData(self):
49+ '''ensure the extract data can populate from the job name.'''
50+ patterns = [
51+ ('saucy-touch_ro-maguro-smoke-master', {
52+ 'arch': 'maguro',
53+ 'release': 'saucy',
54+ 'test_name': 'master',
55+ 'variant': 'touch_ro',
56+ }),
57+ ('trusty-touch-mako-smoke-friends-app-autopilot', {
58+ 'arch': 'mako',
59+ 'release': 'trusty',
60+ 'test_name': 'friends-app-autopilot',
61+ 'variant': 'touch',
62+ }),
63+ ]
64+ for name, data in patterns:
65+ self._extract_matches(name, data)
66+
67+ def testUtahLogs(self):
68+ '''ensure we find the proper patterns of logfile names'''
69+ good = [
70+ {'relativePath': 'utah.yaml'},
71+ {'relativePath': 'clientlogs/utah.yaml'},
72+ ]
73+ bad = [
74+ {'relativePath': 'foo/utah.yaml'},
75+ {'relativePath': 'clientlogs/utah-host.yml'},
76+ {'relativePath': 'clientlogs/test1/utah.yaml'},
77+ {'relativePath': 'clientlogs/test2/utah.yaml'},
78+ ]
79+ c = Command()
80+ logs = c._get_utah_logs(good + bad)
81+ self.assertListEqual(good, logs)
82+
83+
84 class TestSmokeConfig(TestCase):
85
86 def setUp(self):

Subscribers

People subscribed via source and target branches