Make the use of a ramdisk optional for tests
diff --git a/kong/tests/996_test_glance.py b/kong/tests/996_test_glance.py
index 3fd6b15..01cb110 100644
--- a/kong/tests/996_test_glance.py
+++ b/kong/tests/996_test_glance.py
@@ -77,7 +77,12 @@
"""
Uploads a test initrd to glance api
"""
+ if not 'initrd' in self.config['environment']:
+ self.glance['ramdisk_id'] = None
+ return
+
initrd = self.config['environment']['initrd']
+
if 'apiver' in self.glance:
path = "http://%s:%s/%s/images" % (self.glance['host'],
self.glance['port'], self.glance['apiver'])
@@ -126,10 +131,13 @@
'x-image-meta-container-format': 'ami',
'x-image-meta-property-Kernel_id': '%s' % \
self.glance['kernel_id'],
- 'x-image-meta-property-Ramdisk_id': '%s' % \
- self.glance['ramdisk_id'],
'Content-Length': '%d' % os.path.getsize(image),
'Content-Type': 'application/octet-stream'}
+
+ if self.glance['ramdisk_id']:
+ ramdisk_id = '%s' % self.glance['ramdisk_id']
+ headers['x-image-meta-property-Ramdisk_id'] = ramdisk_id
+
http = httplib2.Http()
response, content = http.request(path, 'POST',
headers=headers,
@@ -152,9 +160,12 @@
headers = {'X-Image-Meta-Property-Distro': 'Ubuntu',
'X-Image-Meta-Property-Arch': 'x86_64',
'X-Image-Meta-Property-Kernel_id': '%s' % \
- self.glance['kernel_id'],
- 'X-Image-Meta-Property-Ramdisk_id': '%s' % \
- self.glance['ramdisk_id']}
+ self.glance['kernel_id']}
+
+ if self.glance['ramdisk_id']:
+ ramdisk_id = '%s' % self.glance['ramdisk_id']
+ headers['X-Image-Meta-Property-Ramdisk_id'] = ramdisk_id
+
http = httplib2.Http()
response, content = http.request(path, 'PUT', headers=headers)
self.assertEqual(response.status, 200)
@@ -163,8 +174,9 @@
self.assertEqual(data['image']['properties']['distro'], "Ubuntu")
self.assertEqual(data['image']['properties']['kernel_id'],
str(self.glance['kernel_id']))
- self.assertEqual(data['image']['properties']['ramdisk_id'],
- str(self.glance['ramdisk_id']))
+ if self.glance['ramdisk_id']:
+ self.assertEqual(data['image']['properties']['ramdisk_id'],
+ str(self.glance['ramdisk_id']))
test_005_set_image_meta_property.tags = ['glance']
def test_006_list_image_metadata(self):
@@ -188,6 +200,7 @@
self.assertEqual(response['x-image-meta-property-distro'], "Ubuntu")
self.assertEqual(response['x-image-meta-property-kernel_id'],
str(self.glance['kernel_id']))
- self.assertEqual(response['x-image-meta-property-ramdisk_id'],
- str(self.glance['ramdisk_id']))
+ if self.glance['ramdisk_id']:
+ self.assertEqual(response['x-image-meta-property-ramdisk_id'],
+ str(self.glance['ramdisk_id']))
test_006_list_image_metadata.tags = ['glance']