This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
battery:addtestgitlab [2026/01/26 10:26] arthur |
battery:addtestgitlab [2026/11/19 10:54] (current) arthur |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Test battery - New method ====== | ====== Test battery - New method ====== | ||
| - | This new test battery consists of a large number of simulation that are directly implemented in Gitlab: whenever a new push is made, the continuous integration pipeline launches a build phase and then a test phase. If everything went right, the merge is possible. Otherwise, the user is required to correct its mistake before being able to merge. This improves the robustness of the code and avoids mistakes. \\ | + | This new test battery consists of a large number of simulations that are directly implemented in Gitlab: whenever a new push is made, the continuous integration pipeline launches a build phase and then a test phase. If everything went right, the merge is possible. Otherwise, the user is required to correct their mistake before being able to merge. This improves the robustness of the code and avoids mistakes. \\ |
| Implemented by: Arthur Fanara, 2025 | Implemented by: Arthur Fanara, 2025 | ||
| - | + | ===== How does it work ? ===== | |
| - | ===== How does it work ? ===== | + | |
| ==== Flowchart ==== | ==== Flowchart ==== | ||
| - | Gitlab's Continuous Integration (CI) is launched through the file .gitlab-ci.yml in which two steps are defined: | + | Gitlab's Continuous Integration (CI) is launched through the file ''.gitlab-ci.yml'' in which two steps are defined: |
| - | - 1. A build phase that generates, in Unix, the Prepro.exe, Lagamine.exe and Select.exe. This gives a first information on the state of the code. | + | - A **build phase** that generates, in Unix, the Prepro.exe, Lagamine.exe and Select.exe. This gives a first information on the state of the code. |
| - | - 2. A test phase that launches as many tests as implemented. It uses three .sh files: | + | - A **test phase** that launches as many tests as implemented. It uses three .sh files: |
| - | * run_tests.sh: this file cycles through the $CI_PROJECT/Tests/ folders in order to run each test. The prepro and lagamine is run for each test, then the .ipe, .ipn and .ipr are compared with the original results that may be found in a folder ExpectedResults. For the moment, the tolerance is set to 3% and any value below 1E-7 is rounded to 0.0. The differences are calculated as such:\\ \\ if(absx < abs_tol && absy < abs_tol) {diff = 0} \\ else if(absx < abs_tol) {diff = absy / abs_tol} \\ else if(absy < abs_tol) {diff = absx / abs_tol} \\ else {diff = (y - x)/x} \\ | + | * ''run_tests.sh'': this file cycles through the ''$CI_PROJECT/Tests/'' folders in order to run each test. The prepro and lagamine are run for each test, then the .ipe, .ipn and .ipr are compared with the reference results stored in the folder ''ExpectedResults'': |
| - | | + | * **Matching**: lines are paired by (time = column 3, node/element = column 4, occurrence). Only the time steps present in BOTH files are compared. Extra steps (e.g. sub-steps after a non-convergence) are ignored and reported in an INFO line. |
| - | * run_prepro.sh: this file calls the newly generated prepro.exe for the test case. | + | * **Error**: for each value from column 5 onwards, ''scale = max(|x|, |y|, REL_FLOOR*max|column|, NOISE_REL*max|file|, abs_tol)'' and ''diff = |y - x| / scale'', where x is the computed value, y the expected one, max|column| is taken over both files and max|file| over all columns >= 5. |
| - | * run_lagamine.sh: this file calls the newly generated lagamine.exe for the test case. The .ipe, .ipn, .ipr, .log and .out are generated and exported in the artifacts of Gitlab, for further referencing. The simulations are run in sequential as all routines do not allow the use of parallelisation at the moment. | + | * **Defaults**: tolerance 3 %, REL_FLOOR = 1e-6, NOISE_REL = 1e-10, abs_tol = 1e-7. REL_FLOOR and NOISE_REL can be overridden as environment variables. |
| - | + | * **Output**: for each file, OK or ECHEC with the maximum error, time, column, computed and expected values. An empty expected file (header only) is reported as INFO, not as a failure. | |
| - | If one of the steps goes wrong, the job fails and the user is not allowed to merge its modification. | + | * **Failures**: a failure does not stop the battery. All tests are run, the list of failures is printed at the end, and the job then exits with an error, so the merge is blocked. |
| + | * ''run_prepro.sh'': this file calls the newly generated prepro.exe for the test case. | ||
| + | * ''run_lagamine.sh'': this file calls the newly generated lagamine.exe for the test case. The .ipe, .ipn, .ipr, .log and .out are generated and exported in the artifacts of Gitlab, for further referencing. The simulations are run sequentially as not all routines allow parallelisation at the moment. | ||
| + | If one of the steps goes wrong, the job fails and the user is not allowed to merge their modification. | ||
| ==== Tests ==== | ==== Tests ==== | ||
| + | |||
| The folder 'Tests' contains all the tests. \\ \\ | The folder 'Tests' contains all the tests. \\ \\ | ||
| Each test is in a separate subfolder named with the same name as the test defined in "Test_battery.txt", preceded by its number. For example, 26_HYPOFE2_KFLU1 is the 26th test in the battery, and it verifies the integrity of the law HYPOFE2 with parameter KFLU1. | Each test is in a separate subfolder named with the same name as the test defined in "Test_battery.txt", preceded by its number. For example, 26_HYPOFE2_KFLU1 is the 26th test in the battery, and it verifies the integrity of the law HYPOFE2 with parameter KFLU1. | ||
| Line 26: | Line 29: | ||
| In this test subfolder, there are: | In this test subfolder, there are: | ||
| - The necessary files to run the prepro and lagamine: .DAT, .LAG, .PRI, .DEP, .LIC, and so on. | - The necessary files to run the prepro and lagamine: .DAT, .LAG, .PRI, .DEP, .LIC, and so on. | ||
| - | - A subfolder named "ExpectedResults" in which the results file are: the .ipn, .ipe and .ipr. | + | - A subfolder named "ExpectedResults" in which the result files are: the .ipn, .ipe and .ipr. |
| No other file should be found in this subfolder. | No other file should be found in this subfolder. | ||
| + | **The ExpectedResults must be produced with exactly the files of the test folder (same .LAG, same final time).** | ||
| ===== How to add your own test to the battery ===== | ===== How to add your own test to the battery ===== | ||
| ==== Creating your test ==== | ==== Creating your test ==== | ||
| - | In order to ensure that your developments in the Lagamine code will keep functioning properly, it is highly recommanded that you add one or several tests specific to the law(s) or element(s) you use and develop. \\ \\ | + | In order to ensure that your developments in the Lagamine code will keep functioning properly, it is highly recommended that you add one or several tests specific to the law(s) or element(s) you use and develop. \\ \\ |
| To test a material law or an element, you should design a **simple test**, using only 1 element when possible. Preferably, your test should **not take more than a few seconds** to run. If you need to test something more complex, you can also create a "Big" test. However, the total number of Big tests should be limited to avoid excessive computational times for the whole test battery. \\ | To test a material law or an element, you should design a **simple test**, using only 1 element when possible. Preferably, your test should **not take more than a few seconds** to run. If you need to test something more complex, you can also create a "Big" test. However, the total number of Big tests should be limited to avoid excessive computational times for the whole test battery. \\ | ||
| Line 45: | Line 49: | ||
| To add a new test to the battery, you should: | To add a new test to the battery, you should: | ||
| - | * Add the new test to "http://www.lagamine.uliege.be/dokuwiki/doku.php/battery/listtests" | + | * Add the new test to [[battery:listtests|the list of tests]]. |
| * Add the folder containing your test to the test battery directory. | * Add the folder containing your test to the test battery directory. | ||
| - | |||