[multisite] integrate kingbird tempest testcases
authormeimei <meimei@huawei.com>
Thu, 14 Jul 2016 04:04:37 +0000 (12:04 +0800)
committermei mei <meimei@huawei.com>
Thu, 14 Jul 2016 08:51:46 +0000 (08:51 +0000)
JIRA: FUNCTEST-179

Change-Id: I4a8ae43e2814b3d859c32a6278671f87155aa855
Signed-off-by: meimei <meimei@huawei.com>
ci/exec_test.sh
testcases/OpenStack/tempest/run_tempest.py

index 89e2966..dbf9410 100755 (executable)
@@ -147,6 +147,8 @@ function run_test(){
         ;;
         "multisite")
             python ${FUNCTEST_REPO_DIR}/testcases/features/multisite.py
+            python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
+                $clean_flag -s -m feature_multisite $report
         ;;
         *)
             echo "The test case '${test_name}' does not exist."
index a16ba26..ab79a87 100755 (executable)
@@ -33,7 +33,7 @@ import functest.utils.openstack_utils as os_utils
 
 modes = ['full', 'smoke', 'baremetal', 'compute', 'data_processing',
          'identity', 'image', 'network', 'object_storage', 'orchestration',
-         'telemetry', 'volume', 'custom', 'defcore']
+         'telemetry', 'volume', 'custom', 'defcore', 'feature_multisite']
 
 """ tests configuration """
 parser = argparse.ArgumentParser()
@@ -211,6 +211,45 @@ def configure_tempest(deployment_dir):
     return True
 
 
+def configure_tempest_feature(deployment_dir, mode):
+    """
+    Add/update needed parameters into tempest.conf file generated by Rally
+    """
+
+    logger.debug("Finding tempest.conf file...")
+    tempest_conf_file = deployment_dir + "/tempest.conf"
+    if not os.path.isfile(tempest_conf_file):
+        logger.error("Tempest configuration file %s NOT found."
+                     % tempest_conf_file)
+        exit(-1)
+
+    logger.debug("Updating selected tempest.conf parameters...")
+    config = ConfigParser.RawConfigParser()
+    config.read(tempest_conf_file)
+    if mode == 'feature_multisite':
+        config.set('service_available', 'kingbird', 'true')
+        cmd = "openstack endpoint show kingbird | grep publicurl |\
+               awk '{print $4}' | awk -F '/' '{print $3}'"
+        kingbird_endpoint_url = os.popen(cmd).read()
+        cmd = "openstack endpoint show kingbird | grep publicurl |\
+               awk '{print $4}' | awk -F '/' '{print $4}'"
+        kingbird_api_version = os.popen(cmd).read()
+        try:
+            config.add_section("kingbird")
+        except:
+            logger.info('kingbird section exist')
+        config.set('kingbird', 'endpoint_type', 'publicURL')
+        config.set('kingbird', 'TIME_TO_SYNC', '20')
+        config.set('kingbird', 'endpoint_url', kingbird_endpoint_url)
+        config.set('kingbird', 'api_version', kingbird_api_version)
+    with open(tempest_conf_file, 'wb') as config_file:
+        config.write(config_file)
+
+    # Copy tempest.conf to /home/opnfv/functest/results/tempest/
+    shutil.copyfile(tempest_conf_file, TEMPEST_RESULTS_DIR + '/tempest.conf')
+    return True
+
+
 def read_file(filename):
     with open(filename) as src:
         return [line.strip() for line in src.readlines()]
@@ -230,6 +269,8 @@ def generate_test_list(deployment_dir, mode):
     else:
         if mode == 'smoke':
             testr_mode = "smoke"
+        elif mode == 'feature_multisite':
+            testr_mode = " | grep kingbird "
         elif mode == 'full':
             testr_mode = ""
         else:
@@ -365,6 +406,7 @@ def main():
 
     deployment_dir = ft_utils.get_deployment_dir(logger)
     configure_tempest(deployment_dir)
+    configure_tempest_feature(deployment_dir, args.mode)
     create_tempest_resources()
     generate_test_list(deployment_dir, args.mode)
     apply_tempest_blacklist()