Move rally and tempest out of functest-core
[functest-xtesting.git] / functest / opnfv_tests / openstack / rally / rally.py
index e92639b..a4970fc 100644 (file)
@@ -20,13 +20,13 @@ import subprocess
 import time
 import uuid
 
-import iniparse
 import pkg_resources
 import yaml
 
 from functest.core import testcase
 from functest.energy import energy
 from functest.opnfv_tests.openstack.snaps import snaps_utils
+from functest.opnfv_tests.openstack.tempest import conf_utils
 from functest.utils.constants import CONST
 
 from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor
@@ -74,8 +74,6 @@ class RallyBase(testcase.TestCase):
     ITERATIONS_AMOUNT = 10
     CONCURRENCY = 4
     RESULTS_DIR = os.path.join(CONST.__getattribute__('dir_results'), 'rally')
-    TEMPEST_CONF_FILE = os.path.join(CONST.__getattribute__('dir_results'),
-                                     'tempest/tempest.conf')
     BLACKLIST_FILE = os.path.join(RALLY_DIR, "blacklist.txt")
     TEMP_DIR = os.path.join(RALLY_DIR, "var")
 
@@ -117,6 +115,7 @@ class RallyBase(testcase.TestCase):
         self.start_time = None
         self.result = None
         self.details = None
+        self.compute_cnt = 0
 
     def _build_task_args(self, test_file_name):
         task_args = {'service_list': [test_file_name]}
@@ -167,7 +166,7 @@ class RallyBase(testcase.TestCase):
         if not os.path.exists(self.TEMP_DIR):
             os.makedirs(self.TEMP_DIR)
 
-        self.apply_blacklist(scenario_file_name, test_file_name)
+        self._apply_blacklist(scenario_file_name, test_file_name)
         return test_file_name
 
     @staticmethod
@@ -205,16 +204,10 @@ class RallyBase(testcase.TestCase):
 
         return True
 
-    @staticmethod
-    def live_migration_supported():
-        """Determine if live migration is supported."""
-        config = iniparse.ConfigParser()
-        if (config.read(RallyBase.TEMPEST_CONF_FILE) and
-                config.has_section('compute-feature-enabled') and
-                config.has_option('compute-feature-enabled',
-                                  'live_migration')):
-            return config.getboolean('compute-feature-enabled',
-                                     'live_migration')
+    def _migration_supported(self):
+        """Determine if migration is supported."""
+        if self.compute_cnt > 1:
+            return True
 
         return False
 
@@ -273,8 +266,7 @@ class RallyBase(testcase.TestCase):
         else:
             return False
 
-    @staticmethod
-    def excl_func():
+    def excl_func(self):
         """Exclude functionalities."""
         black_tests = []
         func_list = []
@@ -283,8 +275,8 @@ class RallyBase(testcase.TestCase):
             with open(RallyBase.BLACKLIST_FILE, 'r') as black_list_file:
                 black_list_yaml = yaml.safe_load(black_list_file)
 
-            if not RallyBase.live_migration_supported():
-                func_list.append("no_live_migration")
+            if not self._migration_supported():
+                func_list.append("no_migration")
 
             if 'functionality' in black_list_yaml.keys():
                 for item in black_list_yaml['functionality']:
@@ -298,15 +290,14 @@ class RallyBase(testcase.TestCase):
 
         return black_tests
 
-    @staticmethod
-    def apply_blacklist(case_file_name, result_file_name):
+    def _apply_blacklist(self, case_file_name, result_file_name):
         """Apply blacklist."""
         LOGGER.debug("Applying blacklist...")
         cases_file = open(case_file_name, 'r')
         result_file = open(result_file_name, 'w')
 
-        black_tests = list(set(RallyBase.excl_func() +
-                               RallyBase.excl_scenario()))
+        black_tests = list(set(self.excl_func() +
+                               self.excl_scenario()))
 
         if black_tests:
             LOGGER.debug("Blacklisted tests: " + str(black_tests))
@@ -483,6 +474,7 @@ class RallyBase(testcase.TestCase):
         self.flavor_name = self.FLAVOR_NAME + self.guid
         self.flavor_alt_name = self.FLAVOR_ALT_NAME + self.guid
         self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
+        self.compute_cnt = snaps_utils.get_active_compute_cnt(self.os_creds)
 
         LOGGER.debug("Creating image '%s'...", self.image_name)
         image_creator = deploy_utils.create_image(
@@ -630,6 +622,7 @@ class RallyBase(testcase.TestCase):
         """Run testcase."""
         self.start_time = time.time()
         try:
+            conf_utils.create_rally_deployment()
             self._prepare_env()
             self._run_tests()
             self._generate_report()