diff options
Diffstat (limited to 'testcases')
-rwxr-xr-x | testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py | 54 | ||||
-rw-r--r-- | testcases/functest_utils.py | 30 |
2 files changed, 77 insertions, 7 deletions
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py index d2128d9ac..d2ac62ac1 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): @@ -218,10 +221,22 @@ def run_task(test_name): p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, stderr=RALLY_STDERR, shell=True) result = "" while p.poll() is None: - l = p.stdout.readline() - print l.replace('\n', '') - result += l - + #l = p.stdout.readline() + #line = l.replace('\n', '') + line = p.stdout.readline() + if "Load duration" in line or \ + "started" in line or \ + "finished" in line or \ + " Preparing" in line or \ + "+-" in line or \ + "|" in line: + result += line + elif "test scenario" in line: + result += "\n" + line + elif "Full duration" in line: + result += line + "\n\n" + + logger.info("\n" + result) task_id = get_task_id(result) logger.debug('task_id : {}'.format(task_id)) @@ -262,9 +277,9 @@ def run_task(test_name): """ parse JSON operation result """ if task_succeed(json_results): - print 'Test OK' + logger.info("Test OK.") else: - print 'Test KO' + logger.info("Test Failed.") def main(): @@ -283,9 +298,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 == '': @@ -307,7 +341,6 @@ def main(): for test_name in tests: if not (test_name == 'all' or test_name == 'vm'): - print(test_name) run_task(test_name) else: print(args.test_name) @@ -318,5 +351,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 |