summaryrefslogtreecommitdiffstats
path: root/testcases/VIM/OpenStack/CI/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/VIM/OpenStack/CI/libraries')
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/clean_openstack.py66
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/generate_defaults.py30
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/run_rally-cert.py32
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/run_rally.py288
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/run_tempest.py21
5 files changed, 74 insertions, 363 deletions
diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
index e47750052..8ea08b49d 100644
--- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
+++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
@@ -57,7 +57,7 @@ if not os.path.exists(REPO_PATH):
logger.error("Functest repository directory not found '%s'" % REPO_PATH)
exit(-1)
sys.path.append(REPO_PATH + "testcases/")
-import functest_utils
+import openstack_utils
DEFAULTS_FILE = '/home/opnfv/functest/conf/os_defaults.yaml'
@@ -85,7 +85,7 @@ def separator():
def remove_instances(nova_client):
logger.info("Removing Nova instances...")
- instances = functest_utils.get_instances(nova_client)
+ instances = openstack_utils.get_instances(nova_client)
if instances is None or len(instances) == 0:
logger.debug("No instances found.")
return
@@ -94,7 +94,7 @@ def remove_instances(nova_client):
instance_name = getattr(instance, 'name')
instance_id = getattr(instance, 'id')
logger.debug("Removing instance '%s', ID=%s ..." % (instance_name,instance_id))
- if functest_utils.delete_instance(nova_client, instance_id):
+ if openstack_utils.delete_instance(nova_client, instance_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the "
@@ -102,7 +102,7 @@ def remove_instances(nova_client):
timeout = 50
while timeout > 0:
- instances = functest_utils.get_instances(nova_client)
+ instances = openstack_utils.get_instances(nova_client)
if instances is None or len(instances) == 0:
break
else:
@@ -113,7 +113,7 @@ def remove_instances(nova_client):
def remove_images(nova_client):
logger.info("Removing Glance images...")
- images = functest_utils.get_images(nova_client)
+ images = openstack_utils.get_images(nova_client)
if images is None or len(images) == 0:
logger.debug("No images found.")
return
@@ -124,7 +124,7 @@ def remove_images(nova_client):
logger.debug("'%s', ID=%s " %(image_name,image_id))
if image_id not in default_images:
logger.debug("Removing image '%s', ID=%s ..." % (image_name,image_id))
- if functest_utils.delete_glance_image(nova_client, image_id):
+ if openstack_utils.delete_glance_image(nova_client, image_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the"
@@ -135,7 +135,7 @@ def remove_images(nova_client):
def remove_volumes(cinder_client):
logger.info("Removing Cinder volumes...")
- volumes = functest_utils.get_volumes(cinder_client)
+ volumes = openstack_utils.get_volumes(cinder_client)
if volumes is None or len(volumes) == 0:
logger.debug("No volumes found.")
return
@@ -146,11 +146,11 @@ def remove_volumes(cinder_client):
logger.debug("'%s', ID=%s " %(volume_name,volume_id))
if volume_id not in default_volumes:
logger.debug("Removing cinder volume %s ..." % volume_id)
- if functest_utils.delete_volume(cinder_client, volume_id):
+ if openstack_utils.delete_volume(cinder_client, volume_id):
logger.debug(" > Done!")
else:
logger.debug("Trying forced removal...")
- if functest_utils.delete_volume(cinder_client,
+ if openstack_utils.delete_volume(cinder_client,
volume_id,
forced=True):
logger.debug(" > Done!")
@@ -162,7 +162,7 @@ def remove_volumes(cinder_client):
def remove_floatingips(nova_client):
logger.info("Removing floating IPs...")
- floatingips = functest_utils.get_floating_ips(nova_client)
+ floatingips = openstack_utils.get_floating_ips(nova_client)
if floatingips is None or len(floatingips) == 0:
logger.debug("No floating IPs found.")
return
@@ -175,7 +175,7 @@ def remove_floatingips(nova_client):
logger.debug("'%s', ID=%s " %(fip_ip,fip_id))
if fip_id not in default_floatingips:
logger.debug("Removing floating IP %s ..." % fip_id)
- if functest_utils.delete_floating_ip(nova_client, fip_id):
+ if openstack_utils.delete_floating_ip(nova_client, fip_id):
logger.debug(" > Done!")
deleted += 1
else:
@@ -187,7 +187,7 @@ def remove_floatingips(nova_client):
timeout = 50
while timeout > 0:
- floatingips = functest_utils.get_floating_ips(nova_client)
+ floatingips = openstack_utils.get_floating_ips(nova_client)
if floatingips is None or len(floatingips) == (init_len - deleted):
break
else:
@@ -199,7 +199,7 @@ def remove_floatingips(nova_client):
def remove_networks(neutron_client):
logger.info("Removing Neutron objects")
network_ids = []
- networks = functest_utils.get_network_list(neutron_client)
+ networks = openstack_utils.get_network_list(neutron_client)
if networks == None:
logger.debug("There are no networks in the deployment. ")
else:
@@ -217,14 +217,14 @@ def remove_networks(neutron_client):
network_ids.append(net_id)
#delete ports
- ports = functest_utils.get_port_list(neutron_client)
+ ports = openstack_utils.get_port_list(neutron_client)
if ports is None:
logger.debug("There are no ports in the deployment. ")
else:
remove_ports(neutron_client, ports, network_ids)
#remove routers
- routers = functest_utils.get_router_list(neutron_client)
+ routers = openstack_utils.get_router_list(neutron_client)
if routers is None:
logger.debug("There are no routers in the deployment. ")
else:
@@ -234,7 +234,7 @@ def remove_networks(neutron_client):
if network_ids != None:
for net_id in network_ids:
logger.debug("Removing network %s ..." % net_id)
- if functest_utils.delete_neutron_net(neutron_client, net_id):
+ if openstack_utils.delete_neutron_net(neutron_client, net_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the "
@@ -253,7 +253,7 @@ def remove_ports(neutron_client, ports, network_ids):
router_id = port['device_id']
if len(port['fixed_ips']) == 0 and router_id == '':
logger.debug("Removing port %s ..." % port_id)
- if functest_utils.delete_neutron_port(neutron_client, port_id):
+ if openstack_utils.delete_neutron_port(neutron_client, port_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the "
@@ -263,7 +263,7 @@ def remove_ports(neutron_client, ports, network_ids):
elif port['device_owner'] == 'network:router_interface':
logger.debug("Detaching port %s (subnet %s) from router %s ..."
% (port_id,subnet_id,router_id))
- if functest_utils.remove_interface_router(neutron_client,
+ if openstack_utils.remove_interface_router(neutron_client,
router_id, subnet_id):
time.sleep(5) # leave 5 seconds to detach before doing anything else
logger.debug(" > Done!")
@@ -277,11 +277,11 @@ def remove_ports(neutron_client, ports, network_ids):
def force_remove_port(neutron_client, port_id):
logger.debug("Clearing device_owner for port %s ..." % port_id)
- functest_utils.update_neutron_port(neutron_client,
+ openstack_utils.update_neutron_port(neutron_client,
port_id,
device_owner='clear')
logger.debug("Removing port %s ..." % port_id)
- if functest_utils.delete_neutron_port(neutron_client, port_id):
+ if openstack_utils.delete_neutron_port(neutron_client, port_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing "
@@ -296,7 +296,7 @@ def remove_routers(neutron_client, routers):
logger.debug("Checking '%s' with ID=(%s) ..." % (router_name,router_id))
if router['external_gateway_info'] != None:
logger.debug("Router has gateway to external network. Removing link...")
- if functest_utils.remove_gateway_router(neutron_client, router_id):
+ if openstack_utils.remove_gateway_router(neutron_client, router_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing "
@@ -304,7 +304,7 @@ def remove_routers(neutron_client, routers):
else:
logger.debug("Router is not connected to anything. Ready to remove...")
logger.debug("Removing router %s(%s) ..." % (router_name, router_id))
- if functest_utils.delete_neutron_router(neutron_client, router_id):
+ if openstack_utils.delete_neutron_router(neutron_client, router_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the "
@@ -313,7 +313,7 @@ def remove_routers(neutron_client, routers):
def remove_security_groups(neutron_client):
logger.info("Removing Security groups...")
- secgroups = functest_utils.get_security_groups(neutron_client)
+ secgroups = openstack_utils.get_security_groups(neutron_client)
if secgroups is None or len(secgroups) == 0:
logger.debug("No security groups found.")
return
@@ -324,7 +324,7 @@ def remove_security_groups(neutron_client):
logger.debug("'%s', ID=%s " %(secgroup_name,secgroup_id))
if secgroup_id not in default_security_groups:
logger.debug(" Removing '%s'..." % secgroup_name)
- if functest_utils.delete_security_group(neutron_client, secgroup_id):
+ if openstack_utils.delete_security_group(neutron_client, secgroup_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the "
@@ -336,7 +336,7 @@ def remove_security_groups(neutron_client):
def remove_users(keystone_client):
logger.info("Removing Users...")
- users = functest_utils.get_users(keystone_client)
+ users = openstack_utils.get_users(keystone_client)
if users == None:
logger.debug("There are no users in the deployment. ")
return
@@ -347,7 +347,7 @@ def remove_users(keystone_client):
logger.debug("'%s', ID=%s " %(user_name,user_id))
if user_id not in default_users:
logger.debug(" Removing '%s'..." % user_name)
- if functest_utils.delete_user(keystone_client,user_id):
+ if openstack_utils.delete_user(keystone_client,user_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the "
@@ -358,7 +358,7 @@ def remove_users(keystone_client):
def remove_tenants(keystone_client):
logger.info("Removing Tenants...")
- tenants = functest_utils.get_tenants(keystone_client)
+ tenants = openstack_utils.get_tenants(keystone_client)
if tenants == None:
logger.debug("There are no tenants in the deployment. ")
return
@@ -369,7 +369,7 @@ def remove_tenants(keystone_client):
logger.debug("'%s', ID=%s " %(tenant_name,tenant_id))
if tenant_id not in default_tenants:
logger.debug(" Removing '%s'..." % tenant_name)
- if functest_utils.delete_tenant(keystone_client,tenant_id):
+ if openstack_utils.delete_tenant(keystone_client,tenant_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the "
@@ -380,16 +380,16 @@ def remove_tenants(keystone_client):
def main():
- creds_nova = functest_utils.get_credentials("nova")
+ creds_nova = openstack_utils.get_credentials("nova")
nova_client = novaclient.Client('2',**creds_nova)
- creds_neutron = functest_utils.get_credentials("neutron")
+ creds_neutron = openstack_utils.get_credentials("neutron")
neutron_client = neutronclient.Client(**creds_neutron)
- creds_keystone = functest_utils.get_credentials("keystone")
+ creds_keystone = openstack_utils.get_credentials("keystone")
keystone_client = keystoneclient.Client(**creds_keystone)
- creds_cinder = functest_utils.get_credentials("cinder")
+ creds_cinder = openstack_utils.get_credentials("cinder")
#cinder_client = cinderclient.Client(**creds_cinder)
cinder_client = cinderclient.Client('1',creds_cinder['username'],
creds_cinder['api_key'],
@@ -397,7 +397,7 @@ def main():
creds_cinder['auth_url'],
service_type="volume")
- if not functest_utils.check_credentials():
+ if not openstack_utils.check_credentials():
logger.error("Please source the openrc credentials and run the script again.")
exit(-1)
diff --git a/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py b/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
index 72987ddda..731ed9e4e 100644
--- a/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
+++ b/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
@@ -57,7 +57,7 @@ if not os.path.exists(REPO_PATH):
logger.error("Functest repository directory not found '%s'" % REPO_PATH)
exit(-1)
sys.path.append(REPO_PATH + "testcases/")
-import functest_utils
+import openstack_utils
DEFAULTS_FILE = '/home/opnfv/functest/conf/os_defaults.yaml'
@@ -68,7 +68,7 @@ def separator():
def get_instances(nova_client):
logger.debug("Getting instances...")
dic_instances = {}
- instances = functest_utils.get_instances(nova_client)
+ instances = openstack_utils.get_instances(nova_client)
if not (instances is None or len(instances) == 0):
for instance in instances:
dic_instances.update({getattr(instance, 'id'):getattr(instance, 'name')})
@@ -78,7 +78,7 @@ def get_instances(nova_client):
def get_images(nova_client):
logger.debug("Getting images...")
dic_images = {}
- images = functest_utils.get_images(nova_client)
+ images = openstack_utils.get_images(nova_client)
if not (images is None or len(images) == 0):
for image in images:
dic_images.update({getattr(image, 'id'):getattr(image, 'name')})
@@ -88,7 +88,7 @@ def get_images(nova_client):
def get_volumes(cinder_client):
logger.debug("Getting volumes...")
dic_volumes = {}
- volumes = functest_utils.get_volumes(cinder_client)
+ volumes = openstack_utils.get_volumes(cinder_client)
if volumes != None:
for volume in volumes:
dic_volumes.update({volume.id:volume.display_name})
@@ -98,7 +98,7 @@ def get_volumes(cinder_client):
def get_networks(neutron_client):
logger.debug("Getting networks")
dic_networks = {}
- networks = functest_utils.get_network_list(neutron_client)
+ networks = openstack_utils.get_network_list(neutron_client)
if networks != None:
for network in networks:
dic_networks.update({network['id']:network['name']})
@@ -108,7 +108,7 @@ def get_networks(neutron_client):
def get_routers(neutron_client):
logger.debug("Getting routers")
dic_routers = {}
- routers = functest_utils.get_router_list(neutron_client)
+ routers = openstack_utils.get_router_list(neutron_client)
if routers != None:
for router in routers:
dic_routers.update({router['id']:router['name']})
@@ -118,7 +118,7 @@ def get_routers(neutron_client):
def get_security_groups(neutron_client):
logger.debug("Getting Security groups...")
dic_secgroups = {}
- secgroups = functest_utils.get_security_groups(neutron_client)
+ secgroups = openstack_utils.get_security_groups(neutron_client)
if not (secgroups is None or len(secgroups) == 0):
for secgroup in secgroups:
dic_secgroups.update({secgroup['id']:secgroup['name']})
@@ -128,7 +128,7 @@ def get_security_groups(neutron_client):
def get_floatinips(nova_client):
logger.debug("Getting Floating IPs...")
dic_floatingips = {}
- floatingips = functest_utils.get_floating_ips(nova_client)
+ floatingips = openstack_utils.get_floating_ips(nova_client)
if not (floatingips is None or len(floatingips) == 0):
for floatingip in floatingips:
dic_floatingips.update({floatingip.id:floatingip.ip})
@@ -138,7 +138,7 @@ def get_floatinips(nova_client):
def get_users(keystone_client):
logger.debug("Getting users...")
dic_users = {}
- users = functest_utils.get_users(keystone_client)
+ users = openstack_utils.get_users(keystone_client)
if not (users is None or len(users) == 0):
for user in users:
dic_users.update({getattr(user, 'id'):getattr(user, 'name')})
@@ -148,7 +148,7 @@ def get_users(keystone_client):
def get_tenants(keystone_client):
logger.debug("Getting users...")
dic_tenants = {}
- tenants = functest_utils.get_tenants(keystone_client)
+ tenants = openstack_utils.get_tenants(keystone_client)
if not (tenants is None or len(tenants) == 0):
for tenant in tenants:
dic_tenants.update({getattr(tenant, 'id'):getattr(tenant, 'name')})
@@ -156,23 +156,23 @@ def get_tenants(keystone_client):
def main():
- creds_nova = functest_utils.get_credentials("nova")
+ creds_nova = openstack_utils.get_credentials("nova")
nova_client = novaclient.Client('2',**creds_nova)
- creds_neutron = functest_utils.get_credentials("neutron")
+ creds_neutron = openstack_utils.get_credentials("neutron")
neutron_client = neutronclient.Client(**creds_neutron)
- creds_keystone = functest_utils.get_credentials("keystone")
+ creds_keystone = openstack_utils.get_credentials("keystone")
keystone_client = keystoneclient.Client(**creds_keystone)
- creds_cinder = functest_utils.get_credentials("cinder")
+ creds_cinder = openstack_utils.get_credentials("cinder")
cinder_client = cinderclient.Client('1',creds_cinder['username'],
creds_cinder['api_key'],
creds_cinder['project_id'],
creds_cinder['auth_url'],
service_type="volume")
- if not functest_utils.check_credentials():
+ if not openstack_utils.check_credentials():
logger.error("Please source the openrc credentials and run the script again.")
exit(-1)
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
index 7e1f89abf..078e5eaa1 100755
--- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
@@ -89,17 +89,15 @@ if not os.path.exists(REPO_PATH):
exit(-1)
sys.path.append(REPO_PATH + "testcases/")
import functest_utils
+import openstack_utils
with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
functest_yaml = yaml.safe_load(f)
f.close()
HOME = os.environ['HOME']+"/"
-### todo:
-# SCENARIOS_DIR = REPO_PATH + functest_yaml.get("general"). \
-# get("directories").get("dir_rally_scn")
-SCENARIOS_DIR = REPO_PATH + "testcases/VIM/OpenStack/CI/rally_cert/"
-###
+SCENARIOS_DIR = REPO_PATH + functest_yaml.get("general"). \
+ get("directories").get("dir_rally_scn")
TEMPLATE_DIR = SCENARIOS_DIR + "scenario/templates"
SUPPORT_DIR = SCENARIOS_DIR + "scenario/support"
###todo:
@@ -210,13 +208,13 @@ def build_task_args(test_file_name):
task_args['iterations'] = ITERATIONS_AMOUNT
task_args['concurrency'] = CONCURRENCY
- ext_net = functest_utils.get_external_net(client_dict['neutron'])
+ ext_net = openstack_utils.get_external_net(client_dict['neutron'])
if ext_net:
task_args['floating_network'] = str(ext_net)
else:
task_args['floating_network'] = ''
- net_id = functest_utils.get_network_id(client_dict['neutron'],
+ net_id = openstack_utils.get_network_id(client_dict['neutron'],
PRIVATE_NETWORK)
task_args['netid'] = str(net_id)
task_args['live_migration'] = live_migration_supported()
@@ -374,17 +372,17 @@ def main():
exit(-1)
SUMMARY = []
- creds_nova = functest_utils.get_credentials("nova")
+ creds_nova = openstack_utils.get_credentials("nova")
nova_client = novaclient.Client('2', **creds_nova)
- creds_neutron = functest_utils.get_credentials("neutron")
+ creds_neutron = openstack_utils.get_credentials("neutron")
neutron_client = neutronclient.Client(**creds_neutron)
- creds_keystone = functest_utils.get_credentials("keystone")
+ creds_keystone = openstack_utils.get_credentials("keystone")
keystone_client = keystoneclient.Client(**creds_keystone)
glance_endpoint = keystone_client.service_catalog.url_for(service_type='image',
endpoint_type='publicURL')
glance_client = glanceclient.Client(1, glance_endpoint,
token=keystone_client.auth_token)
- creds_cinder = functest_utils.get_credentials("cinder")
+ creds_cinder = openstack_utils.get_credentials("cinder")
cinder_client = cinderclient.Client('2', creds_cinder['username'],
creds_cinder['api_key'],
creds_cinder['project_id'],
@@ -393,10 +391,10 @@ def main():
client_dict['neutron'] = neutron_client
- volume_types = functest_utils.list_volume_types(cinder_client,
+ volume_types = openstack_utils.list_volume_types(cinder_client,
private=False)
if not volume_types:
- volume_type = functest_utils.create_volume_type(cinder_client,
+ volume_type = openstack_utils.create_volume_type(cinder_client,
CINDER_VOLUME_TYPE_NAME)
if not volume_type:
logger.error("Failed to create volume type...")
@@ -407,12 +405,12 @@ def main():
else:
logger.debug("Using existing volume type(s)...")
- image_id = functest_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
+ image_id = openstack_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
if image_id == '':
logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME,
GLANCE_IMAGE_PATH))
- image_id = functest_utils.create_glance_image(glance_client,
+ image_id = openstack_utils.create_glance_image(glance_client,
GLANCE_IMAGE_NAME,
GLANCE_IMAGE_PATH)
if not image_id:
@@ -499,13 +497,13 @@ def main():
logger.debug("Deleting image '%s' with ID '%s'..." \
% (GLANCE_IMAGE_NAME, image_id))
- if not functest_utils.delete_glance_image(nova_client, image_id):
+ if not openstack_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):
+ if not openstack_utils.delete_volume_type(cinder_client, volume_type):
logger.error("Error in deleting volume type...")
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally.py b/testcases/VIM/OpenStack/CI/libraries/run_rally.py
deleted file mode 100755
index 1ea6ca6db..000000000
--- a/testcases/VIM/OpenStack/CI/libraries/run_rally.py
+++ /dev/null
@@ -1,288 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2015 Orange
-# guyrodrigue.koffi@orange.com
-# morgan.richomme@orange.com
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# 0.1 (05/2015) initial commit
-# 0.2 (28/09/2015) extract Tempest, format json result, add ceilometer suite
-# 0.3 (19/10/2015) remove Tempest from run_rally
-# and push result into test DB
-#
-
-import re
-import json
-import os
-import argparse
-import logging
-import yaml
-import requests
-import subprocess
-import sys
-from novaclient import client as novaclient
-from keystoneclient.v2_0 import client as keystoneclient
-from glanceclient import client as glanceclient
-
-""" tests configuration """
-tests = ['authenticate', 'glance', 'cinder', 'ceilometer', 'heat', 'keystone',
- 'neutron', 'nova', 'quotas', 'requests', 'vm', 'all']
-parser = argparse.ArgumentParser()
-parser.add_argument("test_name",
- help="Module name to be tested"
- "Possible values are : "
- "[ {d[0]} | {d[1]} | {d[2]} | {d[3]} | {d[4]} | "
- "{d[5]} | {d[6]} | {d[7]} | {d[8]} | {d[9]} | "
- "{d[10]} | {d[11]}]. The 'all' value "
- "performs all the possible tests scenarios"
- .format(d=tests))
-
-parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
-parser.add_argument("-r", "--report",
- help="Create json result file",
- action="store_true")
-parser.add_argument("-v", "--verbose",
- help="Print verbose info about the progress",
- action="store_true")
-parser.add_argument("-n", "--noclean",
- help="Don't clean the created resources for this test.",
- action="store_true")
-
-args = parser.parse_args()
-
-if args.verbose:
- RALLY_STDERR = subprocess.STDOUT
-else:
- RALLY_STDERR = open(os.devnull, 'w')
-
-""" logging configuration """
-logger = logging.getLogger("run_rally")
-logger.setLevel(logging.DEBUG)
-
-ch = logging.StreamHandler()
-if args.debug:
- ch.setLevel(logging.DEBUG)
-else:
- ch.setLevel(logging.INFO)
-
-formatter = logging.Formatter("%(asctime)s - %(name)s - "
- "%(levelname)s - %(message)s")
-ch.setFormatter(formatter)
-logger.addHandler(ch)
-
-REPO_PATH = os.environ['repos_dir']+'/functest/'
-if not os.path.exists(REPO_PATH):
- logger.error("Functest repository directory not found '%s'" % REPO_PATH)
- exit(-1)
-sys.path.append(REPO_PATH + "testcases/")
-import functest_utils
-
-with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
- functest_yaml = yaml.safe_load(f)
-f.close()
-
-HOME = os.environ['HOME']+"/"
-SCENARIOS_DIR = REPO_PATH + functest_yaml.get("general"). \
- get("directories").get("dir_rally_scn")
-RESULTS_DIR = functest_yaml.get("general").get("directories"). \
- get("dir_rally_res")
-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(case, payload):
-
- url = TEST_DB + "/results"
- installer = functest_utils.get_installer_type(logger)
- scenario = functest_utils.get_scenario(logger)
- pod_name = functest_utils.get_pod_name(logger)
- build_tag = functest_utils.get_build_tag(logger)
- # TODO pod_name hardcoded, info shall come from Jenkins
- params = {"project_name": "functest", "case_name": case,
- "pod_name": pod_name, "installer": installer,
- "version": scenario, "build_tag": build_tag,
- "details": payload}
-
- headers = {'Content-Type': 'application/json'}
- r = requests.post(url, data=json.dumps(params), headers=headers)
- logger.debug(r)
-
-
-def get_task_id(cmd_raw):
- """
- get task id from command rally result
- :param cmd_raw:
- :return: task_id as string
- """
- taskid_re = re.compile('^Task +(.*): started$')
- for line in cmd_raw.splitlines(True):
- line = line.strip()
- match = taskid_re.match(line)
- if match:
- return match.group(1)
- return None
-
-
-def task_succeed(json_raw):
- """
- Parse JSON from rally JSON results
- :param json_raw:
- :return: Bool
- """
- rally_report = json.loads(json_raw)
- rally_report = rally_report[0]
- if rally_report is None:
- return False
- if rally_report.get('result') is None:
- return False
-
- for result in rally_report.get('result'):
- if len(result.get('error')) > 0:
- return False
-
- return True
-
-
-def run_task(test_name):
- #
- # the "main" function of the script who lunch rally for a task
- # :param test_name: name for the rally test
- # :return: void
- #
-
- logger.info('starting {} test ...'.format(test_name))
-
- # check directory for scenarios test files or retrieve from git otherwise
- proceed_test = True
- test_file_name = '{}opnfv-{}.json'.format(SCENARIOS_DIR, test_name)
-
- if not os.path.exists(test_file_name):
- logger.error("The scenario '%s' does not exist." % test_file_name)
- exit(-1)
-
- # we do the test only if we have a scenario test file
- if proceed_test:
- logger.debug('Scenario fetched from : {}'.format(test_file_name))
- cmd_line = "rally task start --abort-on-sla-failure {}".format(test_file_name)
- logger.debug('running command line : {}'.format(cmd_line))
- 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
-
- task_id = get_task_id(result)
- logger.debug('task_id : {}'.format(task_id))
-
- if task_id is None:
- logger.error("failed to retrieve task_id")
- exit(-1)
-
- # check for result directory and create it otherwise
- if not os.path.exists(RESULTS_DIR):
- logger.debug('does not exists, we create it'.format(RESULTS_DIR))
- os.makedirs(RESULTS_DIR)
-
- # write html report file
- report_file_name = '{}opnfv-{}.html'.format(RESULTS_DIR, test_name)
- cmd_line = "rally task report {} --out {}".format(task_id,
- report_file_name)
-
- logger.debug('running command line : {}'.format(cmd_line))
- os.popen(cmd_line)
-
- # get and save rally operation JSON result
- cmd_line = "rally task results %s" % task_id
- logger.debug('running command line : {}'.format(cmd_line))
- cmd = os.popen(cmd_line)
- json_results = cmd.read()
- with open('{}opnfv-{}.json'.format(RESULTS_DIR, test_name), 'w') as f:
- logger.debug('saving json file')
- f.write(json_results)
-
- with open('{}opnfv-{}.json'
- .format(RESULTS_DIR, test_name)) as json_file:
- json_data = json.load(json_file)
-
- # Push results in payload of testcase
- if args.report:
- logger.debug("Push result into DB")
- push_results_to_db("Rally_details", json_data)
-
- """ parse JSON operation result """
- if task_succeed(json_results):
- print 'Test OK'
- else:
- print 'Test KO'
- else:
- logger.error('{} test failed, unable to fetch a scenario test file'
- .format(test_name))
-
-
-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('2', **creds_nova)
- creds_keystone = functest_utils.get_credentials("keystone")
- keystone_client = keystoneclient.Client(**creds_keystone)
- glance_endpoint = keystone_client.service_catalog.url_for(service_type='image',
- endpoint_type='publicURL')
- glance_client = glanceclient.Client(1, glance_endpoint,
- token=keystone_client.auth_token)
-
- image_id = functest_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
-
- if image_id == '':
- logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH))
- image_id = functest_utils.create_glance_image(glance_client,
- GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH)
- if not image_id:
- logger.error("Failed to create the Glance image...")
- exit(-1)
- else:
- logger.debug("Image '%s' with ID '%s' created succesfully ." \
- % (GLANCE_IMAGE_NAME, image_id))
- else:
- logger.debug("Using existing image '%s' with ID '%s'..." \
- % (GLANCE_IMAGE_NAME, image_id))
-
- if args.test_name == "all":
- for test_name in tests:
- if not (test_name == 'all' or
- test_name == 'heat' or
- test_name == 'ceilometer' or
- test_name == 'smoke' or
- test_name == 'vm'):
- print(test_name)
- run_task(test_name)
- else:
- print(args.test_name)
- run_task(args.test_name)
-
- if args.noclean:
- exit(0)
-
- logger.debug("Deleting image '%s' with ID '%s'..." \
- % (GLANCE_IMAGE_NAME, image_id))
- if not functest_utils.delete_glance_image(nova_client, image_id):
- logger.error("Error deleting the glance image")
-
-if __name__ == '__main__':
- main()
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
index 58c39225f..75ce7fb9a 100644
--- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
@@ -71,6 +71,7 @@ if not os.path.exists(REPO_PATH):
exit(-1)
sys.path.append(REPO_PATH + "testcases/")
import functest_utils
+import openstack_utils
with open("/home/opnfv/functest/conf/config_functest.yaml") as f:
functest_yaml = yaml.safe_load(f)
@@ -134,38 +135,38 @@ def push_results_to_db(case, payload, criteria):
def create_tempest_resources():
- ks_creds = functest_utils.get_credentials("keystone")
+ ks_creds = openstack_utils.get_credentials("keystone")
logger.info("Creating tenant and user for Tempest suite")
keystone = ksclient.Client(**ks_creds)
- tenant_id = functest_utils.create_tenant(keystone,
+ tenant_id = openstack_utils.create_tenant(keystone,
TENANT_NAME,
TENANT_DESCRIPTION)
if tenant_id == '':
logger.error("Error : Failed to create %s tenant" % TENANT_NAME)
- user_id = functest_utils.create_user(keystone, USER_NAME, USER_PASSWORD,
+ user_id = openstack_utils.create_user(keystone, USER_NAME, USER_PASSWORD,
None, tenant_id)
if user_id == '':
logger.error("Error : Failed to create %s user" % USER_NAME)
def free_tempest_resources():
- ks_creds = functest_utils.get_credentials("keystone")
+ ks_creds = openstack_utils.get_credentials("keystone")
logger.info("Deleting tenant and user for Tempest suite)")
keystone = ksclient.Client(**ks_creds)
- user_id = functest_utils.get_user_id(keystone, USER_NAME)
+ user_id = openstack_utils.get_user_id(keystone, USER_NAME)
if user_id == '':
logger.error("Error : Failed to get id of %s user" % USER_NAME)
else:
- if not functest_utils.delete_user(keystone, user_id):
+ if not openstack_utils.delete_user(keystone, user_id):
logger.error("Error : Failed to delete %s user" % USER_NAME)
- tenant_id = functest_utils.get_tenant_id(keystone, TENANT_NAME)
+ tenant_id = openstack_utils.get_tenant_id(keystone, TENANT_NAME)
if tenant_id == '':
logger.error("Error : Failed to get id of %s tenant" % TENANT_NAME)
else:
- if not functest_utils.delete_tenant(keystone, tenant_id):
+ if not openstack_utils.delete_tenant(keystone, tenant_id):
logger.error("Error : Failed to delete %s tenant" % TENANT_NAME)
@@ -197,9 +198,9 @@ def configure_tempest():
logger.debug(" Updating fixed_network_name...")
private_net_name = ""
- creds_neutron = functest_utils.get_credentials("neutron")
+ creds_neutron = openstack_utils.get_credentials("neutron")
neutron_client = neutronclient.Client(**creds_neutron)
- private_net = functest_utils.get_private_net(neutron_client)
+ private_net = openstack_utils.get_private_net(neutron_client)
if private_net is None:
logger.error("No shared private networks found.")
else: