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
=== modified file 'smokeng/management/commands/jenkins_pull_smokeng.py'
--- smokeng/management/commands/jenkins_pull_smokeng.py 2013-12-02 16:37:50 +0000
+++ smokeng/management/commands/jenkins_pull_smokeng.py 2013-12-04 03:49:14 +0000
@@ -289,9 +289,9 @@
289289
290 logs = []290 logs = []
291291
292 utah_log_regex = re.compile(ur'^(clientlogs\/|)utah.*.yaml')
292 for artifact in artifacts:293 for artifact in artifacts:
293 path = artifact['relativePath']294 path = artifact['relativePath']
294 utah_log_regex = re.compile(ur'^(clientlogs\/|)utah.*.yaml')
295 logging.debug(path)295 logging.debug(path)
296 if utah_log_regex.match(path):296 if utah_log_regex.match(path):
297 logs.append(artifact)297 logs.append(artifact)
298298
=== modified file 'smokeng/tests.py'
--- smokeng/tests.py 2013-11-21 16:58:17 +0000
+++ smokeng/tests.py 2013-12-04 03:49:14 +0000
@@ -392,6 +392,67 @@
392 self.assertFalse(self.command._has_media_info(self.build))392 self.assertFalse(self.command._has_media_info(self.build))
393393
394394
395class TestPullScript(TestCase):
396 def testJobNames(self):
397 '''ensure the job_regex matches everything it should.'''
398 good = [
399 'trusty-touch-mako-smoke-dropping-letters-app-autopilot',
400 'saucy-touch_ro-maguro-smoke-master',
401 'precise-server-amd64-smoke-default',
402 'trusty-desktop-i386-smoke-default',
403 ]
404 bad = [
405 'foo-touch_ro-maguro-smoke-master', # no such release
406 'trusty-touch_ro-maguro-smoke', # no test defined
407 'trusty-desktop-i386-smoke-static_validation',
408 ]
409
410 for x in good:
411 self.assertIsNotNone(Command.job_regex.match(x))
412 for x in bad:
413 self.assertIsNone(Command.job_regex.match(x))
414
415 def _extract_matches(self, name, expected):
416 c = Command()
417 c.extract_data(name)
418 self.assertDictEqual(expected, c.install_data)
419
420 def testExtractData(self):
421 '''ensure the extract data can populate from the job name.'''
422 patterns = [
423 ('saucy-touch_ro-maguro-smoke-master', {
424 'arch': 'maguro',
425 'release': 'saucy',
426 'test_name': 'master',
427 'variant': 'touch_ro',
428 }),
429 ('trusty-touch-mako-smoke-friends-app-autopilot', {
430 'arch': 'mako',
431 'release': 'trusty',
432 'test_name': 'friends-app-autopilot',
433 'variant': 'touch',
434 }),
435 ]
436 for name, data in patterns:
437 self._extract_matches(name, data)
438
439 def testUtahLogs(self):
440 '''ensure we find the proper patterns of logfile names'''
441 good = [
442 {'relativePath': 'utah.yaml'},
443 {'relativePath': 'clientlogs/utah.yaml'},
444 ]
445 bad = [
446 {'relativePath': 'foo/utah.yaml'},
447 {'relativePath': 'clientlogs/utah-host.yml'},
448 {'relativePath': 'clientlogs/test1/utah.yaml'},
449 {'relativePath': 'clientlogs/test2/utah.yaml'},
450 ]
451 c = Command()
452 logs = c._get_utah_logs(good + bad)
453 self.assertListEqual(good, logs)
454
455
395class TestSmokeConfig(TestCase):456class TestSmokeConfig(TestCase):
396457
397 def setUp(self):458 def setUp(self):

Subscribers

People subscribed via source and target branches