def test_get_functest_yaml(self):
     with mock.patch('six.moves.builtins.open', mock.mock_open()), \
             mock.patch('functest.utils.functest_utils.yaml.safe_load') \
             as mock_yaml:
         mock_yaml.return_value = self.file_yaml
         resp = functest_utils.get_functest_yaml()
         self.assertEqual(resp, self.file_yaml)
Exemple #2
0
def patch_config_file():
    updated = False
    for key in functest_patch_yaml:
        if key in CONST.DEPLOY_SCENARIO:
            new_functest_yaml = dict(ft_utils.merge_dicts(
                ft_utils.get_functest_yaml(), functest_patch_yaml[key]))
            updated = True

    if updated:
        os.remove(CONFIG_FUNCTEST_PATH)
        with open(CONFIG_FUNCTEST_PATH, "w") as f:
            f.write(yaml.dump(new_functest_yaml, default_style='"'))
        f.close()
Exemple #3
0
def patch_file(patch_file_path):
    logger.debug('Updating file: %s', patch_file_path)
    with open(patch_file_path) as f:
        patch_file = yaml.safe_load(f)

    updated = False
    for key in patch_file:
        if key in CONST.__getattribute__('DEPLOY_SCENARIO'):
            new_functest_yaml = dict(ft_utils.merge_dicts(
                ft_utils.get_functest_yaml(), patch_file[key]))
            updated = True

    if updated:
        os.remove(CONFIG_FUNCTEST_PATH)
        with open(CONFIG_FUNCTEST_PATH, "w") as f:
            f.write(yaml.dump(new_functest_yaml, default_style='"'))
Exemple #4
0
import argparse
import os
import time

import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as functest_utils
import functest.utils.functest_constants as ft_constants

parser = argparse.ArgumentParser()
parser.add_argument("-r",
                    "--report",
                    help="Create json result file",
                    action="store_true")
args = parser.parse_args()

functest_yaml = functest_utils.get_functest_yaml()

DOCTOR_REPO_DIR = ft_constants.DOCTOR_REPO_DIR
RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR

logger = ft_logger.Logger("doctor").getLogger()


def main():
    exit_code = -1

    # if the image name is explicitly set for the doctor suite, set it as
    # enviroment variable
    if 'doctor' in functest_yaml and 'image_name' in functest_yaml['doctor']:
        os.environ["IMAGE_NAME"] = functest_yaml['doctor']['image_name']