summaryrefslogtreecommitdiffstats
path: root/functest/ci/prepare_env.py
diff options
context:
space:
mode:
authorCristina Pauna <cristina.pauna@enea.com>2017-02-16 12:22:21 +0200
committerCristina Pauna <cristina.pauna@enea.com>2017-02-27 17:04:04 +0200
commitadbcb25389612d86d446d5f34787b1b2519c3b83 (patch)
tree2835532d04d2fde90819e2e8752e872be5dc1b60 /functest/ci/prepare_env.py
parentcbcf4f5b8805cc6a052fdf190e1cade2d75c02e0 (diff)
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 <cristina.pauna@enea.com>
Diffstat (limited to 'functest/ci/prepare_env.py')
-rwxr-xr-xfunctest/ci/prepare_env.py99
1 files changed, 63 insertions, 36 deletions
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py
index 5a9f99cb6..f5bae6a04 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()