From adbcb25389612d86d446d5f34787b1b2519c3b83 Mon Sep 17 00:00:00 2001 From: Cristina Pauna Date: Thu, 16 Feb 2017 12:22:21 +0200 Subject: Add aarch64 custom config In order to run functest on an aarch64 POD, some custom configuration is needed. Up until now that custom configuration was put on the arm jenkins slave. With this commit it is integrated in functest project. 1. In order to identify if the POD is aarch64 or x86 function get_arch() from https://gerrit.opnfv.org/gerrit/#/c/29099 is used 2. Changes to config_functest.yaml are made via a new patch file config_aarch64_patch.yaml which is applied for all scenarios. Function patch_config_file() is modified to be more generic. It now receives a file as parameter and merges any type of patch file 3. The aarch64 cirros images are downloaded into the data directory. Functest can be run from both an aarch64 or a x86 jenkins slave in order to test an aarch64 POD. So the images are downloded in both dockerfiles 4. Other custom config needs to be added to /etc/rally/rally.conf in the docker. The custom config is set in rally_aarch64_patch.conf and inserted in the needed file before the rally environment is set up JIRA: ARMBAND-60 Change-Id: I8e460cdf02d297c259cbbd9c05e7983367fd2bb9 Signed-off-by: Cristina Pauna --- functest/ci/config_aarch64_patch.yaml | 20 +++++++ functest/ci/prepare_env.py | 99 ++++++++++++++++++++++------------- functest/ci/rally_aarch64_patch.conf | 5 ++ 3 files changed, 88 insertions(+), 36 deletions(-) create mode 100644 functest/ci/config_aarch64_patch.yaml create mode 100644 functest/ci/rally_aarch64_patch.conf (limited to 'functest/ci') diff --git a/functest/ci/config_aarch64_patch.yaml b/functest/ci/config_aarch64_patch.yaml new file mode 100644 index 00000000..9a345e3f --- /dev/null +++ b/functest/ci/config_aarch64_patch.yaml @@ -0,0 +1,20 @@ +os: + general: + openstack: + image_name: TestVM + image_file_name: cirros-d161201-aarch64-disk.img + image_password: gocubsgo + + snaps_simple_healthcheck: + disk_image: /home/opnfv/functest/data/cirros-d161201-aarch64-disk.img + kernel_image: /home/opnfv/functest/data/cirros-d161201-aarch64-kernel + ramdisk_image: /home/opnfv/functest/data/cirros-d161201-aarch64-initramfs + extra_properties: + os_command_line: root=/dev/vdb1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0 + hw_video_model: vga + + vping: + image_name: TestVM + + doctor: + image_name: TestVM diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py index 5a9f99cb..f5bae6a0 100755 --- a/functest/ci/prepare_env.py +++ b/functest/ci/prepare_env.py @@ -12,6 +12,7 @@ import os import re import subprocess import sys +import fileinput import yaml @@ -27,14 +28,18 @@ actions = ['start', 'check'] """ logging configuration """ logger = ft_logger.Logger("prepare_env").getLogger() - +handler = None +# set the architecture to default +pod_arch = None CONFIG_FUNCTEST_PATH = CONST.CONFIG_FUNCTEST_YAML CONFIG_PATCH_PATH = os.path.join(os.path.dirname( CONFIG_FUNCTEST_PATH), "config_patch.yaml") - -with open(CONFIG_PATCH_PATH) as f: - functest_patch_yaml = yaml.safe_load(f) +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") class PrepareEnvParser(object): @@ -102,6 +107,34 @@ def check_env_variables(): logger.info(" IS_CI_RUN=%s" % CONST.IS_CI_RUN) +def get_deployment_handler(): + global handler + global pod_arch + + installer_params_yaml = os.path.join(CONST.dir_repo_functest, + 'functest/ci/installer_params.yaml') + if (CONST.INSTALLER_IP and CONST.INSTALLER_TYPE and + CONST.INSTALLER_TYPE in opnfv_constants.INSTALLERS): + installer_params = ft_utils.get_parameter_from_yaml( + CONST.INSTALLER_TYPE, installer_params_yaml) + + user = installer_params.get('user', None) + password = installer_params.get('password', None) + pkey = installer_params.get('pkey', None) + + try: + handler = factory.Factory.get_handler( + installer=CONST.INSTALLER_TYPE, + installer_ip=CONST.INSTALLER_IP, + installer_user=user, + installer_pwd=password, + pkey_file=pkey) + if handler: + pod_arch = handler.get_arch() + except Exception as e: + logger.debug("Cannot get deployment information. %s" % e) + + def create_directories(): print_separator() logger.info("Creating needed directories...") @@ -177,12 +210,18 @@ def source_rc_file(): CONST.OS_PASSWORD = value -def patch_config_file(): +def patch_config_file(patch_file_path, arch_filter=None): + if arch_filter and pod_arch not in arch_filter: + return + + with open(patch_file_path) as f: + patch_file = yaml.safe_load(f) + updated = False - for key in functest_patch_yaml: + for key in patch_file: if key in CONST.DEPLOY_SCENARIO: new_functest_yaml = dict(ft_utils.merge_dicts( - ft_utils.get_functest_yaml(), functest_patch_yaml[key])) + ft_utils.get_functest_yaml(), patch_file[key])) updated = True if updated: @@ -210,6 +249,17 @@ def verify_deployment(): def install_rally(): print_separator() + + if 'aarch64' in pod_arch: + logger.info("Apply aarch64 specific to rally config...") + with open(RALLY_AARCH64_PATCH_PATH, "r") as f: + rally_patch_conf = f.read() + + for line in fileinput.input(RALLY_CONF_PATH, inplace=1): + print line, + if "cirros|testvm" in line: + print rally_patch_conf + logger.info("Creating Rally environment...") cmd = "rally deployment destroy opnfv-rally" @@ -284,34 +334,9 @@ def check_environment(): def print_deployment_info(): - installer_params_yaml = os.path.join(CONST.dir_repo_functest, - 'functest/ci/installer_params.yaml') - if (CONST.INSTALLER_IP and CONST.INSTALLER_TYPE and - CONST.INSTALLER_TYPE in opnfv_constants.INSTALLERS): - try: - installer_params = ft_utils.get_parameter_from_yaml( - CONST.INSTALLER_TYPE, installer_params_yaml) - except ValueError as e: - logger.debug('Printing deployment info is not supported for %s' % - CONST.INSTALLER_TYPE) - logger.debug(e) - else: - user = installer_params.get('user', None) - password = installer_params.get('password', None) - pkey = installer_params.get('pkey', None) - - try: - handler = factory.Factory.get_handler( - installer=CONST.INSTALLER_TYPE, - installer_ip=CONST.INSTALLER_IP, - installer_user=user, - installer_pwd=password, - pkey_file=pkey) - if handler: - logger.info('\n\nDeployment information:\n%s' % - handler.get_deployment_info()) - except Exception as e: - logger.debug("Cannot get deployment information. %s" % e) + if handler: + logger.info('\n\nDeployment information:\n%s' % + handler.get_deployment_info()) def main(**kwargs): @@ -322,9 +347,11 @@ 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() + patch_config_file(CONFIG_PATCH_PATH) + patch_config_file(CONFIG_AARCH64_PATCH_PATH, 'aarch64') verify_deployment() install_rally() install_tempest() diff --git a/functest/ci/rally_aarch64_patch.conf b/functest/ci/rally_aarch64_patch.conf new file mode 100644 index 00000000..a49588bf --- /dev/null +++ b/functest/ci/rally_aarch64_patch.conf @@ -0,0 +1,5 @@ +img_name_regex = ^TestVM$ +img_url = http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img +flavor_ref_ram = 128 +flavor_ref_alt_ram = 256 +heat_instance_type_ram = 128 -- cgit 1.2.3-korg