diff options
Diffstat (limited to 'sfc/tests')
-rw-r--r-- | sfc/tests/functest/config.yaml | 12 | ||||
-rw-r--r-- | sfc/tests/functest/run_sfc_tests.py | 76 | ||||
-rw-r--r-- | sfc/tests/functest/sfc_one_chain_two_service_functions.py | 13 | ||||
-rw-r--r-- | sfc/tests/functest/sfc_symmetric_chain.py | 9 | ||||
-rw-r--r-- | sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py | 15 |
5 files changed, 86 insertions, 39 deletions
diff --git a/sfc/tests/functest/config.yaml b/sfc/tests/functest/config.yaml index d28456dd..b844880d 100644 --- a/sfc/tests/functest/config.yaml +++ b/sfc/tests/functest/config.yaml @@ -8,11 +8,13 @@ defaults: image_name: sfc_nsh_danube image_file_name: sfc_nsh_danube.qcow2 installer: - type: fuel - ip: 10.20.0.2 - user: root - password: r00tme - cluster: 1 # Change this to the id of the desired fuel env (1, 2, 3...) + fuel: + user: root + password: r00tme + cluster: 1 # Change this to the id of the desired fuel env (1, 2, 3...) + apex: + user: stack + pkey_file: "/root/.ssh/id_rsa" image_format: qcow2 url: "http://artifacts.opnfv.org/sfc/images" vnfd-dir: "vnfd-templates" diff --git a/sfc/tests/functest/run_sfc_tests.py b/sfc/tests/functest/run_sfc_tests.py index c569165b..edf9595e 100644 --- a/sfc/tests/functest/run_sfc_tests.py +++ b/sfc/tests/functest/run_sfc_tests.py @@ -14,8 +14,8 @@ import time import sys import yaml -from functest.core import testcase from functest.utils import openstack_utils as os_utils +from functest.core import testcase from opnfv.utils import ovs_logger as ovs_log from opnfv.deployment.factory import Factory as DeploymentFactory from sfc.lib import cleanup as sfc_cleanup @@ -40,8 +40,43 @@ class SfcFunctest(testcase.OSGCTestCase): logger.info("found tackerc file") return rc_file - def __disable_heat_resource_finder_cache(self, nodes): - controllers = [node for node in nodes if node.is_controller()] + def __disable_heat_resource_finder_cache_apex(self, controllers): + remote_heat_conf_etc = '/etc/heat/heat.conf' + remote_heat_conf_home = '/home/heat-admin/heat.conf' + local_heat_conf = '/tmp/heat.conf' + cmd_restart_heat = ("sudo" + " /bin/systemctl" + " restart" + " openstack-heat-engine.service" + ) + for controller in controllers: + logger.info("Fetch {0} from controller {1}" + .format(remote_heat_conf_etc, controller.ip)) + controller.run_cmd('sudo cp {0} /home/heat-admin/' + .format(remote_heat_conf_etc)) + controller.run_cmd('sudo chmod 777 {0}' + .format(remote_heat_conf_home)) + controller.get_file(remote_heat_conf_home, local_heat_conf) + with open(local_heat_conf, 'a') as cfg: + cfg.write('\n[resource_finder_cache]\n') + cfg.write('caching=False\n') + logger.info("Replace {0} with {1} in controller {2}" + .format(remote_heat_conf_etc, + local_heat_conf, + controller.ip)) + controller.run_cmd('sudo rm -f {0}'.format(remote_heat_conf_home)) + controller.run_cmd('sudo rm -f {0}'.format(remote_heat_conf_etc)) + controller.put_file(local_heat_conf, + remote_heat_conf_home) + controller.run_cmd('sudo cp {0} /etc/heat/' + .format(remote_heat_conf_home)) + logger.info("Restart heat-engine in {0}".format(controller.ip)) + controller.run_cmd(cmd_restart_heat) + os.remove(local_heat_conf) + logger.info("Waiting for heat-engine to restart in controllers") + time.sleep(10) + + def __disable_heat_resource_finder_cache_fuel(self, controllers): remote_heat_conf = '/etc/heat/heat.conf' local_heat_conf = '/tmp/heat.conf' for controller in controllers: @@ -63,32 +98,45 @@ class SfcFunctest(testcase.OSGCTestCase): logger.info("Waiting for heat-engine to restart in controllers") time.sleep(10) + def __disable_heat_resource_finder_cache(self, nodes, installer_type): + controllers = [node for node in nodes if node.is_controller()] + + if installer_type == 'apex': + self.__disable_heat_resource_finder_cache_apex(controllers) + elif installer_type == "fuel": + self.__disable_heat_resource_finder_cache_fuel(controllers) + else: + raise Exception('Unsupported installer') + def run(self): deploymentHandler = DeploymentFactory.get_handler( COMMON_CONFIG.installer_type, COMMON_CONFIG.installer_ip, COMMON_CONFIG.installer_user, - installer_pwd=COMMON_CONFIG.installer_password) + COMMON_CONFIG.installer_password, + COMMON_CONFIG.installer_key_file) cluster = COMMON_CONFIG.installer_cluster nodes = (deploymentHandler.get_nodes({'cluster': cluster}) if cluster is not None else deploymentHandler.get_nodes()) - a_controller = [node for node in nodes - if node.is_controller()][0] + self.__disable_heat_resource_finder_cache(nodes, + COMMON_CONFIG.installer_type) - self.__disable_heat_resource_finder_cache(nodes) + if COMMON_CONFIG.installer_type == 'fuel': + a_controller = [node for node in nodes + if node.is_controller()][0] - rc_file = self.__fetch_tackerc_file(a_controller) - os_utils.source_credentials(rc_file) + rc_file = self.__fetch_tackerc_file(a_controller) + os_utils.source_credentials(rc_file) - logger.info("Updating env with {0}".format(rc_file)) - logger.info("OS credentials:") - for var, value in os.environ.items(): - if var.startswith("OS_"): - logger.info("\t{0}={1}".format(var, value)) + logger.info("Updating env with {0}".format(rc_file)) + logger.info("OS credentials:") + for var, value in os.environ.items(): + if var.startswith("OS_"): + logger.info("\t{0}={1}".format(var, value)) odl_ip, odl_port = sfc_utils.get_odl_ip_port(nodes) diff --git a/sfc/tests/functest/sfc_one_chain_two_service_functions.py b/sfc/tests/functest/sfc_one_chain_two_service_functions.py index 3f1165ec..695c8b36 100644 --- a/sfc/tests/functest/sfc_one_chain_two_service_functions.py +++ b/sfc/tests/functest/sfc_one_chain_two_service_functions.py @@ -7,13 +7,11 @@ # # http://www.apache.org/licenses/LICENSE-2.0 # - import os import sys import threading - import logging -from functest.utils.constants import CONST + import functest.utils.openstack_tacker as os_tacker import functest.utils.openstack_utils as os_utils import opnfv.utils.ovs_logger as ovs_log @@ -40,9 +38,11 @@ def main(): COMMON_CONFIG.installer_type, COMMON_CONFIG.installer_ip, COMMON_CONFIG.installer_user, - installer_pwd=COMMON_CONFIG.installer_password) + COMMON_CONFIG.installer_password, + COMMON_CONFIG.installer_key_file) cluster = COMMON_CONFIG.installer_cluster + openstack_nodes = (deploymentHandler.get_nodes({'cluster': cluster}) if cluster is not None else deploymentHandler.get_nodes()) @@ -55,7 +55,7 @@ def main(): odl_ip, odl_port = test_utils.get_odl_ip_port(openstack_nodes) for compute in compute_nodes: - logger.info("This is a compute: %s" % compute.info) + logger.info("This is a compute: %s" % compute.ip) results = Results(COMMON_CONFIG.line_length) results.add_to_summary(0, "=") @@ -275,6 +275,5 @@ def main(): if __name__ == '__main__': - logging.config.fileConfig( - CONST.__getattribute__('dir_functest_logging_cfg')) + logging.config.fileConfig(COMMON_CONFIG.functest_logging_api) main() diff --git a/sfc/tests/functest/sfc_symmetric_chain.py b/sfc/tests/functest/sfc_symmetric_chain.py index 686d7fc0..cdcd8d3a 100644 --- a/sfc/tests/functest/sfc_symmetric_chain.py +++ b/sfc/tests/functest/sfc_symmetric_chain.py @@ -12,8 +12,8 @@ import os import sys import threading - import logging + import functest.utils.openstack_tacker as os_tacker import functest.utils.openstack_utils as os_utils import opnfv.utils.ovs_logger as ovs_log @@ -25,7 +25,6 @@ from sfc.lib.results import Results import sfc.lib.topology_shuffler as topo_shuffler -from functest.utils.constants import CONST logger = logging.getLogger(__name__) CLIENT = "client" @@ -39,7 +38,8 @@ def main(): COMMON_CONFIG.installer_type, COMMON_CONFIG.installer_ip, COMMON_CONFIG.installer_user, - installer_pwd=COMMON_CONFIG.installer_password) + COMMON_CONFIG.installer_password, + COMMON_CONFIG.installer_key_file) cluster = COMMON_CONFIG.installer_cluster all_nodes = (deploymentHandler.get_nodes({'cluster': cluster}) @@ -250,6 +250,5 @@ def main(): if __name__ == '__main__': - logging.config.fileConfig( - CONST.__getattribute__('dir_functest_logging_cfg')) + logging.config.fileConfig(COMMON_CONFIG.functest_logging_api) main() diff --git a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py index 7f121b93..f0c5844e 100644 --- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py +++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py @@ -11,8 +11,8 @@ import os import sys import threading - import logging + import functest.utils.openstack_tacker as os_tacker import functest.utils.openstack_utils as os_utils import opnfv.utils.ovs_logger as ovs_log @@ -23,7 +23,6 @@ from sfc.lib.results import Results from opnfv.deployment.factory import Factory as DeploymentFactory import sfc.lib.topology_shuffler as topo_shuffler -from functest.utils.constants import CONST logger = logging.getLogger(__name__) @@ -38,7 +37,8 @@ def main(): COMMON_CONFIG.installer_type, COMMON_CONFIG.installer_ip, COMMON_CONFIG.installer_user, - installer_pwd=COMMON_CONFIG.installer_password) + COMMON_CONFIG.installer_password, + COMMON_CONFIG.installer_key_file) cluster = COMMON_CONFIG.installer_cluster openstack_nodes = (deploymentHandler.get_nodes({'cluster': cluster}) @@ -53,7 +53,7 @@ def main(): odl_ip, odl_port = test_utils.get_odl_ip_port(openstack_nodes) for compute in compute_nodes: - logger.info("This is a compute: %s" % compute.info) + logger.info("This is a compute: %s" % compute.ip) results = Results(COMMON_CONFIG.line_length) results.add_to_summary(0, "=") @@ -61,9 +61,9 @@ def main(): results.add_to_summary(0, "=") installer_type = os.environ.get("INSTALLER_TYPE") - if installer_type != "fuel": + if installer_type != "fuel" and installer_type != "apex": logger.error( - '\033[91mCurrently supported only Fuel Installer type\033[0m') + '\033[91mCurrently supported only Fuel and Apex\033[0m') sys.exit(1) installer_ip = os.environ.get("INSTALLER_IP") @@ -321,6 +321,5 @@ def main(): if __name__ == '__main__': - logging.config.fileConfig( - CONST.__getattribute__('dir_functest_logging_cfg')) + logging.config.fileConfig(COMMON_CONFIG.functest_logging_api) main() |