Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 63 additions & 18 deletions testing_and_setup/compass/manage_regression_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # {{{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just clean-up of an unused argument

dev_null = open('/dev/null', 'a')

# Process test attributes
Expand Down Expand Up @@ -304,15 +304,13 @@ def clean_suite(suite_tag, work_dir): # {{{
for child in suite_tag:
# Process <test> children within the <regression_suite>
if child.tag == 'test':
process_test_clean(child, work_dir, regression_script)
process_test_clean(child, 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':
Expand Down Expand Up @@ -367,9 +365,36 @@ def summarize_suite(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

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'):
Expand All @@ -395,19 +420,33 @@ 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,
'prereqs': prereqs}

if procs > max_procs:
max_procs = procs
return testcases # }}}

if threads > max_threads:
max_threads = threads

if cores > max_cores:
max_cores = cores
def summarize_suite(testcases): # {{{

del config_root
del config_tree
max_procs = 1
max_threads = 1
max_cores = 1
for name in testcases:
procs = testcases[name]['procs']
threads = testcases[name]['threads']
cores = threads * procs

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:")
Expand All @@ -417,7 +456,7 @@ def summarize_suite(suite_tag): # {{{
# }}}


if __name__ == "__main__":
def main (): # {{{
Comment on lines -420 to +459
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making main() a function to avoid having module-level variables (sometimes prevents bugs).

# Define and process input arguments
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
Expand Down Expand Up @@ -495,14 +534,15 @@ 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)
Comment on lines +537 to +540
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes require doing the parsing that was previously in summarize_suite() before doing setup_suite() so we can error out if the prerequisites are not present. The info from this parsing is stored in nested dicts that will likely be useful for future efforts for parallelization.

if args.verbose:
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'))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like garbage in python 3 without the decode

write_history = True

# Write the history of this command to the command_history file, for
Expand Down Expand Up @@ -533,5 +573,10 @@ def summarize_suite(suite_tag): # {{{
history_file.write('**************************************************'
'*********************\n')
history_file.close()
# }}}


if __name__ == "__main__":
main()

# vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python