Merge lp:~joetalbott/britney/fetch_exception_handling into lp:~canonical-ci-engineering/britney/boottesting-support

Proposed by Joe Talbott
Status: Merged
Merged at revision: 457
Proposed branch: lp:~joetalbott/britney/fetch_exception_handling
Merge into: lp:~canonical-ci-engineering/britney/boottesting-support
Diff against target: 34 lines (+12/-1)
2 files modified
boottest.py (+7/-1)
tests/test_boottest.py (+5/-0)
To merge this branch: bzr merge lp:~joetalbott/britney/fetch_exception_handling
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Vincent Ladeuil (community) Approve
Review via email: mp+248784@code.launchpad.net

Commit message

boottest - Add exception handling for manifest fetching.

Description of the change

boottest - Add exception handling for manifest fetching.

To post a comment you must log in.
457. By Joe Talbott

boottest - Add exception handling for manifest fetching

Revision history for this message
Vincent Ladeuil (vila) wrote :

Small tweaks in the inline comments, thanks for the speedy MP !

review: Approve
458. By Joe Talbott

boottest - Add exception message to warning print and fix typo

Revision history for this message
Celso Providelo (cprov) :
review: Needs Fixing
459. By Joe Talbott

Don't bother creating another mocked urllib.urlopen.

Revision history for this message
Celso Providelo (cprov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'boottest.py'
2--- boottest.py 2015-02-05 13:15:07 +0000
3+++ boottest.py 2015-02-05 22:22:26 +0000
4@@ -79,7 +79,13 @@
5 "I: [%s] - Fetching manifest from %s" % (
6 time.asctime(), url))
7 print("I: [%s] - saving it to %s" % (time.asctime(), self.path))
8- response = urllib.urlopen(url)
9+ try:
10+ response = urllib.urlopen(url)
11+ except IOError as e:
12+ print("W: [%s] - error connecting to %s: %s" % (
13+ time.asctime(), self.path, e))
14+ return success # failure
15+
16 # Only [re]create the manifest file if one was successfully downloaded
17 # this allows for an existing image to be used if the download fails.
18 if response.code == 200:
19
20=== modified file 'tests/test_boottest.py'
21--- tests/test_boottest.py 2015-02-05 14:43:23 +0000
22+++ tests/test_boottest.py 2015-02-05 22:22:26 +0000
23@@ -89,6 +89,11 @@
24 self.assertEqual(1, len(manifest._manifest))
25 self.assertIn('foo', manifest)
26
27+ def test_fetch_exception(self):
28+ self.mocked_urlopen.side_effect = [IOError("connection refused")]
29+ manifest = boottest.TouchManifest('not-real', 'not-real')
30+ self.assertEqual(0, len(manifest._manifest))
31+
32 def test_simple(self):
33 # Existing manifest file allows callsites to properly check presence.
34 manifest_dir = os.path.join(self.imagesdir, 'ubuntu/vivid')

Subscribers

People subscribed via source and target branches