Skip to content

Commit

Permalink
Invalid reference to self in functional test test_scrubber.py
Browse files Browse the repository at this point in the history
In the test_scrubber.py the function wait_for_scrub() makes a
reference to self even tho it is not a member of any class and
has no such reference in its scope.  This patch makes that
function a method in the test class so that it can assert the
failure which it intends.

fixes bug: 1163617

Change-Id: I453c8097363dc2f7577fd807ffe8cbc613078258
  • Loading branch information
John Bresnahan committed Apr 2, 2013
1 parent 0fc6972 commit 07eda70
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions glance/tests/functional/test_scrubber.py
Expand Up @@ -78,7 +78,7 @@ def test_delayed_delete(self):
self.assertEqual(response.status, 200)
self.assertEqual('pending_delete', response['x-image-meta-status'])

wait_for_scrub(path)
self.wait_for_scrub(path)

self.stop_servers()

Expand Down Expand Up @@ -125,7 +125,7 @@ def test_scrubber_app(self):
exitcode, out, err = execute(cmd, raise_error=False)
self.assertEqual(0, exitcode)

wait_for_scrub(path)
self.wait_for_scrub(path)

self.stop_servers()

Expand Down Expand Up @@ -186,7 +186,7 @@ def test_scrubber_app_against_swift(self):
self.assertEqual(0, exitcode)

# ensure the image has been successfully deleted
wait_for_scrub(path)
self.wait_for_scrub(path)

self.stop_servers()

Expand Down Expand Up @@ -252,7 +252,7 @@ def test_scrubber_with_metadata_enc(self):
self.assertEqual("swift+http", loc.scheme)
self.assertEqual(image['id'], loc.obj)

wait_for_scrub(path)
self.wait_for_scrub(path)

self.stop_servers()

Expand Down Expand Up @@ -323,28 +323,27 @@ def test_scrubber_handles_swift_missing(self):
exitcode, out, err = execute(cmd, raise_error=False)
self.assertEqual(0, exitcode)

wait_for_scrub(path)
self.wait_for_scrub(path)

self.stop_servers()


def wait_for_scrub(path):
"""
NOTE(jkoelker) The build servers sometimes take longer than 15 seconds to
scrub. Give it up to 5 min, checking checking every 15 seconds. When/if it
flips to deleted, bail immediatly.
"""
http = httplib2.Http()
wait_for = 300 # seconds
check_every = 15 # seconds
for _ in xrange(wait_for / check_every):
time.sleep(check_every)

response, content = http.request(path, 'HEAD')
if (response['x-image-meta-status'] == 'deleted' and
response['x-image-meta-deleted'] == 'True'):
break
def wait_for_scrub(self, path):
"""
NOTE(jkoelker) The build servers sometimes take longer than 15 seconds
to scrub. Give it up to 5 min, checking checking every 15 seconds.
When/if it flips to deleted, bail immediatly.
"""
http = httplib2.Http()
wait_for = 300 # seconds
check_every = 15 # seconds
for _ in xrange(wait_for / check_every):
time.sleep(check_every)

response, content = http.request(path, 'HEAD')
if (response['x-image-meta-status'] == 'deleted' and
response['x-image-meta-deleted'] == 'True'):
break
else:
continue
else:
continue
else:
self.fail('image was never scrubbed')
self.fail('image was never scrubbed')

0 comments on commit 07eda70

Please sign in to comment.