Merge lp:~reldan/glance/fix_logging_in_swift into lp:~glance-coresec/glance/cactus-trunk

Proposed by Eldar Nugaev
Status: Merged
Approved by: Jay Pipes
Approved revision: no longer in the source branch.
Merged at revision: 111
Proposed branch: lp:~reldan/glance/fix_logging_in_swift
Merge into: lp:~glance-coresec/glance/cactus-trunk
Diff against target: 79 lines (+39/-3)
2 files modified
glance/store/swift.py (+3/-3)
tests/unit/test_swift_store.py (+36/-0)
To merge this branch: bzr merge lp:~reldan/glance/fix_logging_in_swift
Reviewer Review Type Date Requested Status
Thierry Carrez (community) Approve
Devin Carlen (community) Approve
Rick Harris (community) Needs Fixing
Jay Pipes (community) Approve
Review via email: mp+57196@code.launchpad.net

Description of the change

Fix logging in swift

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

thanks, Eldar! lgtm.

review: Approve
108. By Soren Hansen

Add the migration sql scripts to MANIFEST.in. The gets them included in not only the tarball, but also by setup.py install.

Revision history for this message
Rick Harris (rconradharris) wrote :

Really nice job, Eldar.

> 46 + image_swift = StringIO.StringIO("nevergonnamakeit")
> 47 + options = SWIFT_OPTIONS.copy()
> 48 + del options['swift_store_user']
> 49 + self.assertRaises(BackendException,
> 50 + SwiftBackend.add,
> 51 + 2, image_swift, options)

Might be better to DRY up the code some by adding a helper-method, like:

def assertOptionRequiredForSwift(self, key):
  image_swift = StringIO.StringIO("nevergonnamakeit")
  options = SWIFT_OPTIONS.copy()
  del options[key]
  self.assertRaises(BackendException,
    SwiftBackend.add,
    2, image_swift, options)

Marking as Needs Fixing, but if you don't like the idea, I'd be willing to set this as Approved (since the suggestion is so minor :-)

review: Needs Fixing
109. By Jay Pipes

Fix up the way the exception is raised from _safe_kill()... When I "fixed" bug 729726, I mistakenly used the traceback as the message. doh.

Revision history for this message
Devin Carlen (devcamcar) wrote :

agree with Jay's suggestion, but I'll approve for now.

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

s/Jay/Rick

Revision history for this message
Thierry Carrez (ttx) wrote :

LGTM... Getting late, so i wouldn't be too picky on the test style :)

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

agreed. Rick, I'm pushing this through... we can always refactor the test for DRY later.

110. By Jay Pipes

Change parsing of headers to accept 'True', 'on', 1 for boolean truth values.

111. By Eldar Nugaev

Fix logging in swift

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'glance/store/swift.py'
2--- glance/store/swift.py 2011-03-23 14:16:10 +0000
3+++ glance/store/swift.py 2011-04-11 16:55:55 +0000
4@@ -111,9 +111,9 @@
5 # should be a stateful object with options parsed once in
6 # a constructor.
7 if not auth_address:
8- logger.error(msg)
9 msg = ("Could not find swift_store_auth_address in configuration "
10 "options.")
11+ logger.error(msg)
12 raise glance.store.BackendException(msg)
13 else:
14 full_auth_address = auth_address
15@@ -121,15 +121,15 @@
16 full_auth_address = 'https://' + full_auth_address
17
18 if not user:
19- logger.error(msg)
20 msg = ("Could not find swift_store_user in configuration "
21 "options.")
22+ logger.error(msg)
23 raise glance.store.BackendException(msg)
24
25 if not key:
26- logger.error(msg)
27 msg = ("Could not find swift_store_key in configuration "
28 "options.")
29+ logger.error(msg)
30 raise glance.store.BackendException(msg)
31
32 swift_conn = swift_client.Connection(
33
34=== modified file 'tests/unit/test_swift_store.py'
35--- tests/unit/test_swift_store.py 2011-03-23 14:16:10 +0000
36+++ tests/unit/test_swift_store.py 2011-04-11 16:55:55 +0000
37@@ -324,6 +324,42 @@
38 SwiftBackend.add,
39 2, image_swift, SWIFT_OPTIONS)
40
41+ def test_add_no_user(self):
42+ """
43+ Tests that adding options without user raises
44+ an appropriate exception
45+ """
46+ image_swift = StringIO.StringIO("nevergonnamakeit")
47+ options = SWIFT_OPTIONS.copy()
48+ del options['swift_store_user']
49+ self.assertRaises(BackendException,
50+ SwiftBackend.add,
51+ 2, image_swift, options)
52+
53+ def test_no_key(self):
54+ """
55+ Tests that adding options without key raises
56+ an appropriate exception
57+ """
58+ image_swift = StringIO.StringIO("nevergonnamakeit")
59+ options = SWIFT_OPTIONS.copy()
60+ del options['swift_store_key']
61+ self.assertRaises(BackendException,
62+ SwiftBackend.add,
63+ 2, image_swift, options)
64+
65+ def test_add_no_auth_address(self):
66+ """
67+ Tests that adding options without auth address raises
68+ an appropriate exception
69+ """
70+ image_swift = StringIO.StringIO("nevergonnamakeit")
71+ options = SWIFT_OPTIONS.copy()
72+ del options['swift_store_auth_address']
73+ self.assertRaises(BackendException,
74+ SwiftBackend.add,
75+ 2, image_swift, options)
76+
77 def test_delete(self):
78 """
79 Test we can delete an existing image in the swift store

Subscribers

People subscribed via source and target branches