diff options
Diffstat (limited to 'functest/opnfv_tests/openstack')
-rwxr-xr-x | functest/opnfv_tests/openstack/healthcheck/healthcheck.sh | 16 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/rally/rally.py | 12 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/snaps/health_check.py | 34 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/conf_utils.py | 58 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/tempest.py | 75 |
5 files changed, 113 insertions, 82 deletions
diff --git a/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh b/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh index 57aa0c70..7fa957c0 100755 --- a/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh +++ b/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh @@ -23,17 +23,17 @@ echo "">$LOG_FILE exec 1<>$LOG_FILE info () { - echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - INFO - " "$*" | tee -a $LOG_FILE 1>&2 + echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healthcheck - INFO - " "$*" | tee -a $LOG_FILE 1>&2 } debug () { if [[ "${CI_DEBUG,,}" == "true" ]]; then - echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - DEBUG - " "$*" | tee -a $LOG_FILE 1>&2 + echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healthcheck - DEBUG - " "$*" | tee -a $LOG_FILE 1>&2 fi } error () { - echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healtcheck - ERROR - " "$*" | tee -a $LOG_FILE 1>&2 + echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healthcheck - ERROR - " "$*" | tee -a $LOG_FILE 1>&2 exit 1 } @@ -125,16 +125,16 @@ kernel_img=$(cat ${YAML_FILE} | shyaml get-value healthcheck.kernel_image 2> /de ramdisk_img=$(cat ${YAML_FILE} | shyaml get-value healthcheck.ramdisk_image 2> /dev/null || true) extra_properties=$(cat ${YAML_FILE} | shyaml get-value healthcheck.extra_properties 2> /dev/null || true) -# Test if we need to create a 3part image +# Test if we need to create a 3party image if [ "X$kernel_img" != "X" ] then - img_id=$(glance image-create --name ${kernel_image} --disk-format aki \ + img_id=$(openstack image create ${kernel_image} --disk-format aki \ --container-format bare < ${kernel_img} | awk '$2 == "id" { print $4 }') extra_opts="--property kernel_id=${img_id}" if [ "X$ramdisk_img" != "X" ] then - img_id=$(glance image-create --name ${ramdisk_image} --disk-format ari \ + img_id=$(openstack image create ${ramdisk_image} --disk-format ari \ --container-format bare < ${ramdisk_img} | awk '$2 == "id" { print $4 }') extra_opts="$extra_opts --property ramdisk_id=${img_id}" fi @@ -152,10 +152,10 @@ fi debug "image extra_properties=${extra_properties}" -eval glance image-create --name ${image_1} --disk-format ${disk_format} --container-format bare \ +eval openstack image create ${image_1} --disk-format ${disk_format} --container-format bare \ ${extra_opts} < ${disk_img} debug "image '${image_1}' created." -eval glance image-create --name ${image_2} --disk-format ${disk_format} --container-format bare \ +eval openstack image create ${image_2} --disk-format ${disk_format} --container-format bare \ ${extra_opts} < ${disk_img} debug "image '${image_2}' created." info "... Glance OK!" diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index f984c368..46d6a570 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -66,6 +66,7 @@ class RallyBase(testcase_base.TestcaseBase): self.cinder_client = os_utils.get_cinder_client() self.network_dict = {} self.volume_type = None + self.smoke = None def _build_task_args(self, test_file_name): task_args = {'service_list': [test_file_name]} @@ -287,7 +288,7 @@ class RallyBase(testcase_base.TestcaseBase): cmd_line = ("rally task validate " "--task {0} " "--task-args \"{1}\"" - .format(task_file, self.__build_task_args(test_name))) + .format(task_file, self._build_task_args(test_name))) logger.debug('running command line: {}'.format(cmd_line)) p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) @@ -525,14 +526,13 @@ class RallyBase(testcase_base.TestcaseBase): self._run_tests() self._generate_report() self._clean_up() + res = testcase_base.TestcaseBase.EX_OK except Exception as e: logger.error('Error with run: %s' % e) - return testcase_base.TestcaseBase.EX_RUN_ERROR - self.stop_time = time.time() + res = testcase_base.TestcaseBase.EX_RUN_ERROR - # If we are here, it means that the test case was successfully executed - # criteria is managed by the criteria Field - return testcase_base.TestcaseBase.EX_OK + self.stop_time = time.time() + return res class RallySanity(RallyBase): diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py new file mode 100644 index 00000000..993c1000 --- /dev/null +++ b/functest/opnfv_tests/openstack/snaps/health_check.py @@ -0,0 +1,34 @@ +# Copyright (c) 2015 All rights reserved +# This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# +# http://www.apache.org/licenses/LICENSE-2.0 + +import unittest + +from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase +from snaps.openstack.tests.create_instance_tests import SimpleHealthCheck + +from functest.core.pytest_suite_runner import PyTestSuiteRunner +from functest.opnfv_tests.openstack.snaps import snaps_utils +from functest.utils.constants import CONST + + +class HealthCheck(PyTestSuiteRunner): + """ + This test executes the SNAPS Python Test case SimpleHealthCheck which + creates a VM with a single port with an IPv4 address that is assigned by + DHCP. This test then validates the expected IP with the actual + """ + def __init__(self): + super(HealthCheck, self).__init__() + + self.suite = unittest.TestSuite() + self.case_name = "snaps_health_check" + ext_net_name = snaps_utils.get_ext_net_name() + + self.suite.addTest( + OSIntegrationTestCase.parameterize( + SimpleHealthCheck, CONST.openstack_creds, ext_net_name, + use_keystone=CONST.snaps_use_keystone)) diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index 0c9064a1..03735baa 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -13,8 +13,6 @@ import re import shutil import subprocess -import opnfv.utils.constants as releng_constants - from functest.utils.constants import CONST import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils @@ -110,24 +108,19 @@ def get_verifier_deployment_dir(verifier_id, deployment_id): def configure_tempest(deployment_dir, IMAGE_ID=None, FLAVOR_ID=None): """ - Add/update needed parameters into tempest.conf file generated by Rally + Calls rally verify and updates the generated tempest.conf with + given parameters """ - tempest_conf_file = os.path.join(deployment_dir, "tempest.conf") - if os.path.isfile(tempest_conf_file): - logger.debug("Verifier is already configured.") - logger.debug("Reconfiguring the current verifier...") - cmd = "rally verify configure-verifier --reconfigure" - else: - logger.info("Configuring the verifier...") - cmd = "rally verify configure-verifier" - ft_utils.execute_command(cmd) + conf_verifier_result = configure_verifier(deployment_dir) + configure_tempest_update_params(conf_verifier_result, + IMAGE_ID, FLAVOR_ID) - logger.debug("Looking for tempest.conf file...") - if not os.path.isfile(tempest_conf_file): - logger.error("Tempest configuration file %s NOT found." - % tempest_conf_file) - return releng_constants.EXIT_RUN_ERROR +def configure_tempest_update_params(tempest_conf_file, + IMAGE_ID=None, FLAVOR_ID=None): + """ + Add/update needed parameters into tempest.conf file + """ logger.debug("Updating selected tempest.conf parameters...") config = ConfigParser.RawConfigParser() config.read(tempest_conf_file) @@ -178,7 +171,27 @@ def configure_tempest(deployment_dir, IMAGE_ID=None, FLAVOR_ID=None): shutil.copyfile(tempest_conf_file, os.path.join(TEMPEST_RESULTS_DIR, 'tempest.conf')) - return releng_constants.EXIT_OK + +def configure_verifier(deployment_dir): + """ + Execute rally verify configure-verifier, which generates tempest.conf + """ + tempest_conf_file = os.path.join(deployment_dir, "tempest.conf") + if os.path.isfile(tempest_conf_file): + logger.debug("Verifier is already configured.") + logger.debug("Reconfiguring the current verifier...") + cmd = "rally verify configure-verifier --reconfigure" + else: + logger.info("Configuring the verifier...") + cmd = "rally verify configure-verifier" + ft_utils.execute_command(cmd) + + logger.debug("Looking for tempest.conf file...") + if not os.path.isfile(tempest_conf_file): + logger.error("Tempest configuration file %s NOT found." + % tempest_conf_file) + raise Exception("Tempest configuration file %s NOT found." + % tempest_conf_file) def configure_tempest_multisite(deployment_dir): @@ -191,9 +204,8 @@ def configure_tempest_multisite(deployment_dir): logger.debug("Finding tempest.conf file...") tempest_conf_old = os.path.join(deployment_dir, 'tempest.conf') if not os.path.isfile(tempest_conf_old): - logger.error("Tempest configuration file %s NOT found." - % tempest_conf_old) - return releng_constants.EXIT_RUN_ERROR + raise Exception("Tempest configuration file %s NOT found." + % tempest_conf_old) # Copy tempest.conf to /home/opnfv/functest/results/tempest/ cur_path = os.path.split(os.path.realpath(__file__))[0] @@ -208,7 +220,7 @@ def configure_tempest_multisite(deployment_dir): # cmd = ("openstack endpoint show kingbird | grep publicurl |" # "awk '{print $4}' | awk -F '/' '{print $4}'") # kingbird_api_version = os.popen(cmd).read() - kingbird_api_version = os_utils.get_endpoint(service_type='kingbird') + kingbird_api_version = os_utils.get_endpoint(service_type='multisite') if CI_INSTALLER_TYPE == 'fuel': # For MOS based setup, the service is accessible @@ -265,5 +277,3 @@ def configure_tempest_multisite(deployment_dir): config.set('kingbird', 'api_version', kingbird_api_version) with open(tempest_conf_file, 'wb') as config_file: config.write(config_file) - - return releng_constants.EXIT_OK diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 9c19a147..13d9e4e6 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -57,7 +57,7 @@ class TempestCommon(testcase_base.TestcaseBase): CONST.tempest_identity_tenant_name, CONST.tempest_identity_tenant_description) if not tenant_id: - logger.error("Error : Failed to create %s tenant" + logger.error("Failed to create %s tenant" % CONST.tempest_identity_tenant_name) user_id = os_utils.create_user(keystone_client, @@ -65,7 +65,7 @@ class TempestCommon(testcase_base.TestcaseBase): CONST.tempest_identity_user_password, None, tenant_id) if not user_id: - logger.error("Error : Failed to create %s user" % + logger.error("Failed to create %s user" % CONST.tempest_identity_user_name) logger.debug("Creating private network for Tempest suite") @@ -74,8 +74,8 @@ class TempestCommon(testcase_base.TestcaseBase): CONST.tempest_private_subnet_name, CONST.tempest_router_name, CONST.tempest_private_subnet_cidr) - if not network_dic: - return testcase_base.TestcaseBase.EX_RUN_ERROR + if network_dic is None: + raise Exception('Failed to create private network') if CONST.tempest_use_custom_images: # adding alternative image should be trivial should we need it @@ -83,8 +83,8 @@ class TempestCommon(testcase_base.TestcaseBase): _, self.IMAGE_ID = os_utils.get_or_create_image( CONST.openstack_image_name, conf_utils.GLANCE_IMAGE_PATH, CONST.openstack_image_disk_format) - if not self.IMAGE_ID: - return testcase_base.TestcaseBase.EX_RUN_ERROR + if self.IMAGE_ID is None: + raise Exception('Failed to create image') if CONST.tempest_use_custom_flavors: # adding alternative flavor should be trivial should we need it @@ -94,10 +94,8 @@ class TempestCommon(testcase_base.TestcaseBase): CONST.openstack_flavor_ram, CONST.openstack_flavor_disk, CONST.openstack_flavor_vcpus) - if not self.FLAVOR_ID: - return testcase_base.TestcaseBase.EX_RUN_ERROR - - return testcase_base.TestcaseBase.EX_OK + if self.FLAVOR_ID is None: + raise Exception('Failed to create flavor') def generate_test_list(self, verifier_repo_dir): logger.debug("Generating test case list...") @@ -109,9 +107,8 @@ class TempestCommon(testcase_base.TestcaseBase): shutil.copyfile( conf_utils.TEMPEST_CUSTOM, conf_utils.TEMPEST_RAW_LIST) else: - logger.error("Tempest test list file %s NOT found." - % conf_utils.TEMPEST_CUSTOM) - return testcase_base.TestcaseBase.EX_RUN_ERROR + raise Exception("Tempest test list file %s NOT found." + % conf_utils.TEMPEST_CUSTOM) else: if self.MODE == 'smoke': testr_mode = "smoke" @@ -128,8 +125,6 @@ class TempestCommon(testcase_base.TestcaseBase): conf_utils.TEMPEST_RAW_LIST)) ft_utils.execute_command(cmd) - return testcase_base.TestcaseBase.EX_OK - def apply_tempest_blacklist(self): logger.debug("Applying tempest blacklist...") cases_file = self.read_file(conf_utils.TEMPEST_RAW_LIST) @@ -164,7 +159,6 @@ class TempestCommon(testcase_base.TestcaseBase): else: result_file.write(str(cases_line) + '\n') result_file.close() - return testcase_base.TestcaseBase.EX_OK def _parse_verification_id(line): first_pos = line.index("UUID=") + len("UUID=") @@ -217,7 +211,7 @@ class TempestCommon(testcase_base.TestcaseBase): f_env.close() def parse_verifier_result(self): - if not self.VERIFICATION_ID: + if self.VERIFICATION_ID is None: raise Exception('Verification UUID not found') cmd_line = "rally verify show --uuid {}".format(self.VERIFICATION_ID) @@ -249,12 +243,16 @@ class TempestCommon(testcase_base.TestcaseBase): output = logfile.read() error_logs = "" - for match in re.findall('(.*?)[. ]*FAILED', output): + for match in re.findall('(.*?)[. ]*fail ', output): error_logs += match + skipped_testcase = "" + for match in re.findall('(.*?)[. ]*skip:', output): + skipped_testcase += match self.details = {"tests": int(num_tests), "failures": int(num_failures), - "errors": error_logs} + "errors": error_logs, + "skipped": skipped_testcase} except Exception: success_rate = 0 @@ -270,33 +268,22 @@ class TempestCommon(testcase_base.TestcaseBase): if not os.path.exists(conf_utils.TEMPEST_RESULTS_DIR): os.makedirs(conf_utils.TEMPEST_RESULTS_DIR) - # Pre-configuration - res = self.create_tempest_resources() - if res != testcase_base.TestcaseBase.EX_OK: - return res - - res = conf_utils.configure_tempest(self.DEPLOYMENT_DIR, - self.IMAGE_ID, - self.FLAVOR_ID) - if res != testcase_base.TestcaseBase.EX_OK: - return res - - res = self.generate_test_list(self.VERIFIER_REPO_DIR) - if res != testcase_base.TestcaseBase.EX_OK: - return res - - res = self.apply_tempest_blacklist() - if res != testcase_base.TestcaseBase.EX_OK: - return res - - self.run_verifier_tests() - self.parse_verifier_result() + try: + self.create_tempest_resources() + conf_utils.configure_tempest(self.DEPLOYMENT_DIR, + self.IMAGE_ID, + self.FLAVOR_ID) + self.generate_test_list(self.VERIFIER_REPO_DIR) + self.apply_tempest_blacklist() + self.run_verifier_tests() + self.parse_verifier_result() + res = testcase_base.TestcaseBase.EX_OK + except Exception as e: + logger.error('Error with run: %s' % e) + res = testcase_base.TestcaseBase.EX_RUN_ERROR self.stop_time = time.time() - - # If we are here, it means that the test case was successfully executed - # criteria is managed by the criteria Field - return testcase_base.TestcaseBase.EX_OK + return res class TempestSmokeSerial(TempestCommon): |