aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Kosonen <juha.kosonen@nokia.com>2016-01-27 23:56:46 +0000
committerMorgan Richomme <morgan.richomme@orange.com>2016-01-28 07:46:20 +0000
commitada8e6155d24866ce5d453a940f68b47bde707c5 (patch)
tree46efd54fb052d0668d61330b5af6f39d358c77bc
parent2f66c60ff09bd1f3505ba276b151eb6f6a2d90b1 (diff)
Volume type management moved from run_tests.sh to run_rally-cert.py
Change-Id: I80c8b27e041ec5089b816b8515cbc8fa1e8b9eea Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com> (cherry picked from commit 9922669c3dd92d43c6e387c8077255153c35b71e)
-rwxr-xr-xdocker/run_tests.sh2
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/run_rally-cert.py29
-rw-r--r--testcases/functest_utils.py30
3 files changed, 59 insertions, 2 deletions
diff --git a/docker/run_tests.sh b/docker/run_tests.sh
index 7c5349ae2..d24a00948 100755
--- a/docker/run_tests.sh
+++ b/docker/run_tests.sh
@@ -125,10 +125,8 @@ function run_test(){
;;
"rally")
info "Running Rally benchmark suite..."
- cinder type-create volume-test #provisional
python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \
--debug all ${report}
- cinder type-delete $(cinder type-list|grep test|awk '{print $2}')
clean_openstack
;;
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
index d2128d9ac..a0304519b 100755
--- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
@@ -27,6 +27,7 @@ from novaclient import client as novaclient
from glanceclient import client as glanceclient
from keystoneclient.v2_0 import client as keystoneclient
from neutronclient.v2_0 import client as neutronclient
+from cinderclient import client as cinderclient
""" tests configuration """
tests = ['authenticate', 'glance', 'cinder', 'heat', 'keystone',
@@ -119,6 +120,8 @@ GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \
GLANCE_IMAGE_PATH = functest_yaml.get("general"). \
get("directories").get("dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME
+CINDER_VOLUME_TYPE_NAME = "volume_test"
+
def push_results_to_db(payload):
@@ -283,9 +286,28 @@ def main():
endpoint_type='publicURL')
glance_client = glanceclient.Client(1, glance_endpoint,
token=keystone_client.auth_token)
+ creds_cinder = functest_utils.get_credentials("cinder")
+ cinder_client = cinderclient.Client('2',creds_cinder['username'],
+ creds_cinder['api_key'],
+ creds_cinder['project_id'],
+ creds_cinder['auth_url'],
+ service_type="volume")
client_dict['neutron'] = neutron_client
+ volume_types = functest_utils.list_volume_types(cinder_client, private=False)
+ if not volume_types:
+ volume_type = functest_utils.create_volume_type(cinder_client, \
+ CINDER_VOLUME_TYPE_NAME)
+ if not volume_type:
+ logger.error("Failed to create volume type...")
+ exit(-1)
+ else:
+ logger.debug("Volume type '%s' created succesfully..." \
+ % CINDER_VOLUME_TYPE_NAME)
+ else:
+ logger.debug("Using existing volume type(s)...")
+
image_id = functest_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
if image_id == '':
@@ -318,5 +340,12 @@ def main():
if not functest_utils.delete_glance_image(nova_client, image_id):
logger.error("Error deleting the glance image")
+ if not volume_types:
+ logger.debug("Deleting volume type '%s'..." \
+ % CINDER_VOLUME_TYPE_NAME)
+ if not functest_utils.delete_volume_type(cinder_client, volume_type):
+ logger.error("Error in deleting volume type...")
+
+
if __name__ == '__main__':
main()
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index bbe933ab8..b3549ee93 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -544,6 +544,36 @@ def delete_volume(cinder_client, volume_id, forced=False):
return False
+def list_volume_types(cinder_client, public=True, private=True):
+ try:
+ volume_types = cinder_client.volume_types.list()
+ if not public:
+ volume_types = [vt for vt in volume_types if not vt.is_public]
+ if not private:
+ volume_types = [vt for vt in volume_types if vt.is_public]
+ return volume_types
+ except:
+ return None
+
+
+def create_volume_type(cinder_client, name):
+ try:
+ volume_type = cinder_client.volume_types.create(name)
+ return volume_type
+ except:
+ print "Error:", sys.exc_info()[0]
+ return None
+
+
+def delete_volume_type(cinder_client, volume_type):
+ try:
+ cinder_client.volume_types.delete(volume_type)
+ return True
+ except:
+ print "Error:", sys.exc_info()[0]
+ return False
+
+
#*********************************************
# KEYSTONE