aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/VIM
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 /testcases/VIM
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>
Diffstat (limited to 'testcases/VIM')
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/run_tempest.py90
1 files changed, 90 insertions, 0 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__':