diff options
Diffstat (limited to 'func')
-rw-r--r-- | func/args_handler.py | 18 | ||||
-rw-r--r-- | func/cli.py | 28 | ||||
-rw-r--r-- | func/env_setup.py | 6 |
3 files changed, 32 insertions, 20 deletions
diff --git a/func/args_handler.py b/func/args_handler.py index 59712800..624f90c4 100644 --- a/func/args_handler.py +++ b/func/args_handler.py @@ -14,8 +14,8 @@ from func.spawn_vm import SpawnVM from func.driver import Driver -def get_files_in_test_list(suite_name, case_type='all'): - benchmark_list = json.load(file('test_list/{0}'.format(suite_name))) +def get_files_in_suite(suite_name, case_type='all'): + benchmark_list = json.load(file('benchmarks/suite/{0}'.format(suite_name))) return reduce(add, benchmark_list.values()) \ if case_type == 'all' else benchmark_list[case_type] @@ -30,8 +30,8 @@ def get_benchmark_path(lab, suit, benchmark): return './test_cases/{0}/{1}/{2}'.format(lab, suit, benchmark) -def check_suite_in_test_list(suite_name): - return True if os.path.isfile('test_list/' + suite_name) else False +def check_suite(suite_name): + return True if os.path.isfile('benchmarks/suite/' + suite_name) else False def check_lab_name(lab_name): @@ -59,10 +59,12 @@ def prepare_ansible_env(benchmark_test_case): def run_benchmark(installer_type, pwd, benchmark, benchmark_details, proxy_info, env_setup, benchmark_test_case): driver = Driver() - return driver.drive_bench(installer_type, pwd, benchmark, - env_setup.roles_dict.items(), - _get_f_name(benchmark_test_case), - benchmark_details, env_setup.ip_pw_dict.items(), proxy_info) + result = driver.drive_bench(installer_type, pwd, benchmark, + env_setup.roles_dict.items(), + _get_f_name(benchmark_test_case), + benchmark_details, env_setup.ip_pw_dict.items(), proxy_info) + env_setup.cleanup_authorized_keys() + return result def prepare_and_run_benchmark(installer_type, pwd, benchmark_test_case): diff --git a/func/cli.py b/func/cli.py index d914a2de..c5f5d2b7 100644 --- a/func/cli.py +++ b/func/cli.py @@ -11,6 +11,9 @@ import sys import os import args_handler import argparse +from utils import logger_utils + +logger = logger_utils.QtipLogger('cli').get class Cli: @@ -26,40 +29,41 @@ class Cli: ' The user should list default after -l . all the fields in' ' the files are necessary and should be filled') parser.add_argument('-f', '--file', required=True, help='File in ' - 'test_list with the list of tests. there are three files' + 'benchmarks/suite/ with the list of tests. there are three files' '\n compute ' '\n storage ' '\n network ' 'They contain all the tests that will be run. They are listed by suite.' 'Please ensure there are no empty lines') parser.add_argument('-b', '--benchmark', help='Name of the benchmark.' - 'Can be found in test_lists/file_name') + 'Can be found in benchmarks/suite/file_name') return parser.parse_args(args) def __init__(self, args=sys.argv[1:]): args = self._parse_args(args) - if not args_handler.check_suite_in_test_list(args.file): - print('\n\n ERROR: Test File Does not exist in test_list/ please enter correct file \n\n') + if not args_handler.check_suite(args.file): + logger.error("ERROR: This suite file doesn't exist under benchmarks/suite/.\ + Please enter correct file." % str(args.file)) sys.exit(1) if not args_handler.check_lab_name(args.lab): - print('\n\n You have specified a lab that is not present in test_cases/ please enter \ - correct file. If unsure how to proceed, use -l default.\n\n') + logger.error("You have specified a lab that is not present under test_cases/.\ + Please enter correct file. If unsure how to proceed, use -l default.") sys.exit(1) suite = args.file - benchmarks = args_handler.get_files_in_test_list(suite) + benchmarks = args_handler.get_files_in_suite(suite) test_cases = args_handler.get_files_in_test_case(args.lab, suite) benchmarks_list = filter(lambda x: x in test_cases, benchmarks) if args.benchmark: if not args_handler.check_benchmark_name(args.lab, args.file, args.benchmark): - print('\n\n You have specified an incorrect benchmark. Please' - 'enter the correct one.\n\n') + logger.error("You have specified an incorrect benchmark.\ + Please enter the correct one.") sys.exit(1) else: - print("Starting with " + args.benchmark) + logger.info("Starting with " + args.benchmark) args_handler.prepare_and_run_benchmark( os.environ['INSTALLER_TYPE'], os.environ['PWD'], args_handler.get_benchmark_path(args.lab.lower(), args.file, args.benchmark)) @@ -68,5 +72,5 @@ class Cli: os.environ['INSTALLER_TYPE'], os.environ['PWD'], args_handler.get_benchmark_path(args.lab.lower(), suite, x)), benchmarks_list) - print('{0} is not a Template in the Directory Enter a Valid file name.' - 'or use qtip.py -h for list'.format(filter(lambda x: x not in test_cases, benchmarks))) + logger.info("{0} is not a Template in the Directory Enter a Valid file name.\ + or use qtip.py -h for list".format(filter(lambda x: x not in test_cases, benchmarks))) diff --git a/func/env_setup.py b/func/env_setup.py index 9e21a5b6..6027f904 100644 --- a/func/env_setup.py +++ b/func/env_setup.py @@ -208,3 +208,9 @@ class Env_setup: def call_ssh_test(self): self.ssh_test(self.ip_pw_list) + + def cleanup_authorized_keys(self): + for ip, pw in self.ip_pw_list: + cmd = './scripts/cleanup_creds.sh %s' % ip + logger.info("cleanup authorized_keys: %s " % cmd) + os.system(cmd) |