Merge "Add checksum to an external image during add."

This commit is contained in:
Jenkins 2012-02-27 23:31:10 +00:00 committed by Gerrit Code Review
commit b563deb797
2 changed files with 66 additions and 0 deletions

View File

@ -247,6 +247,8 @@ EXAMPLES
if 'location' in fields.keys():
source = fields.pop('location')
image_meta['location'] = source
if 'checksum' in fields.keys():
image_meta['checksum'] = fields.pop('checksum')
elif 'copy_from' in fields.keys():
source = fields.pop('copy_from')
features['x-glance-api-copy-from'] = source

View File

@ -448,6 +448,70 @@ class TestBinGlance(functional.FunctionalTest):
self.stop_servers()
@functional.runs_sql
def test_add_location_with_checksum(self):
"""
We test the following:
1. Add an image with location and checksum
2. Run SQL against DB to verify checksum was entered correctly
"""
self.cleanup()
self.start_servers(**self.__dict__.copy())
api_port = self.api_port
registry_port = self.registry_port
# 1. Add public image
cmd = minimal_add_command(api_port,
'MyImage',
'location=http://example.com checksum=1')
exitcode, out, err = execute(cmd)
self.assertEqual(0, exitcode)
self.assertTrue(out.strip().startswith('Added new image with ID:'))
image_id = out.split(":")[1].strip()
sql = 'SELECT checksum FROM images WHERE id = "%s"' % image_id
recs = self.run_sql_cmd(sql)
self.assertEqual('1', recs.first()[0])
self.stop_servers()
@functional.runs_sql
def test_add_location_without_checksum(self):
"""
We test the following:
1. Add an image with location and no checksum
2. Run SQL against DB to verify checksum is NULL
"""
self.cleanup()
self.start_servers(**self.__dict__.copy())
api_port = self.api_port
registry_port = self.registry_port
# 1. Add public image
cmd = minimal_add_command(api_port,
'MyImage',
'location=http://example.com')
exitcode, out, err = execute(cmd)
self.assertEqual(0, exitcode)
self.assertTrue(out.strip().startswith('Added new image with ID:'))
image_id = out.split(":")[1].strip()
sql = 'SELECT checksum FROM images WHERE id = "%s"' % image_id
recs = self.run_sql_cmd(sql)
self.assertEqual(None, recs.first()[0])
self.stop_servers()
@functional.runs_sql
def test_add_clear(self):
"""