From f1dfdcace77edde67d822126591121da14f1e744 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Wed, 7 Aug 2024 16:19:38 -0700 Subject: [PATCH 1/3] CI: add option to clean up test dirs --- .azure-pipelines.yml | 2 +- run_test.sh | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 7e4edc2dc36..ad2144212fd 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -116,7 +116,7 @@ jobs: - bash: | set -eu -o pipefail df -h - ./run_test.sh + ./run_test.sh -c rm -rf ${WARPX_CI_TMP} df -h displayName: 'Build & test' diff --git a/run_test.sh b/run_test.sh index 4efa86eb36c..ba020a19eb4 100755 --- a/run_test.sh +++ b/run_test.sh @@ -23,10 +23,25 @@ set -eu -o pipefail -# Parse command line arguments: if test names are given as command line arguments, +# Parse command line arguments: +# - if -c option is given, set clean=1 and call regtest.py with option --rm_testdir +# in order to remove all subdirectories from each test directory, after each test +# - if test names are given as command line arguments, # store them in variable tests_arg and define new command line argument to call # regtest.py with option --tests (works also for single test) -tests_arg=$* +clean=0 +while getopts c name +do + case ${name} in + c) clean=1;; + esac +done +tests_arg="" +if [ ! -z "${clean}" ]; then + tests_arg=${*:2} +else + tests_arg=$* +fi tests_run=${tests_arg:+--tests=${tests_arg}} # environment options @@ -80,7 +95,7 @@ curl -sOL https://github.com/openPMD/openPMD-example-datasets/raw/4ba1d257c5b489 cd - # Clone the AMReX regression test utility -git clone https://github.com/AMReX-Codes/regression_testing.git +git clone -b EZoni_rm_testdir https://github.com/EZoni/regression_testing.git # Prepare regression tests mkdir -p rt-WarpX/WarpX-benchmarks @@ -93,12 +108,22 @@ cp -r Checksum ../../regression_testing/ # Run tests cd ../../regression_testing/ echo "cd $PWD" -# run only tests specified in variable tests_arg (single test or multiple tests) -if [[ ! -z "${tests_arg}" ]]; then - python3 regtest.py ../rt-WarpX/ci-tests.ini --skip_comparison --no_update all "${tests_run}" -# run all tests (variables tests_arg and tests_run are empty) +if [ ! -z "${clean}" ]; then + # run only tests specified in variable tests_arg (single test or multiple tests) + if [ ! -z "${tests_arg}" ]; then + python3 regtest.py ../rt-WarpX/ci-tests.ini --rm_testdir --skip_comparison --no_update all "${tests_run}" + # run all tests (variables tests_arg and tests_run are empty) + else + python3 regtest.py ../rt-WarpX/ci-tests.ini --rm_testdir --skip_comparison --no_update all + fi else - python3 regtest.py ../rt-WarpX/ci-tests.ini --skip_comparison --no_update all + # run only tests specified in variable tests_arg (single test or multiple tests) + if [ ! -z "${tests_arg}" ]; then + python3 regtest.py ../rt-WarpX/ci-tests.ini --skip_comparison --no_update all "${tests_run}" + # run all tests (variables tests_arg and tests_run are empty) + else + python3 regtest.py ../rt-WarpX/ci-tests.ini --skip_comparison --no_update all + fi fi # clean up python virtual environment From bf358b3db2dd83b56bf56f9cae632efcf47d77b0 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 7 Aug 2024 22:01:26 -0700 Subject: [PATCH 2/3] Reset Checksum: `collisionXZ` --- .../Checksum/benchmarks_json/collisionXZ.json | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Regression/Checksum/benchmarks_json/collisionXZ.json b/Regression/Checksum/benchmarks_json/collisionXZ.json index f90c34bc86d..4fcf00ced62 100644 --- a/Regression/Checksum/benchmarks_json/collisionXZ.json +++ b/Regression/Checksum/benchmarks_json/collisionXZ.json @@ -7,20 +7,20 @@ "Ey": 0.0, "Ez": 0.0 }, - "ion": { - "particle_momentum_x": 2.4932317055825563e-19, - "particle_momentum_y": 2.274916403334278e-19, - "particle_momentum_z": 2.2528161767665816e-19, - "particle_position_x": 2648815.601036139, - "particle_position_y": 2662836.7581390506, + "electron": { + "particle_momentum_x": 1.0618161248729303e-19, + "particle_momentum_y": 1.0331186403682394e-19, + "particle_momentum_z": 1.0375409035564829e-19, + "particle_position_x": 2652982.4592067804, + "particle_position_y": 2666143.4238272114, "particle_weight": 1.7256099431746894e+26 }, - "electron": { - "particle_momentum_x": 1.0489203687862582e-19, - "particle_momentum_y": 1.0209657029567292e-19, - "particle_momentum_z": 1.0248962872393911e-19, - "particle_position_x": 2657004.8285825616, - "particle_position_y": 2670174.272797987, + "ion": { + "particle_momentum_x": 2.4479519290953386e-19, + "particle_momentum_y": 2.2313460312794214e-19, + "particle_momentum_z": 2.207395147435577e-19, + "particle_position_x": 2666525.886108531, + "particle_position_y": 2666683.4040517565, "particle_weight": 1.7256099431746894e+26 } } From 907199fa750402cb1692a669deff647d8363013e Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 7 Aug 2024 22:08:30 -0700 Subject: [PATCH 3/3] Env Var Control: `WARPX_CI_CLEAN_TESTS` --- .azure-pipelines.yml | 3 ++- run_test.sh | 49 +++++++++++++++----------------------------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index ad2144212fd..7c71599bbf3 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -18,6 +18,7 @@ jobs: LAPACKPP_HOME: '/usr/local' OMP_NUM_THREADS: 1 WARPX_CI_CCACHE: 'TRUE' + WARPX_CI_CLEAN_TESTS: 'TRUE' WARPX_CI_NUM_MAKE_JOBS: 2 WARPX_CI_OPENPMD: 'TRUE' WARPX_CI_TMP: '/tmp/ci' @@ -116,7 +117,7 @@ jobs: - bash: | set -eu -o pipefail df -h - ./run_test.sh -c + ./run_test.sh rm -rf ${WARPX_CI_TMP} df -h displayName: 'Build & test' diff --git a/run_test.sh b/run_test.sh index ba020a19eb4..275b7b5efb0 100755 --- a/run_test.sh +++ b/run_test.sh @@ -16,35 +16,23 @@ # physically correct. # The tests can be influenced by environment variables: +# Use `export WARPX_CI_CLEAN_TESTS=ON` in order to remove all subdirectories +# from each test directory, directly after a test has passed. # Use `export WARPX_CI_DIM=3` or `export WARPX_CI_DIM=2` in order to -# select only the tests that correspond to this dimension +# select only the tests that correspond to this dimension. # Use `export WARPX_TEST_ARCH=CPU` or `export WARPX_TEST_ARCH=GPU` in order # to run the tests on CPU or GPU respectively. set -eu -o pipefail -# Parse command line arguments: -# - if -c option is given, set clean=1 and call regtest.py with option --rm_testdir -# in order to remove all subdirectories from each test directory, after each test -# - if test names are given as command line arguments, +# Parse command line arguments: if test names are given as command line arguments, # store them in variable tests_arg and define new command line argument to call # regtest.py with option --tests (works also for single test) -clean=0 -while getopts c name -do - case ${name} in - c) clean=1;; - esac -done -tests_arg="" -if [ ! -z "${clean}" ]; then - tests_arg=${*:2} -else - tests_arg=$* -fi +tests_arg=$* tests_run=${tests_arg:+--tests=${tests_arg}} # environment options +WARPX_CI_CLEAN_TESTS=${WARPX_CI_CLEAN_TESTS:-""} WARPX_CI_TMP=${WARPX_CI_TMP:-""} # Remove contents and link to a previous test directory (intentionally two arguments) @@ -108,22 +96,17 @@ cp -r Checksum ../../regression_testing/ # Run tests cd ../../regression_testing/ echo "cd $PWD" -if [ ! -z "${clean}" ]; then - # run only tests specified in variable tests_arg (single test or multiple tests) - if [ ! -z "${tests_arg}" ]; then - python3 regtest.py ../rt-WarpX/ci-tests.ini --rm_testdir --skip_comparison --no_update all "${tests_run}" - # run all tests (variables tests_arg and tests_run are empty) - else - python3 regtest.py ../rt-WarpX/ci-tests.ini --rm_testdir --skip_comparison --no_update all - fi +if [ -z "${WARPX_CI_CLEAN_TESTS}" ]; then + test_rm_dir="" else - # run only tests specified in variable tests_arg (single test or multiple tests) - if [ ! -z "${tests_arg}" ]; then - python3 regtest.py ../rt-WarpX/ci-tests.ini --skip_comparison --no_update all "${tests_run}" - # run all tests (variables tests_arg and tests_run are empty) - else - python3 regtest.py ../rt-WarpX/ci-tests.ini --skip_comparison --no_update all - fi + test_rm_dir="--rm_testdir" +fi +# run only tests specified in variable tests_arg (single test or multiple tests) +if [[ ! -z "${tests_arg}" ]]; then + python3 regtest.py ../rt-WarpX/ci-tests.ini ${test_rm_dir} --skip_comparison --no_update all "${tests_run}" +# run all tests (variables tests_arg and tests_run are empty) +else + python3 regtest.py ../rt-WarpX/ci-tests.ini ${test_rm_dir} --skip_comparison --no_update all fi # clean up python virtual environment