Merge "Bug fixes odl-sfc + new features"
authorvalentin boucher <valentin.boucher@orange.com>
Sun, 7 Aug 2016 11:03:01 +0000 (11:03 +0000)
committerGerrit Code Review <gerrit@172.30.200.206>
Sun, 7 Aug 2016 11:03:01 +0000 (11:03 +0000)
ci/config_functest.yaml
ci/testcases.yaml
ci/tier_handler.py
testcases/OpenStack/tempest/run_tempest.py
testcases/features/doctor.py
testcases/vnf/RNC/parser.py
utils/functest_utils.py

index e446820..fb4103d 100644 (file)
@@ -74,6 +74,8 @@ tempest:
         tenant_description: Tenant for Tempest test suite
         user_name: tempest
         user_password: tempest
+    validation:
+        ssh_timeout: 130
     private_net_name: tempest-net
     private_subnet_name: tempest-subnet
     private_subnet_cidr: 192.168.150.0/24
index 315969a..221d2fc 100644 (file)
@@ -257,7 +257,7 @@ tiers:
                     scenario: '(ocl)|(nosdn)|^(os-odl)((?!bgpvpn).)*$'
             -
                 name: parser
-                criteria: 'status == "PASS"'
+                criteria: 'ret == 0'
                 blocking: false
                 description: >-
                     Test suite from Parser project.
index e50fbe6..1eadfba 100644 (file)
@@ -111,17 +111,21 @@ class TestCase:
         self.criteria = criteria
         self.blocking = blocking
 
+    @staticmethod
+    def is_none(item):
+        return item is None or item is ""
+
     def is_compatible(self, ci_installer, ci_scenario):
         try:
-            if ci_installer is not None:
+            if not self.is_none(ci_installer):
                 if re.search(self.dependency.get_installer(),
                              ci_installer) is None:
                     return False
-            if ci_scenario is not None:
+            if not self.is_none(ci_scenario):
                 if re.search(self.dependency.get_scenario(),
                              ci_scenario) is None:
                     return False
-            return not (ci_scenario is None and ci_installer is None)
+            return True
         except TypeError:
             return False
 
index 53a70b7..d29b3f3 100755 (executable)
@@ -81,6 +81,8 @@ TENANT_DESCRIPTION = functest_yaml.get("tempest").get("identity").get(
 USER_NAME = functest_yaml.get("tempest").get("identity").get("user_name")
 USER_PASSWORD = functest_yaml.get("tempest").get("identity").get(
     "user_password")
+SSH_TIMEOUT = functest_yaml.get("tempest").get("validation").get(
+    "ssh_timeout")
 DEPLOYMENT_MAME = functest_yaml.get("rally").get("deployment_name")
 RALLY_INSTALLATION_DIR = functest_yaml.get("general").get("directories").get(
     "dir_rally_inst")
@@ -176,12 +178,16 @@ def configure_tempest(deployment_dir):
     Add/update needed parameters into tempest.conf file generated by Rally
     """
 
-    logger.debug("Generating tempest.conf file...")
+    tempest_conf_file = deployment_dir + "/tempest.conf"
+    if os.path.isfile(tempest_conf_file):
+        logger.debug("Deleting old tempest.conf file...")
+        os.remove(tempest_conf_file)
+
+    logger.debug("Generating new tempest.conf file...")
     cmd = "rally verify genconfig"
     ft_utils.execute_command(cmd, logger)
 
     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)
@@ -194,6 +200,7 @@ def configure_tempest(deployment_dir):
     config.set('identity', 'tenant_name', TENANT_NAME)
     config.set('identity', 'username', USER_NAME)
     config.set('identity', 'password', USER_PASSWORD)
+    config.set('validation', 'ssh_timeout', SSH_TIMEOUT)
 
     if os.getenv('OS_ENDPOINT_TYPE') is not None:
         services_list = ['compute', 'volume', 'image', 'network',
index bdf3ddc..184ab03 100755 (executable)
@@ -37,7 +37,8 @@ def main():
     cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO
     start_time = time.time()
 
-    ret = functest_utils.execute_command(cmd, logger, exit_on_error=False)
+    ret = functest_utils.execute_command(cmd, logger, info=True,
+                                         exit_on_error=False)
 
     stop_time = time.time()
     duration = round(stop_time - start_time, 1)
index 485af0e..91d5bb0 100644 (file)
@@ -32,33 +32,18 @@ logger = ft_logger.Logger("parser").getLogger()
 
 
 def main():
-    EXIT_CODE = -1
     project = 'parser'
     case_name = 'parser-basics'
     cmd = 'cd %s/tests && ./functest_run.sh' % PARSER_REPO
-    start_time = time.time()
 
+    start_time = time.time()
     ret = functest_utils.execute_command(cmd, logger, exit_on_error=False)
-
     stop_time = time.time()
-    duration = round(stop_time - start_time, 1)
-    if ret == 0:
-        EXIT_CODE = 0
-        logger.info("parser OK")
-        test_status = 'OK'
-    else:
-        logger.info("parser FAILED")
-        test_status = 'NOK'
-
-    details = {
-        'timestart': start_time,
-        'duration': duration,
-        'status': test_status,
-    }
 
-    status = "FAIL"
-    if details['status'] == "OK":
-        status = "PASS"
+    status, details = functest_utils.check_test_result(case_name,
+                                                       ret,
+                                                       start_time,
+                                                       stop_time)
 
     functest_utils.logger_test_results(logger,
                                        project,
@@ -73,7 +58,7 @@ def main():
                                       stop_time,
                                       status,
                                       details)
-    exit(EXIT_CODE)
+    exit(ret)
 
 if __name__ == '__main__':
     main()
index 5f790a0..cb2333d 100644 (file)
@@ -357,16 +357,33 @@ def check_success_rate(case_name, success_rate):
     success_rate = float(success_rate)
     criteria = get_criteria_by_test(case_name)
 
-    def get_value(op):
+    def get_criteria_value(op):
         return float(criteria.split(op)[1].rstrip('%'))
 
     status = 'FAIL'
     ops = ['==', '>=']
     for op in ops:
         if op in criteria:
-            c_value = get_value(op)
+            c_value = get_criteria_value(op)
             if eval("%s %s %s" % (success_rate, op, c_value)):
                 status = 'PASS'
             break
 
     return status
+
+
+def check_test_result(test_name, ret, start_time, stop_time):
+    def get_criteria_value():
+        return get_criteria_by_test(test_name).split('==')[1].strip()
+
+    status = 'FAIL'
+    if str(ret) == get_criteria_value():
+        status = 'PASS'
+
+    details = {
+        'timestart': start_time,
+        'duration': round(stop_time - start_time, 1),
+        'status': status,
+    }
+
+    return status, details