forked from paboyle/Grid
-
Notifications
You must be signed in to change notification settings - Fork 0
Create script for automated regression testing #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ilectra
wants to merge
16
commits into
develop
Choose a base branch
from
ic-regression-test
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fc40b16
First attempt at regression test script.
ilectra fc8822a
Adding expected values for 2 additional SU3 tests
8531bf1
Apply suggestions from code review
ilectra 9352015
Initial port to pytest - messy!
ilectra 7de81af
Clean pytest implementation.
ilectra ec81f62
Add function to read expected values by line.
ilectra 57a0049
Read expected values from file by line.
ilectra a15688c
Read test parameters as well from the file, remove from command line.
ilectra bed8c17
Link over needed files for tests with autoconf.
ilectra 565a051
Add nthreads as test parameter
ilectra 85e8906
Add the rest of the requested test parameters.
ilectra 77d5119
Keep MDsteps and trajL in the test as they were
ilectra 187b549
Add documentation to run_regression_tests script. Various debugging.
ilectra dc184a4
Add another test case to Test_hmc_Sp_WilsonFundFermionGauge
ilectra c70335c
Add the hmc tests to configure.ac.
ilectra fbd4349
Merge upstream and local develop
ilectra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| def read_expected(test_name="Test_hmc_Sp_WilsonFundFermionGauge", grid="8.8.8.8", mpi="1.1.1.1"): | ||
| """ | ||
| Read expected values from file. | ||
|
|
||
| The file contains one or more entries of the following format: | ||
| <grid> <mpi> <plaquette> <checksum_rng> <checksum_lat> | ||
| Eg. | ||
| 8.8.8.8 1.1.1.1 0.0256253844 922c392f d1e4cc1c | ||
| """ | ||
|
|
||
| with open(f"{test_name}_expected.txt") as file: | ||
| for line in file: | ||
| line_split = line.split() | ||
| if line_split[0] == grid and line_split[1] == mpi: | ||
| return float(line_split[2]), line_split[3], line_split[4] | ||
|
|
||
|
|
||
| def read_output(): | ||
| """ | ||
| Read test output and fish out values of interest. | ||
| """ | ||
|
|
||
| checksum_rng = None | ||
| checksum_lat = None | ||
| plaquette = None | ||
| with open("output.txt", 'r') as file: | ||
| for line in file: | ||
| if "Written NERSC" in line: | ||
| subline = line.split('checksum ')[1] | ||
| if len(subline.split()) == 1: # this is the rng checksum line | ||
| checksum_rng = subline.strip() | ||
| elif len(subline.split()) == 3: # this is the lat checksum and plaquette value line | ||
| checksum_lat = subline.split()[0] | ||
| plaquette = float(subline.split()[2]) | ||
| else: | ||
| print("Picked wrong line...") | ||
|
|
||
| if (checksum_rng is None) or (checksum_lat is None) or (plaquette is None): | ||
| print("Error reading values from output file. Make sure you compile the test with CPparams.saveInterval=1 in order to produce the required output.") | ||
| exit(1) | ||
|
|
||
| return plaquette, checksum_rng, checksum_lat | ||
|
|
||
|
|
||
| def compare(actual, expected, what, stop=False): | ||
| """ | ||
| Compare actual with expected output, and output message if failed. | ||
| """ | ||
|
|
||
| if actual != expected: | ||
| print(f"{what} comparison failed: actual={actual} , expected={expected}") | ||
| if stop: | ||
| exit(1) | ||
| else: | ||
| return False | ||
| return True | ||
|
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| import argparse | ||
| import subprocess | ||
| import os | ||
|
|
||
| parser = argparse.ArgumentParser(description='Run end-to-end tests and compare results with expectations.') | ||
| parser.add_argument("test_name", help="File name of the test") | ||
| parser.add_argument("grid", help="Grid configuration") | ||
| parser.add_argument("mpi", help="MPI configuration") | ||
| parser.add_argument("-s", "--stop", action='store_true', help="Flag to stop testing when a test fails.") | ||
| args = parser.parse_args() | ||
|
|
||
| expected_plaquette, expected_checksum_rng, expected_checksum_lat = read_expected(args.test_name, args.grid, args.mpi) | ||
|
|
||
| result = subprocess.run([f"./{args.test_name} --grid {args.grid} --mpi {args.mpi} --Thermalizations 0 --Trajectories 1 > output.txt"], shell=True, encoding="text") | ||
| plaquette, checksum_rng, checksum_lat = read_output() | ||
|
|
||
| print(f"Running {args.test_name}") | ||
| result = compare(plaquette, expected_plaquette, "plaquette", args.stop) | ||
| result = result and compare(checksum_rng, expected_checksum_rng, "Checksum RNG file ", args.stop) | ||
| result = result and compare(checksum_lat, expected_checksum_lat, "Checksum LAT file ", args.stop) | ||
| if result: | ||
| print("All tests passed!") | ||
| else: | ||
| print("Some tests failed...") | ||
|
|
||
| os.remove("output.txt") | ||
| os.remove("ckpoint_rng.1") | ||
| os.remove("ckpoint_lat.1") | ||
|
ilectra marked this conversation as resolved.
Outdated
|
||
|
|
||
| #result = subprocess.run(["./Test_hmc_Sp_WilsonFundFermionGauge --grid 8.8.8.8 --mpi 1.1.1.1 --Thermalizations 0 --Trajectories 1 > output1.txt"], shell=True, encoding="text") | ||
|
|
||
| # expected_value = 0.0256253844 | ||
| # checksum_rng = "922c392f" | ||
| # checksum_lat = "d1e4cc1c" | ||
|
|
||
| # with open("output1.txt", 'r') as file: | ||
| # for line in file: | ||
| # # if "Plaquette" in line: | ||
| # # #print(line) | ||
| # # plaquette_value = float(line.split('] ')[1]) | ||
| # # #print(plaquette_value) | ||
| # # if plaquette_value == expected_value: | ||
| # # print("Success!") | ||
| # if "Written NERSC" in line: | ||
| # print(line) | ||
| # subline = line.split('checksum ')[1] | ||
| # if len(subline.split()) == 1: # this is the rng checksum line | ||
| # print(subline) | ||
| # if subline.strip() == checksum_rng: | ||
| # print("RNG file checksum success!") | ||
| # else: | ||
| # print("RNG file checksum failed!") | ||
| # elif len(subline.split()) == 3: # this is the lat checksum and plaquette value line | ||
| # print(subline) | ||
| # checksum_value = subline.split()[0] | ||
| # plaquette_value = float(subline.split()[2]) | ||
| # print(checksum_value, plaquette_value) | ||
| # if checksum_value == checksum_lat: | ||
| # print("LAT file checksum success!") | ||
| # else: | ||
| # print("LAT file checksum failed!") | ||
| # if plaquette_value == expected_value: | ||
| # print("Plaquette value success!") | ||
| # else: | ||
| # print("Plaquette value failed!") | ||
| # else: | ||
| # print("Picked wrong line...") | ||
|
|
||
|
|
||
| #loc1 = result.find("Plaquette") | ||
| #print(loc1) | ||
| #loc2 = result.find("Smeared") | ||
| #print(loc2) | ||
| #print(result[loc1,loc2]) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 8.8.8.8 1.1.1.1 0.0256253844 922c392f d1e4cc1c | ||
|
ilectra marked this conversation as resolved.
Outdated
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.