diff options
Diffstat (limited to 'functest/ci')
-rwxr-xr-x | functest/ci/check_os.sh | 24 | ||||
-rw-r--r-- | functest/ci/config_aarch64_patch.yaml | 3 | ||||
-rw-r--r-- | functest/ci/config_functest.yaml | 29 | ||||
-rw-r--r-- | functest/ci/config_patch.yaml | 3 | ||||
-rwxr-xr-x | functest/ci/prepare_env.py | 94 | ||||
-rwxr-xr-x | functest/ci/run_tests.py | 29 | ||||
-rw-r--r-- | functest/ci/testcases.yaml | 2 |
7 files changed, 80 insertions, 104 deletions
diff --git a/functest/ci/check_os.sh b/functest/ci/check_os.sh index ce0bc20c..7b66f3da 100755 --- a/functest/ci/check_os.sh +++ b/functest/ci/check_os.sh @@ -6,12 +6,18 @@ # jose.lausuch@ericsson.com # +if [[ ${OS_INSECURE,,} == "true" ]]; then + options='--insecure' +else + options='' +fi + declare -A service_cmd_array -service_cmd_array['nova']='openstack server list' -service_cmd_array['neutron']='openstack network list' -service_cmd_array['keystone']='openstack endpoint list' -service_cmd_array['cinder']='openstack volume list' -service_cmd_array['glance']='openstack image list' +service_cmd_array['nova']="openstack $options server list" +service_cmd_array['neutron']="openstack $options network list" +service_cmd_array['keystone']="openstack $options endpoint list" +service_cmd_array['cinder']="openstack $options volume list" +service_cmd_array['glance']="openstack $options image list" MANDATORY_SERVICES='nova neutron keystone glance' OPTIONAL_SERVICES='cinder' @@ -41,7 +47,7 @@ check_service() { required=$2 fi echo ">>Checking ${service} service..." - if ! openstack service list | grep -i ${service} > /dev/null; then + if ! openstack $options service list | grep -i ${service} > /dev/null; then if [ "$required" == 'false' ]; then echo "WARN: Optional Service ${service} is not enabled!" return @@ -67,7 +73,7 @@ fi echo "Checking OpenStack endpoints:" -publicURL=$(openstack catalog show identity |awk '/public/ {print $4}') +publicURL=$(openstack $options catalog show identity |awk '/public/ {print $4}') publicIP=$(echo $publicURL|sed 's/^.*http.*\:\/\///'|sed 's/.[^:]*$//') publicPort=$(echo $publicURL|grep -Po '(?<=:)\d+') https_enabled=$(echo $publicURL | grep 'https') @@ -99,11 +105,11 @@ for service in $OPTIONAL_SERVICES; do done echo "Checking External network..." -networks=($(neutron net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}')) +networks=($(neutron $options net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}')) is_external=False for net in "${networks[@]}" do - is_external=$(neutron net-show $net|grep "router:external"|awk '{print $4}') + is_external=$(neutron $options net-show $net|grep "router:external"|awk '{print $4}') if [ $is_external == "True" ]; then echo "External network found: $net" break diff --git a/functest/ci/config_aarch64_patch.yaml b/functest/ci/config_aarch64_patch.yaml index cd395ab8..80cf4ccc 100644 --- a/functest/ci/config_aarch64_patch.yaml +++ b/functest/ci/config_aarch64_patch.yaml @@ -16,6 +16,9 @@ os: vping: image_name: TestVM + tempest: + use_custom_images: False + odl_sfc: image_base_url: "http://artifacts.opnfv.org/sfc/demo" image_name: sfc_nsh_danube diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml index 9b796071..623092a5 100644 --- a/functest/ci/config_functest.yaml +++ b/functest/ci/config_functest.yaml @@ -1,17 +1,7 @@ general: dir: - # Relative to the path where the repo is cloned: - vping: functest/opnfv_tests/openstack/vping - dir_odl: functest/opnfv_tests/sdn/odl - rally: functest/opnfv_tests/openstack/rally - tempest_cases: functest/opnfv_tests/openstack/tempest/custom_tests - onos: functest/opnfv_tests/sdn/onos/teston - onos_sfc: functest/opnfv_tests/sdn/onos/sfc - - # Absolute path home: /home/opnfv repos: /home/opnfv/repos - repo_functest: /home/opnfv/repos/functest dir_repo_rally: /home/opnfv/repos/rally repo_tempest: /home/opnfv/repos/tempest dir_repo_releng: /home/opnfv/repos/releng @@ -32,9 +22,7 @@ general: repo_securityscan: /home/opnfv/repos/securityscanning repo_vrouter: /home/opnfv/repos/vnfs/vrouter functest: /home/opnfv/functest - functest_test: /home/opnfv/repos/functest/functest/opnfv_tests results: /home/opnfv/functest/results - functest_logging_cfg: /home/opnfv/repos/functest/functest/ci/logging.ini functest_conf: /home/opnfv/functest/conf functest_data: /home/opnfv/functest/data ims_data: /home/opnfv/functest/data/ims/ @@ -71,15 +59,12 @@ general: neutron_private_subnet_gateway: 192.168.120.254 neutron_router_name: functest-router - functest: - testcases_yaml: /home/opnfv/repos/functest/functest/ci/testcases.yaml - snaps: use_keystone: True use_floating_ips: True -# images: -# cirros: -# disk_url: http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img + images: + cirros: + disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img # ARM # disk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img # kernel_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-kernel @@ -130,7 +115,7 @@ tempest: tenant_name: tempest tenant_description: Tenant for Tempest test suite user_name: tempest - user_password: tempest + user_password: Tempest123! validation: ssh_timeout: 130 object_storage: @@ -139,7 +124,7 @@ tempest: private_subnet_name: tempest-subnet private_subnet_cidr: 192.168.150.0/24 router_name: tempest-router - use_custom_images: False + use_custom_images: True use_custom_flavors: False volume_device_name: vdc @@ -150,10 +135,6 @@ rally: subnet_cidr: 192.168.140.0/24 router_name: rally-router -refstack: - tempest_conf_path: openstack/refstack_client/refstack_tempest.conf - defcore_list: openstack/refstack_client/defcore.txt - vnf: aaa: tenant_name: aaa diff --git a/functest/ci/config_patch.yaml b/functest/ci/config_patch.yaml index d47766b6..ad8b0889 100644 --- a/functest/ci/config_patch.yaml +++ b/functest/ci/config_patch.yaml @@ -13,16 +13,13 @@ fdio: flavor_extra_specs: {'hw:mem_page_size':'large'} image_properties: {'hw_mem_page_size':'large'} tempest: - use_custom_images: True use_custom_flavors: True ovs: general: flavor_extra_specs: {'hw:mem_page_size':'large'} image_properties: {'hw_mem_page_size':'large'} tempest: - use_custom_images: True use_custom_flavors: True multisite: tempest: - use_custom_images: True use_custom_flavors: True diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py index 8e17a4fc..64fcc925 100755 --- a/functest/ci/prepare_env.py +++ b/functest/ci/prepare_env.py @@ -11,6 +11,7 @@ import json import logging import logging.config import os +import pkg_resources import re import subprocess import sys @@ -34,14 +35,15 @@ handler = None pod_arch = None arch_filter = ['aarch64'] -CONFIG_FUNCTEST_PATH = CONST.__getattribute__('CONFIG_FUNCTEST_YAML') -CONFIG_PATCH_PATH = os.path.join(os.path.dirname( - CONFIG_FUNCTEST_PATH), "config_patch.yaml") -CONFIG_AARCH64_PATCH_PATH = os.path.join(os.path.dirname( - CONFIG_FUNCTEST_PATH), "config_aarch64_patch.yaml") -RALLY_CONF_PATH = os.path.join("/etc/rally/rally.conf") -RALLY_AARCH64_PATCH_PATH = os.path.join(os.path.dirname( - CONFIG_FUNCTEST_PATH), "rally_aarch64_patch.conf") +CONFIG_FUNCTEST_PATH = pkg_resources.resource_filename( + 'functest', 'ci/config_functest.yaml') +CONFIG_PATCH_PATH = pkg_resources.resource_filename( + 'functest', 'ci/config_patch.yaml') +CONFIG_AARCH64_PATCH_PATH = pkg_resources.resource_filename( + 'functest', 'ci/config_aarch64_patch.yaml') +RALLY_CONF_PATH = "/etc/rally/rally.conf" +RALLY_AARCH64_PATCH_PATH = pkg_resources.resource_filename( + 'functest', 'ci/rally_aarch64_patch.conf') class PrepareEnvParser(object): @@ -83,11 +85,9 @@ def check_env_variables(): % CONST.__getattribute__('INSTALLER_TYPE')) if CONST.__getattribute__('INSTALLER_IP') is None: - logger.warning("The env variable 'INSTALLER_IP' is not defined. " - "It is needed to fetch the OpenStack credentials. " - "If the credentials are not provided to the " - "container as a volume, please add this env variable " - "to the 'docker run' command.") + logger.warning( + "The env variable 'INSTALLER_IP' is not defined. It is recommended" + " to extract some information from the deployment") else: logger.info(" INSTALLER_IP=%s" % CONST.__getattribute__('INSTALLER_IP')) @@ -116,9 +116,8 @@ def get_deployment_handler(): global handler global pod_arch - installer_params_yaml = os.path.join( - CONST.__getattribute__('dir_repo_functest'), - 'functest/ci/installer_params.yaml') + installer_params_yaml = pkg_resources.resource_filename( + 'functest', 'ci/installer_params.yaml') if (CONST.__getattribute__('INSTALLER_IP') and CONST.__getattribute__('INSTALLER_TYPE') and CONST.__getattribute__('INSTALLER_TYPE') in @@ -177,7 +176,6 @@ def create_directories(): def source_rc_file(): print_separator() - logger.info("Fetching RC file...") if CONST.__getattribute__('openstack_creds') is None: logger.warning("The environment variable 'creds' must be set and" @@ -187,38 +185,17 @@ def source_rc_file(): CONST.__getattribute__('dir_functest_conf'), 'openstack.creds') if not os.path.isfile(CONST.__getattribute__('openstack_creds')): - logger.info("RC file not provided. " - "Fetching it from the installer...") - if CONST.__getattribute__('INSTALLER_IP')is None: - logger.error("The env variable 'INSTALLER_IP' must be provided in" - " order to fetch the credentials from the installer.") - raise Exception("Missing CI_INSTALLER_IP.") - if (CONST.__getattribute__('INSTALLER_TYPE') not in - opnfv_constants.INSTALLERS): - logger.error("Cannot fetch credentials. INSTALLER_TYPE=%s is " - "not a valid OPNFV installer. Available " - "installers are : %s." % - (CONST.__getattribute__('INSTALLER_TYPE'), - opnfv_constants.INSTALLERS)) - raise Exception("Wrong INSTALLER_TYPE.") - - cmd = ("/home/opnfv/repos/releng/utils/fetch_os_creds.sh " - "-d %s -i %s -a %s" - % (CONST.__getattribute__('openstack_creds'), - CONST.__getattribute__('INSTALLER_TYPE'), - CONST.__getattribute__('INSTALLER_IP'))) - logger.debug("Executing command: %s" % cmd) - p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) - output = p.communicate()[0] - logger.debug("\n%s" % output) - if p.returncode != 0: - raise Exception("Failed to fetch credentials from installer.") + raise Exception( + "OpenStack credentials file not provided. " + "The OpenStack credentials must be in {}" + .format(CONST.__getattribute__('openstack_creds'))) else: logger.info("RC file provided in %s." % CONST.__getattribute__('openstack_creds')) if os.path.getsize(CONST.__getattribute__('openstack_creds')) == 0: - raise Exception("The file %s is empty." % - CONST.__getattribute__('openstack_creds')) + raise Exception( + "The OpenStack RC file {} is empty." + .format(CONST.__getattribute__('openstack_creds'))) logger.info("Sourcing the OpenStack RC file...") os_utils.source_credentials(CONST.__getattribute__('openstack_creds')) @@ -234,12 +211,15 @@ def source_rc_file(): CONST.__setattr__('OS_PASSWORD', value) -def patch_config_file(): +def update_config_file(): patch_file(CONFIG_PATCH_PATH) if pod_arch and pod_arch in arch_filter: patch_file(CONFIG_AARCH64_PATCH_PATH) + if "TEST_DB_URL" in os.environ: + update_db_url() + def patch_file(patch_file_path): logger.debug('Updating file: %s', patch_file_path) @@ -257,14 +237,22 @@ def patch_file(patch_file_path): os.remove(CONFIG_FUNCTEST_PATH) with open(CONFIG_FUNCTEST_PATH, "w") as f: f.write(yaml.dump(new_functest_yaml, default_style='"')) - f.close() + + +def update_db_url(): + with open(CONFIG_FUNCTEST_PATH) as f: + functest_yaml = yaml.safe_load(f) + + with open(CONFIG_FUNCTEST_PATH, "w") as f: + functest_yaml["results"]["test_db_url"] = os.environ.get('TEST_DB_URL') + f.write(yaml.dump(functest_yaml, default_style='"')) def verify_deployment(): print_separator() logger.info("Verifying OpenStack services...") - cmd = ("%s/functest/ci/check_os.sh" % - CONST.__getattribute__('dir_repo_functest')) + cmd = ("%s" % pkg_resources.resource_filename( + 'functest', 'ci/check_os.sh')) logger.debug("Executing command: %s" % cmd) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) @@ -378,10 +366,9 @@ def main(**kwargs): elif kwargs['action'] == "start": logger.info("######### Preparing Functest environment #########\n") check_env_variables() - get_deployment_handler() create_directories() source_rc_file() - patch_config_file() + update_config_file() verify_deployment() install_rally() install_tempest() @@ -389,7 +376,6 @@ def main(**kwargs): with open(CONST.__getattribute__('env_active'), "w") as env_file: env_file.write("1") check_environment() - print_deployment_info() elif kwargs['action'] == "check": check_environment() except Exception as e: @@ -399,8 +385,8 @@ def main(**kwargs): if __name__ == '__main__': - logging.config.fileConfig( - CONST.__getattribute__('dir_functest_logging_cfg')) + logging.config.fileConfig(pkg_resources.resource_filename( + 'functest', 'ci/logging.ini')) parser = PrepareEnvParser() args = parser.parse_args(sys.argv[1:]) sys.exit(main(**args)) diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index af45c321..722df14f 100755 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -14,6 +14,7 @@ import importlib import logging import logging.config import os +import pkg_resources import re import sys @@ -201,7 +202,7 @@ class Runner(object): _tiers = tb.TierBuilder( CONST.__getattribute__('INSTALLER_TYPE'), CONST.__getattribute__('DEPLOY_SCENARIO'), - CONST.__getattribute__("functest_testcases_yaml")) + pkg_resources.resource_filename('functest', 'ci/testcases.yaml')) if kwargs['noclean']: self.clean_flag = False @@ -251,24 +252,26 @@ class Runner(object): msg.add_row([env_var, CONST.__getattribute__(env_var)]) logger.info("Deployment description: \n\n%s\n", msg) - msg = prettytable.PrettyTable( - header_style='upper', padding_width=5, - field_names=['test case', 'project', 'tier', 'duration', 'result']) - for test_case in self.executed_test_cases: - result = 'PASS' if(test_case.is_successful( - ) == test_case.EX_OK) else 'FAIL' - msg.add_row([test_case.case_name, test_case.project_name, - _tiers.get_tier_name(test_case.case_name), - test_case.get_duration(), result]) - logger.info("FUNCTEST REPORT: \n\n%s\n", msg) + if len(self.executed_test_cases) > 1: + msg = prettytable.PrettyTable( + header_style='upper', padding_width=5, + field_names=['test case', 'project', 'tier', + 'duration', 'result']) + for test_case in self.executed_test_cases: + result = 'PASS' if(test_case.is_successful( + ) == test_case.EX_OK) else 'FAIL' + msg.add_row([test_case.case_name, test_case.project_name, + _tiers.get_tier_name(test_case.case_name), + test_case.get_duration(), result]) + logger.info("FUNCTEST REPORT: \n\n%s\n", msg) logger.info("Execution exit value: %s" % self.overall_result) return self.overall_result if __name__ == '__main__': - logging.config.fileConfig( - CONST.__getattribute__('dir_functest_logging_cfg')) + logging.config.fileConfig(pkg_resources.resource_filename( + 'functest', 'ci/logging.ini')) parser = RunTestsParser() args = parser.parse_args(sys.argv[1:]) runner = Runner() diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml index 7d518324..c30292bc 100644 --- a/functest/ci/testcases.yaml +++ b/functest/ci/testcases.yaml @@ -447,7 +447,7 @@ tiers: installer: 'fuel' scenario: 'kvm_ovs_dpdk_bar' run: - module: 'functest.opnfv_tests.features.barometer' + module: 'baro_tests.barometer' class: 'BarometerCollectd' - |