summaryrefslogtreecommitdiffstats
path: root/testcases/VIM
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2015-11-02 18:36:47 +0100
committerMorgan Richomme <morgan.richomme@orange.com>2015-11-02 18:37:44 +0100
commite2f7d3f8c1ce98b2c65c2c8206389b7533e5ba2e (patch)
tree6413b3c9418076eab1104847375cec7587e87b69 /testcases/VIM
parent3c128d2156ed4214f63be7d1b6fe974506f899bf (diff)
add load of functest-img-rally for vm and cinder tests
JIRA: FUNCTEST-94 Change-Id: I959c29eda12709896fdf9c3c4fcd9760b6dfa19b Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'testcases/VIM')
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/run_rally.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally.py b/testcases/VIM/OpenStack/CI/libraries/run_rally.py
index 42ad1f5e4..09ff029d4 100644
--- a/testcases/VIM/OpenStack/CI/libraries/run_rally.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_rally.py
@@ -22,6 +22,7 @@ import logging
import yaml
import requests
import sys
+import novaclient.v2.client as novaclient
""" tests configuration """
tests = ['authenticate', 'glance', 'cinder', 'ceilometer', 'heat', 'keystone',
@@ -74,6 +75,14 @@ RESULTS_DIR = HOME + functest_yaml.get("general").get("directories"). \
get("dir_rally_res") + "/rally/"
TEST_DB = functest_yaml.get("results").get("test_db_url")
+GLANCE_IMAGE_NAME = "functest-img-rally"
+GLANCE_IMAGE_FILENAME = functest_yaml.get("general"). \
+ get("openstack").get("image_file_name")
+GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \
+ get("openstack").get("image_disk_format")
+GLANCE_IMAGE_PATH = functest_yaml.get("general"). \
+ get("directories").get("dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME
+
def push_results_to_db(payload, module):
@@ -105,6 +114,16 @@ def get_task_id(cmd_raw):
return None
+def create_glance_image(path, name, disk_format):
+ """
+ Create a glance image given the absolute path of the image, its name and the disk format
+ """
+ cmd = ("glance image-create --name " + name + " --visibility public "
+ "--disk-format " + disk_format + " --container-format bare --file " + path)
+ functest_utils.execute_command(cmd, logger)
+ return True
+
+
def task_succeed(json_raw):
"""
Parse JSON from rally JSON results
@@ -196,12 +215,41 @@ def run_task(test_name):
.format(test_name))
+def delete_glance_image(name):
+ cmd = ("glance image-delete $(glance image-list | grep %s "
+ "| awk '{print $2}' | head -1)" % name)
+ functest_utils.execute_command(cmd, logger)
+ return True
+
+
+def cleanup(nova):
+ logger.info("Cleaning up...")
+ logger.debug("Deleting image...")
+ delete_glance_image(GLANCE_IMAGE_NAME)
+ return True
+
+
def main():
# configure script
if not (args.test_name in tests):
logger.error('argument not valid')
exit(-1)
+ creds_nova = functest_utils.get_credentials("nova")
+ nova_client = novaclient.Client(**creds_nova)
+
+ logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME, GLANCE_IMAGE_PATH))
+ create_glance_image(GLANCE_IMAGE_PATH, GLANCE_IMAGE_NAME, GLANCE_IMAGE_FORMAT)
+
+ # Check if the given image exists
+ try:
+ nova_client.images.find(name=GLANCE_IMAGE_NAME)
+ logger.info("Glance image found '%s'" % GLANCE_IMAGE_NAME)
+ except:
+ logger.error("ERROR: Glance image '%s' not found." % GLANCE_IMAGE_NAME)
+ logger.info("Available images are: ")
+ exit(-1)
+
if args.test_name == "all":
for test_name in tests:
if not (test_name == 'all' or
@@ -215,5 +263,7 @@ def main():
print(args.test_name)
run_task(args.test_name)
+ cleanup(nova_client)
+
if __name__ == '__main__':
main()