summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViktor Tikkanen <viktor.tikkanen@nokia.com>2016-01-04 10:21:33 +0200
committerViktor Tikkanen <viktor.tikkanen@nokia.com>2016-01-04 10:24:38 +0200
commitc7dbde64949e3af540d6a6520853325111dac988 (patch)
treeaf4a3ee6a4073acf5b8991f5eae28ea7b5f3a59d
parentb4b11996105741263f98e1e66b2412d8962b5c92 (diff)
Configuring non-admin credentials for tempest
Since some test cases from tempest suite require non-admin credentials, a new project and a new user with non-admin role were added to the configuration. JIRA: FUNCTEST-72 Change-Id: I573bc18292b5885bd354f4af16f7f70a7178540d Signed-off-by: Viktor Tikkanen <viktor.tikkanen@nokia.com>
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/run_tempest.py90
-rwxr-xr-xtestcases/config_functest.py46
-rw-r--r--testcases/config_functest.yaml10
3 files changed, 102 insertions, 44 deletions
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
index 41fd4b7cb..e551ed3b1 100644
--- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
@@ -17,6 +17,7 @@ import requests
import subprocess
import sys
import yaml
+import keystoneclient.v2_0.client as ksclient
modes = ['full', 'smoke', 'baremetal', 'compute', 'data_processing',
'identity', 'image', 'network', 'object_storage', 'orchestration',
@@ -60,6 +61,14 @@ f.close()
TEST_DB = functest_yaml.get("results").get("test_db_url")
MODE = "smoke"
+TENANT_NAME = functest_yaml.get("tempest").get("identity").get("tenant_name")
+TENANT_DESCRIPTION = functest_yaml.get("tempest").get("identity").get("tenant_description")
+USER_NAME = functest_yaml.get("tempest").get("identity").get("user_name")
+USER_PASSWORD = functest_yaml.get("tempest").get("identity").get("user_password")
+NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("general"). \
+ get("openstack").get("neutron_private_net_name")
+DEPLOYMENT_MAME = functest_yaml.get("rally").get("deployment_name")
+RALLY_INSTALLATION_DIR = functest_yaml.get("general").get("directories").get("dir_rally_inst")
def get_info(file_result):
@@ -103,6 +112,84 @@ def push_results_to_db(payload, module, pod_name):
logger.debug(r)
+def create_tempest_resources():
+ ks_creds = functest_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_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, 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")
+ logger.info("Deleting tenant and user for Tempest suite)")
+ keystone = ksclient.Client(**ks_creds)
+
+ user_id = functest_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):
+ logger.error("Error : Failed to delete %s user" % USER_NAME)
+
+ tenant_id = functest_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):
+ logger.error("Error : Failed to delete %s tenant" % TENANT_NAME)
+
+
+def configure_tempest():
+ """
+ Add/update needed parameters into tempest.conf file generated by Rally
+ """
+
+ logger.debug("Generating tempest.conf file...")
+ cmd = "rally verify genconfig"
+ functest_utils.execute_command(cmd,logger)
+
+ logger.debug("Resolving deployment UUID...")
+ cmd = "rally deployment list | awk '/"+DEPLOYMENT_MAME+"/ {print $2}'"
+ p = subprocess.Popen(cmd, shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT);
+ deployment_uuid = p.stdout.readline().rstrip()
+ if deployment_uuid == "":
+ logger.debug(" Rally deployment NOT found")
+ return False
+
+ logger.debug("Finding tempest.conf file...")
+ tempest_conf_file = RALLY_INSTALLATION_DIR+"/tempest/for-deployment-" \
+ +deployment_uuid+"/tempest.conf"
+ if tempest_conf_file == "":
+ logger.debug(" Tempest configuration file NOT found")
+ return False
+
+ logger.debug(" Updating fixed_network_name...")
+ cmd = "crudini --set "+tempest_conf_file+" compute fixed_network_name " \
+ +NEUTRON_PRIVATE_NET_NAME
+ functest_utils.execute_command(cmd,logger)
+
+ logger.debug(" Updating non-admin credentials...")
+ cmd = "crudini --set "+tempest_conf_file+" identity tenant_name " \
+ +TENANT_NAME
+ functest_utils.execute_command(cmd,logger)
+ cmd = "crudini --set "+tempest_conf_file+" identity username " \
+ +USER_NAME
+ functest_utils.execute_command(cmd,logger)
+ cmd = "crudini --set "+tempest_conf_file+" identity password " \
+ +USER_PASSWORD
+ functest_utils.execute_command(cmd,logger)
+
+ return True
+
+
def run_tempest(OPTION):
#
# the "main" function of the script which launches Rally to run Tempest
@@ -156,7 +243,10 @@ def main():
else:
MODE = "--set "+args.mode
+ create_tempest_resources()
+ configure_tempest()
run_tempest(MODE)
+ free_tempest_resources()
if __name__ == '__main__':
diff --git a/testcases/config_functest.py b/testcases/config_functest.py
index d0788d30f..20d3a9dd7 100755
--- a/testcases/config_functest.py
+++ b/testcases/config_functest.py
@@ -59,8 +59,8 @@ ODL_DIR = REPO_PATH + functest_yaml.get("general").get("directories").get("dir_o
DATA_DIR = functest_yaml.get("general").get("directories").get("dir_functest_data")
# Tempest/Rally configuration details
-DEPLOYMENT_MAME = "opnfv-rally"
-RALLY_COMMIT = functest_yaml.get("general").get("openstack").get("rally_stable_commit")
+DEPLOYMENT_MAME = functest_yaml.get("rally").get("deployment_name")
+RALLY_COMMIT = functest_yaml.get("general").get("repositories").get("rally_commit")
#Image (cirros)
IMAGE_FILE_NAME = functest_yaml.get("general").get("openstack").get("image_file_name")
@@ -108,19 +108,12 @@ def action_start():
logger.info("Private network '%s' already existing in the deployment."
% private_net['name'])
-
logger.info("Installing Rally...")
if not install_rally():
logger.error("There has been a problem while installing Rally.")
action_clean()
exit(-1)
- logger.info("Configuring Tempest...")
- if not configure_tempest():
- logger.error("There has been a problem while configuring Tempest.")
- action_clean()
- exit(-1)
-
# Create result folder under functest if necessary
if not os.path.exists(RALLY_RESULT_DIR):
os.makedirs(RALLY_RESULT_DIR)
@@ -231,41 +224,6 @@ def install_rally():
return True
-def configure_tempest():
- """
- Add/update needed parameters into tempest.conf file generated by Rally
- """
-
- creds_neutron = functest_utils.get_credentials("neutron")
- neutron_client = neutronclient.Client(**creds_neutron)
-
- logger.debug("Generating tempest.conf file...")
- cmd = "rally verify genconfig"
- functest_utils.execute_command(cmd,logger)
-
- logger.debug("Resolving deployment UUID...")
- cmd = "rally deployment list | awk '/"+DEPLOYMENT_MAME+"/ {print $2}'"
- p = subprocess.Popen(cmd, shell=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT);
- deployment_uuid = p.stdout.readline().rstrip()
- if deployment_uuid == "":
- logger.debug(" Rally deployment NOT found")
- return False
-
- logger.debug("Finding tempest.conf file...")
- tempest_conf_file = RALLY_INSTALLATION_DIR+"/tempest/for-deployment-" \
- +deployment_uuid+"/tempest.conf"
-
- logger.debug(" Updating fixed_network_name...")
- fixed_network = functest_utils.get_network_list(neutron_client)[0]['name']
- if fixed_network != None:
- cmd = "crudini --set "+tempest_conf_file+" compute fixed_network_name "+fixed_network
- functest_utils.execute_command(cmd,logger)
-
- return True
-
-
def check_rally():
"""
Check if Rally is installed and properly configured
diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml
index dc33f07f5..1cc16e17b 100644
--- a/testcases/config_functest.yaml
+++ b/testcases/config_functest.yaml
@@ -68,6 +68,16 @@ vping:
ip_1: 192.168.130.30
ip_2: 192.168.130.40
+tempest:
+ identity:
+ tenant_name: tempest
+ tenant_description: Tenant for Tempest test suite
+ user_name: tempest
+ user_password: tempest
+
+rally:
+ deployment_name: opnfv-rally
+
vIMS:
general:
tenant_name: vIMS