diff --git a/tests/integration/utils.py b/tests/integration/utils.py index d008fd41..36899e25 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -2,6 +2,7 @@ import re import shutil import subprocess +import sys from typing import List from mache import MachineInfo @@ -260,7 +261,12 @@ def substitute_expansions(expansions, file_in, file_out): file_write.write(line) -def generate_cfgs(unified_testing=False, dry_run=False): +def generate_cfgs( + unified_testing=False, + diags_environment_commands=None, + global_time_series_environment_commands=None, + dry_run=False, +): git_top_level = ( subprocess.check_output("git rev-parse --show-toplevel".split()) .strip() @@ -273,6 +279,14 @@ def generate_cfgs(unified_testing=False, dry_run=False): # The cfg doesn't need this line, # but it would be difficult to only write environment_commands in the unified_testing case. expansions["environment_commands"] = "" + + if diags_environment_commands: + expansions["diags_environment_commands"] = diags_environment_commands + if global_time_series_environment_commands: + expansions["global_time_series_environment_commands"] = ( + global_time_series_environment_commands + ) + machine = expansions["machine"] if dry_run: @@ -369,4 +383,12 @@ def generate_cfgs(unified_testing=False, dry_run=False): if __name__ == "__main__": - generate_cfgs(unified_testing=False, dry_run=False) + if len(sys.argv) <= 2: + generate_cfgs(unified_testing=False, dry_run=False) + else: + generate_cfgs( + unified_testing=sys.argv[2] == "True", + diags_environment_commands=sys.argv[3], + global_time_series_environment_commands=sys.argv[4], + dry_run=False, + ) diff --git a/tests/scripts/test_dev.bash b/tests/scripts/test_dev.bash new file mode 100755 index 00000000..f5f521c9 --- /dev/null +++ b/tests/scripts/test_dev.bash @@ -0,0 +1,118 @@ +#!/bin/bash + +# Before running this script ######################################################## + +# Set up branch +# If you want to test `main`, do the following: +# git fetch upstream main +# git checkout -b test_main_ upstream/main +# git log # check the commits match https://github.com/E3SM-Project/zppy/commits/main + +# Set these parameters: + +# Make sure you do not have important changes in any of these directories. This script will reset them! +ZPPY_DIR=/home/ac.forsyth2/zppy/ +DIAGS_DIR=/home/ac.forsyth2/e3sm_diags/ +ZI_DIR=/home/ac.forsyth2/zppy-interfaces/ + +ZPPY_DEV=zppy_dev_n516 +DIAGS_DEV=diags_dev_2024_12_13 +ZI_DEV=zi_dev_2024_12_13 + +DIAGS_ENV_CMD="source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate ${DIAGS_DEV}" +ZI_ENV_CMD="source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate ${ZI_DEV}" + +UNIQUE_ID="unique_id" + +##################################################################################### + +# Set up zppy-interfaces env +cd ${ZI_DIR} +git fetch upstream main +git checkout main upstream/main +if [ $? != 0 ]; then + echo 'ERROR (1): Could not check out zppy-interfaces main branch' + exit 1 +fi +git reset --hard upstream/main +conda clean --all --y +# TODO: previous iterations of this script had issues with activating conda environments +conda env create -f conda/dev.yml -n ${ZI_DEV} +conda activate ${ZI_DEV} +pip install . +pytest tests/global_time_series/test_*.py +if [ $? != 0 ]; then + echo 'ERROR (2): zppy-interfaces unit tests failed' + exit 2 +fi + +# Set up e3sm_diags env +cd ${DIAGS_DIR} +git fetch upstream +git checkout main +if [ $? != 0 ]; then + echo 'ERROR (3): Could not check out e3sm_diags main branch' + exit 3 +fi +git reset --hard upstream/main +conda clean --all --y +conda env create -f conda-env/dev.yml -n ${DIAGS_DEV} +conda activate ${DIAGS_DEV} +pip install . + +# Set up zppy env +cd ${ZPPY_DIR} +# We should already be on the branch we want to test! +conda clean --all --y +conda env create -f conda/dev.yml -n ${ZPPY_DEV} +conda activate ${ZPPY_DEV} +pip install . +pytest tests/test_*.py +if [ $? != 0 ]; then + echo 'ERROR (4): zppy unit tests failed' + exit 4 +fi + +# Integration testing for zppy +python tests/integration/utils.py False ${DIAGS_DEV} ${ZI_DEV} + + +zppy -c tests/integration/generated/test_weekly_comprehensive_v3_chrysalis.cfg +zppy -c tests/integration/generated/test_weekly_comprehensive_v2_chrysalis.cfg +zppy -c tests/integration/generated/test_weekly_bundles_chrysalis.cfg # Runs 1st part of bundles cfg + +# TODO: figure out how to wait for all those jobs to finish + +zppy -c tests/integration/generated/test_weekly_bundles_chrysalis.cfg + +# TODO: figure out how to wait for all those jobs to finish + +# Check output +cd /lcrc/group/e3sm/${USER}/zppy_weekly_comprehensive_v3_output/${UNIQUE_ID}/v3.LR.historical_0051/post/scripts/ +grep -v "OK" *status +if [ $? == 0 ]; then + echo 'ERROR (5): weekly_comprehensive_v3 failed' + exit 5 +fi + +cd /lcrc/group/e3sm/${USER}/zppy_weekly_comprehensive_v2_output/${UNIQUE_ID}/v2.LR.historical_0201/post/scripts +grep -v "OK" *status +if [ $? == 0 ]; then + echo 'ERROR (6): weekly_comprehensive_v2 failed' + exit 6 +fi + +cd /lcrc/group/e3sm/${USER}/zppy_weekly_bundles_output/${UNIQUE_ID}/v3.LR.historical_0051/post/scripts +grep -v "OK" *status +if [ $? == 0 ]; then + echo 'ERROR (7): weekly_bundles failed' + exit 7 +fi + +# Run integration tests +cd ~/ez/zppy +pytest tests/integration/test_*.py +if [ $? != 0 ]; then + echo 'ERROR (8): zppy integration tests failed' + exit 8 +fi