From b592dcb2ebb59b7d634ce10f724d90b05cc02f38 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 14 May 2020 08:35:11 +0200 Subject: [PATCH 1/5] Fix case setup output with --verbose --- testing_and_setup/compass/manage_regression_suite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing_and_setup/compass/manage_regression_suite.py b/testing_and_setup/compass/manage_regression_suite.py index a8ef17551a..ef40ea720b 100755 --- a/testing_and_setup/compass/manage_regression_suite.py +++ b/testing_and_setup/compass/manage_regression_suite.py @@ -502,7 +502,7 @@ def summarize_suite(suite_tag): # {{{ cmd = ['cat', args.work_dir + '/manage_regression_suite.py.out'] print('\nCase setup output:') - print(subprocess.check_output(cmd)) + print(subprocess.check_output(cmd).decode('utf-8')) write_history = True # Write the history of this command to the command_history file, for From e7862e43a13507fec94a299149a28487e85879c2 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 14 May 2020 08:37:51 +0200 Subject: [PATCH 2/5] Clean-up unneeded function argument --- testing_and_setup/compass/manage_regression_suite.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing_and_setup/compass/manage_regression_suite.py b/testing_and_setup/compass/manage_regression_suite.py index ef40ea720b..5a418931aa 100755 --- a/testing_and_setup/compass/manage_regression_suite.py +++ b/testing_and_setup/compass/manage_regression_suite.py @@ -147,7 +147,7 @@ def process_test_setup(test_tag, config_file, work_dir, model_runtime, # }}} -def process_test_clean(test_tag, work_dir, suite_script): # {{{ +def process_test_clean(test_tag, work_dir): # {{{ dev_null = open('/dev/null', 'a') # Process test attributes @@ -304,7 +304,7 @@ def clean_suite(suite_tag, work_dir): # {{{ for child in suite_tag: # Process children within the if child.tag == 'test': - process_test_clean(child, work_dir, regression_script) + process_test_clean(child, work_dir) # }}} From 748a7c35db5dc7d4e4d89ad9f6f82f330fc9a278 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 14 May 2020 09:14:18 +0200 Subject: [PATCH 3/5] Pull test-case info into a dict This merge makes a dict of test cases, each with a dict of info: core, configuration, resolution, test, procs and treads. This will be useful later on in both determining whether prerequisite tasks are present and in determining how to run many tests in parallel --- .../compass/manage_regression_suite.py | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/testing_and_setup/compass/manage_regression_suite.py b/testing_and_setup/compass/manage_regression_suite.py index 5a418931aa..28746225f3 100755 --- a/testing_and_setup/compass/manage_regression_suite.py +++ b/testing_and_setup/compass/manage_regression_suite.py @@ -308,11 +308,9 @@ def clean_suite(suite_tag, work_dir): # {{{ # }}} -def summarize_suite(suite_tag): # {{{ +def get_test_case_procs(suite_tag): # {{{ - max_procs = 1 - max_threads = 1 - max_cores = 1 + testcases = {} for child in suite_tag: if child.tag == 'test': @@ -370,6 +368,8 @@ def summarize_suite(suite_tag): # {{{ del config_root del config_tree + procs = 1 + threads = 1 # Loop over all files in test_path that have the .xml extension. for file in os.listdir('{}'.format(test_path)): if fnmatch.fnmatch(file, '*.xml'): @@ -395,19 +395,31 @@ def summarize_suite(suite_tag): # {{{ except (KeyError, ValueError): threads = 1 - cores = threads * procs + del config_root + del config_tree + testcases[test_name] = {'core': test_core, + 'configuration': test_configuration, + 'resolution': test_resolution, + 'test': test_test, + 'path': test_path, + 'procs': procs, + 'threads': threads} + return testcases # }}} - if procs > max_procs: - max_procs = procs - if threads > max_threads: - max_threads = threads +def summarize_suite(testcases): # {{{ - if cores > max_cores: - max_cores = cores + max_procs = 1 + max_threads = 1 + max_cores = 1 + for name in testcases: + procs = testcases[name]['procs'] + threads = testcases[name]['threads'] + cores = threads * procs - del config_root - del config_tree + max_procs = max(max_procs, procs) + max_threads = max(max_threads, threads) + max_cores = max(max_cores, cores) print("\n") print(" Summary of test cases:") @@ -495,9 +507,10 @@ def summarize_suite(suite_tag): # {{{ if args.setup: print("\n") print("Setting Up Test Cases:") + testcases = get_test_case_procs(suite_root) setup_suite(suite_root, args.work_dir, args.model_runtime, args.config_file, args.baseline_dir, args.verbose) - summarize_suite(suite_root) + summarize_suite(testcases) if args.verbose: cmd = ['cat', args.work_dir + '/manage_regression_suite.py.out'] From 118c336de4c3b28996839fe19277f52030b7894e Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 14 May 2020 09:33:37 +0200 Subject: [PATCH 4/5] Detect prerequisite tests Make sure they are also in the test suite --- .../compass/manage_regression_suite.py | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/testing_and_setup/compass/manage_regression_suite.py b/testing_and_setup/compass/manage_regression_suite.py index 28746225f3..6a4d47faf8 100755 --- a/testing_and_setup/compass/manage_regression_suite.py +++ b/testing_and_setup/compass/manage_regression_suite.py @@ -365,6 +365,31 @@ def get_test_case_procs(suite_tag): # {{{ name = case.attrib['name'] cases.append(name) + prereqs = list() + for config_prereq in config_root.iter('prerequisite'): + prereq = dict() + for tag in ['core', 'configuration', 'resolution', 'test']: + prereq[tag] = config_prereq.attrib[tag] + + # Make sure the prerequisite is already in the test suite + found = False + for other_name, other_test in testcases.items(): + match = [prereq[tag] == other_test[tag] for tag in + ['core', 'configuration', 'resolution', 'test']] + if all(match): + found = True + prereq['name'] = other_name + break + + if not found: + raise ValueError( + 'Prerequisite of {} does not precede it in the test ' + 'suite: {} {} {} {}'.format( + test_name, prereq['core'], prereq['configuration'], + prereq['resolution'], prereq['test'])) + + prereqs.append(prereq) + del config_root del config_tree @@ -403,7 +428,9 @@ def get_test_case_procs(suite_tag): # {{{ 'test': test_test, 'path': test_path, 'procs': procs, - 'threads': threads} + 'threads': threads, + 'prereqs': prereqs} + return testcases # }}} From 95abf0c6219222b104c920b714ce2a794071d097 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 14 May 2020 09:42:10 +0200 Subject: [PATCH 5/5] Move main to function This prevents variables being in global scope that we may not want. --- testing_and_setup/compass/manage_regression_suite.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testing_and_setup/compass/manage_regression_suite.py b/testing_and_setup/compass/manage_regression_suite.py index 6a4d47faf8..a64e708305 100755 --- a/testing_and_setup/compass/manage_regression_suite.py +++ b/testing_and_setup/compass/manage_regression_suite.py @@ -456,7 +456,7 @@ def summarize_suite(testcases): # {{{ # }}} -if __name__ == "__main__": +def main (): # {{{ # Define and process input arguments parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawTextHelpFormatter) @@ -573,5 +573,10 @@ def summarize_suite(testcases): # {{{ history_file.write('**************************************************' '*********************\n') history_file.close() +# }}} + + +if __name__ == "__main__": + main() # vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python