Set status to 'active' after image is uploaded

Fixes bug 1034787

The recent change I made to image_data and the domain model caused this
bug to regress. This change adds assertions to the functional tests in
the hopes of preventing future regressions.

Change-Id: I02f9a5c51f54c0c778e032500079aa13ab073e3e
This commit is contained in:
Mark J. Washenberger
2013-02-22 15:58:24 -08:00
parent 89d8441d12
commit 85e3b9f160
4 changed files with 19 additions and 3 deletions

View File

@@ -81,6 +81,18 @@ class TestStoreImage(utils.BaseTestCase):
#NOTE(markwash): FakeStore returns image_id for location
self.assertEquals(image.location, UUID2)
self.assertEquals(image.checksum, 'Z')
self.assertEquals(image.status, 'active')
def test_image_set_data_unknown_size(self):
context = glance.context.RequestContext(user=USER1)
image_stub = ImageStub(UUID2, status='queued', location=None)
image = glance.store.ImageProxy(image_stub, context, self.store_api)
image.set_data('YYYY', None)
self.assertEquals(image.size, 4)
#NOTE(markwash): FakeStore returns image_id for location
self.assertEquals(image.location, UUID2)
self.assertEquals(image.checksum, 'Z')
self.assertEquals(image.status, 'active')
def test_image_repo_get(self):
image_repo = glance.store.ImageRepoProxy({}, self.store_api,

View File

@@ -122,13 +122,15 @@ class FakeStoreAPI(object):
for location in self.data.keys():
if image_id in location:
raise exception.Duplicate()
if size and (current_store_size + size) > store_max_size:
if not size:
size = len(data)
if (current_store_size + size) > store_max_size:
raise exception.StorageFull()
if context.user == USER2:
raise exception.Forbidden()
if context.user == USER3:
raise exception.StorageWriteDenied()
self.data[image_id] = (data, size or len(data))
self.data[image_id] = (data, size)
checksum = 'Z'
return (image_id, size, checksum)