Skip to content

Commit

Permalink
Adding tests to check 'glance show <ID>' format
Browse files Browse the repository at this point in the history
Prevent regression on bug 888370

Change-Id: I7dedc31cd19c242af25b8a947dbe936a1ed2eb13
  • Loading branch information
Brian Waldon committed Nov 10, 2011
1 parent 98cefb7 commit 854d66e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions glance/tests/functional/test_bin_glance.py
Expand Up @@ -602,3 +602,54 @@ def test_results_sorting(self):
self.assertTrue(image_lines[1].split()[1], image_ids[2])
self.assertTrue(image_lines[12].split()[1], image_ids[1])
self.assertTrue(image_lines[23].split()[1], image_ids[4])

def test_show_image_format(self):
self.cleanup()
self.start_servers()

api_port = self.api_port
registry_port = self.registry_port

# 1. Add public image
with tempfile.NamedTemporaryFile() as image_file:
image_file.write("XXX")
image_file.flush()
image_file_name = image_file.name
cmd = "bin/glance --port=%d add is_public=True"\
" name=MyImage < %s" % (api_port, image_file_name)

exitcode, out, err = execute(cmd)

self.assertEqual(0, exitcode)
image_id = out.strip().rsplit(' ', 1)[1]

# 2. Verify image added as public image
cmd = "bin/glance --port=%d show %s" % (api_port, image_id)

exitcode, out, err = execute(cmd)

self.assertEqual(0, exitcode)
lines = out.split("\n")[:-1]

expected_lines = [
'URI: http://0.0.0.0:%s/v1/images/%s' % (api_port, image_id),
'Id: %s' % image_id,
'Public: Yes',
'Name: MyImage',
'Status: active',
'Size: 3',
'Disk format: raw',
'Container format: ovf',
'Minimum Ram Required (MB): 0',
'Minimum Disk Required (GB): 0',
]

self.assertGreaterEqual(set(lines), set(expected_lines))

# 3. Delete the image
cmd = "bin/glance --port=%d --force delete %s" % (api_port, image_id)

exitcode, out, err = execute(cmd)

self.assertEqual(0, exitcode)
self.assertEqual('Deleted image %s' % image_id, out.strip())

0 comments on commit 854d66e

Please sign in to comment.