Merge remote-tracking branch 'origin/development' into ewinter-derecho_testing

This commit is contained in:
Eric Winter
2025-07-30 16:04:09 -06:00
16 changed files with 401 additions and 107 deletions

View File

@@ -19,19 +19,29 @@ module load {{ module }}
module list
echo 'Loading python environment.'
__conda_setup="$('/glade/u/home/ewinter/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/glade/u/home/ewinter/miniconda3/etc/profile.d/conda.sh" ]; then
. "/glade/u/home/ewinter/miniconda3/etc/profile.d/conda.sh"
if [ -d "${mage_test_root}/miniconda3" ]; then
echo 'Loading local miniconda3'
mage_test_root='{{ mage_test_root }}'
export CONDARC="${mage_test_root}/.condarc"
export CONDA_ENVS_PATH="${mage_test_root}/.conda"
mage_miniconda3="${mage_test_root}/miniconda3"
mage_conda="${mage_miniconda3}/bin/conda"
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
export PATH="/glade/u/home/ewinter/miniconda3/bin:$PATH"
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
. "$mage_miniconda3/etc/profile.d/conda.sh"
else
export PATH="$mage_miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
else
echo 'Loading conda module'
module load conda
fi
unset __conda_setup
conda activate kaiju-3.12-testing
conda activate {{ conda_environment }}
echo 'Setting up MAGE environment.'
source {{ kaijuhome }}/scripts/setupEnvironment.sh

View File

@@ -85,8 +85,7 @@ BUILD_BIN_DIR = "bin"
# Data and configuration files used by the Intel Inspector tests.
TEST_INPUT_FILES = [
"bcwind.h5",
"lfmD.h5",
"tinyCase.xml",
"memSuppress.sup",
"rcmconfig.h5",
"threadSuppress.sup",
@@ -309,6 +308,66 @@ def intelChecks(args: dict):
from_path = os.path.join(TEST_INPUTS_DIRECTORY, filename)
to_path = os.path.join(".", filename)
shutil.copyfile(from_path, to_path)
# Generate bcwind data file.
if verbose:
print("Creating bcwind data file.")
cmd = "cda2wind.py -t0 2016-08-09T09:00:00 -t1 2016-08-09T11:00:00"
if debug:
print(f"cmd = {cmd}")
try:
cproc = subprocess.run(cmd, shell=True, check=True)
except subprocess.CalledProcessError as e:
print("ERROR: Unable to create bcwind data file for module set "
f"{module_set_name}.\n"
f"e.cmd = {e.cmd}\n"
f"e.returncode = {e.returncode}\n"
"See testing log for output from cda2wind.py.\n"
"Skipping remaining steps for module set"
f"{module_set_name}\n")
continue
if debug:
print(f"cproc = {cproc}")
# Generate the LFM grid file.
if verbose:
print("Creating LFM grid file.")
cmd = "genLFM.py -gid D"
if debug:
print(f"cmd = {cmd}")
try:
cproc = subprocess.run(cmd, shell=True, check=True)
except subprocess.CalledProcessError as e:
print("ERROR: Unable to create LFM grid file for module set "
f"{module_set_name}.\n"
f"e.cmd = {e.cmd}\n"
f"e.returncode = {e.returncode}\n"
"See testing log for output from genLFM.py.\n"
"Skipping remaining steps for module set"
f"{module_set_name}\n")
continue
if debug:
print(f"cproc = {cproc}")
# Generate the Raiju configuration file.
if verbose:
print("Creating Raiju configuration file.")
cmd = "genRAIJU.py"
if debug:
print(f"cmd = {cmd}")
try:
cproc = subprocess.run(cmd, shell=True, check=True)
except subprocess.CalledProcessError as e:
print("ERROR: Unable to create Raiju configuration file"
f" for module set {module_set_name}.\n"
f"e.cmd = {e.cmd}\n"
f"e.returncode = {e.returncode}\n"
"See testing log for output from genRAIJU.py.\n"
"Skipping remaining steps for module set "
f"{module_set_name}\n")
continue
if debug:
print(f"cproc = {cproc}")
# --------------------------------------------------------------------

View File

@@ -12,23 +12,29 @@
echo "Job $PBS_JOBID started at `date` on `hostname` in directory `pwd`."
echo 'Loading python environment.'
mage_test_root='{{ mage_test_root }}'
export CONDARC="${mage_test_root}/.condarc"
export CONDA_ENVS_PATH="${mage_test_root}/.conda"
mage_miniconda3="${mage_test_root}/miniconda3"
mage_conda="${mage_miniconda3}/bin/conda"
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
. "$mage_miniconda3/etc/profile.d/conda.sh"
if [ -d "${mage_test_root}/miniconda3" ]; then
echo 'Loading local miniconda3'
mage_test_root='{{ mage_test_root }}'
export CONDARC="${mage_test_root}/.condarc"
export CONDA_ENVS_PATH="${mage_test_root}/.conda"
mage_miniconda3="${mage_test_root}/miniconda3"
mage_conda="${mage_miniconda3}/bin/conda"
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
export PATH="$mage_miniconda3/bin:$PATH"
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
. "$mage_miniconda3/etc/profile.d/conda.sh"
else
export PATH="$mage_miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
else
echo 'Loading conda module'
module load conda
fi
unset __conda_setup
conda activate kaiju-3.8-testing
conda activate {{ conda_environment }}
#echo 'Setting up MAGE environment.'
source {{ kaijuhome }}/scripts/setupEnvironment.sh

View File

@@ -12,23 +12,29 @@
echo "Job $PBS_JOBID started at `date` on `hostname` in directory `pwd`."
echo 'Loading python environment.'
mage_test_root='{{ mage_test_root }}'
export CONDARC="${mage_test_root}/.condarc"
export CONDA_ENVS_PATH="${mage_test_root}/.conda"
mage_miniconda3="${mage_test_root}/miniconda3"
mage_conda="${mage_miniconda3}/bin/conda"
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
. "$mage_miniconda3/etc/profile.d/conda.sh"
if [ -d "${mage_test_root}/miniconda3" ]; then
echo 'Loading local miniconda3'
mage_test_root='{{ mage_test_root }}'
export CONDARC="${mage_test_root}/.condarc"
export CONDA_ENVS_PATH="${mage_test_root}/.conda"
mage_miniconda3="${mage_test_root}/miniconda3"
mage_conda="${mage_miniconda3}/bin/conda"
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
export PATH="$mage_miniconda3/bin:$PATH"
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
. "$mage_miniconda3/etc/profile.d/conda.sh"
else
export PATH="$mage_miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
else
echo 'Loading conda module'
module load conda
fi
unset __conda_setup
conda activate kaiju-3.8-testing
conda activate {{ conda_environment }}
#echo 'Setting up MAGE environment.'
source {{ kaijuhome }}/scripts/setupEnvironment.sh

View File

@@ -23,23 +23,29 @@ module load {{ module }}
module list
echo 'Loading python environment.'
mage_test_root='{{ mage_test_root }}'
export CONDARC="${mage_test_root}/.condarc"
export CONDA_ENVS_PATH="${mage_test_root}/.conda"
mage_miniconda3="${mage_test_root}/miniconda3"
mage_conda="${mage_miniconda3}/bin/conda"
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
. "$mage_miniconda3/etc/profile.d/conda.sh"
if [ -d "${mage_test_root}/miniconda3" ]; then
echo 'Loading local miniconda3'
mage_test_root='{{ mage_test_root }}'
export CONDARC="${mage_test_root}/.condarc"
export CONDA_ENVS_PATH="${mage_test_root}/.conda"
mage_miniconda3="${mage_test_root}/miniconda3"
mage_conda="${mage_miniconda3}/bin/conda"
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
export PATH="$mage_miniconda3/bin:$PATH"
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
. "$mage_miniconda3/etc/profile.d/conda.sh"
else
export PATH="$mage_miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
else
echo 'Loading conda module'
module load conda
fi
unset __conda_setup
conda activate kaiju-3.8-testing
conda activate {{ conda_environment }}
echo 'Setting up MAGE environment.'
source {{ kaijuhome }}/scripts/setupEnvironment.sh

View File

@@ -160,7 +160,7 @@ def generateAndRunCase(caseName,pbsTemplate,pbs_options,xmlTemplate,xml_options,
shutil.copy2('../voltron.x', './voltron.x')
shutil.copy2('../voltron_mpi.x', './voltron_mpi.x')
shutil.copy2('../lfmD.h5', './lfmD.h5')
shutil.copy2('../rcmconfig.h5', './rcmconfig.h5')
shutil.copy2('../raijuconfig.h5', './raijuconfig.h5')
shutil.copy2('../bcwind.h5', './bcwind.h5')
# Submit the job
if verbose:
@@ -643,16 +643,16 @@ def main():
f"{module_set_name}\n")
continue
# Generate the RCM configuration file.
# Generate the Raiju configuration file.
if verbose:
print('Creating RCM configuration file.')
cmd = 'genRCM.py'
print('Creating Raiju configuration file.')
cmd = 'genRAIJU.py'
if debug:
print(f"cmd = {cmd}")
try:
_ = subprocess.run(cmd, shell=True, check=True)
except subprocess.CalledProcessError as e:
print('ERROR: Unable to create RCM configuration file'
print('ERROR: Unable to create Raiju configuration file'
f" for module set {module_set_name}.\n"
f"e.cmd = {e.cmd}\n"
f"e.returncode = {e.returncode}\n"
@@ -674,6 +674,7 @@ def main():
base_pbs_options['mage_test_root'] = os.environ['MAGE_TEST_ROOT']
base_pbs_options['mage_test_set_root'] = os.environ['MAGE_TEST_SET_ROOT']
base_pbs_options['branch_or_commit'] = os.environ['BRANCH_OR_COMMIT']
base_pbs_options["conda_environment"] = os.environ["CONDA_ENVIRONMENT"]
base_pbs_options['report_options'] = ''
if debug:
base_pbs_options['report_options'] += ' -d'

160
testingScripts/runLocalTests.py Executable file
View File

@@ -0,0 +1,160 @@
#!/usr/bin/env python
import argparse
import os
import subprocess
import pathlib
import datetime
def create_command_line_parser():
"""Create the command-line argument parser.
Create the parser for command-line arguments.
Returns
-------
parser : argparse.ArgumentParser
Command-line argument parser for this script.
"""
parser = argparse.ArgumentParser(description="Script to help setup automated tests within a kaiju repo")
parser.add_argument(
"-A", required=True,
help="Charge code to use when running tests."
)
parser.add_argument(
"-ce", required=True,
help="Conda environment name to load with conda module"
)
parser.add_argument(
"-p", default="economy",
help="Job priority to use when running tests (default: %(default)s)."
)
parser.add_argument(
"--unitTests", action='store_true',default=False,
help="Run unit tests (default: %(default)s)."
)
parser.add_argument(
"--weeklyDash", action='store_true',default=False,
help="Run weekly dash (default: %(default)s)."
)
parser.add_argument(
"--compTests", action='store_true',default=False,
help="Run default subset of comparative tests (default: %(default)s)."
)
parser.add_argument(
"--compTestsFull", action='store_true',default=False,
help="Run full suite of comparative tests (over-rides --compTests) (default: %(default)s)."
)
parser.add_argument(
"--buildTests", action='store_true',default=False,
help="Run build tests (default: %(default)s)."
)
parser.add_argument(
"--icTests", action='store_true',default=False,
help="Run tests to build Initial Condition files (default: %(default)s)."
)
parser.add_argument(
"--intelChecks", action='store_true',default=False,
help="Run Intel Inspector memory and thread check tests (default: %(default)s)."
)
parser.add_argument(
"--all", action='store_true',default=False,
help="Run all tests (default: %(default)s)."
)
return parser
def main():
"""Helper script to run automated tests locally inside a kaiju repository
"""
# Set up the command-line parser.
parser = create_command_line_parser()
# Parse the command-line arguments.
args = parser.parse_args()
# find repo home directory
called_from = os.path.dirname(os.path.abspath(__file__))
os.chdir(called_from)
os.chdir('..')
homeDir = os.getcwd()
# Check for necessary environment variables
if 'KAIJUHOME' not in os.environ:
print("The setupEnvironment.sh script must be sourced for the repo this script resides in before calling it.")
exit()
if pathlib.Path(homeDir).resolve() != pathlib.Path(os.environ['KAIJUHOME']).resolve():
print("The setupEnvironment.sh script must be sourced for the repo this script resides in before calling it.")
exit()
if 'KAIPYHOME' not in os.environ:
print("The setupEnvironment.sh script for ANY kaipy repo must be sourced before calling this.")
exit()
# Set environment variables
os.environ['MAGE_TEST_ROOT'] = homeDir
os.environ['MAGE_TEST_RUNS_ROOT']=os.path.join(os.environ['MAGE_TEST_ROOT'],"test_runs")
os.environ['DERECHO_TESTING_ACCOUNT'] = args.A
os.environ['DERECHO_TESTING_QUEUE'] = 'main'
os.environ['DERECHO_TESTING_PRIORITY'] = args.p
os.environ['SLACK_BOT_TOKEN'] = '' # help ensure no accidental reporting to slack
os.environ['PYTHONUNBUFFERED']='TRUE'
os.environ['CONDA_ENVIRONMENT']=args.ce
gitBranch = subprocess.run(['git','branch','--show-current'], stdout=subprocess.PIPE).stdout.decode('utf-8')
if 'not a git repository' in gitBranch:
print("This script must be executed inside a kaiju git repository")
exit()
gitBranch = gitBranch.strip()
os.environ['BRANCH_OR_COMMIT'] = gitBranch
currenttime = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
test_set_dir = f"{currenttime}-{gitBranch}"
os.environ['MAGE_TEST_SET_ROOT'] = os.path.join(os.environ['MAGE_TEST_RUNS_ROOT'],test_set_dir)
os.makedirs(os.environ['MAGE_TEST_SET_ROOT'], exist_ok=True)
os.chdir(os.environ['MAGE_TEST_SET_ROOT'])
print(f"Running tests on branch {gitBranch}")
print(f"Using charge code {args.A} with priority {args.p}")
print(f"Running in folder {test_set_dir}")
# Adjust test options
if args.all:
args.unitTests = True
args.weeklyDash = True
args.compTests = True
args.compTestsFull = True
args.buildTests = True
args.icTests = True
args.intelChecks = True
if args.compTestsFull:
args.compTests = False
# Run Tests
if args.unitTests:
print("Running unit tests")
subprocess.call(['python', os.path.join(os.environ['MAGE_TEST_ROOT'],'testingScripts','unitTest.py'),'-tv'])
if args.weeklyDash:
print("Running weekly dash")
subprocess.call(['python', os.path.join(os.environ['MAGE_TEST_ROOT'],'testingScripts','weeklyDash.py'),'-tv'])
if args.compTests:
print("Running default comparative tests subset")
subprocess.call(['python', os.path.join(os.environ['MAGE_TEST_ROOT'],'testingScripts','relativeTests.py'),'-tv'])
if args.compTestsFull:
print("Running full comparative tests")
subprocess.call(['python', os.path.join(os.environ['MAGE_TEST_ROOT'],'testingScripts','relativeTests.py'),'-tva'])
if args.buildTests:
print("Running build tests")
subprocess.call(['python', os.path.join(os.environ['MAGE_TEST_ROOT'],'testingScripts','buildTest.py'),'-tv'])
if args.icTests:
print("Running Initial Condition tests")
subprocess.call(['python', os.path.join(os.environ['MAGE_TEST_ROOT'],'testingScripts','ICtest.py'),'-tv'])
if args.intelChecks:
print("Running memory and thread tests")
subprocess.call(['python', os.path.join(os.environ['MAGE_TEST_ROOT'],'testingScripts','intelChecks.py'),'-tv'])
if __name__ == "__main__":
main()

View File

@@ -232,11 +232,15 @@ def unitTest(args: dict = None):
if verbose:
print("Copying compiled pFUnit binaries.")
for directory in PFUNIT_BINARY_DIRECTORIES:
from_path = os.path.join(PFUNIT_HOME, directory)
to_path = os.path.join(KAIJU_EXTERNAL_DIRECTORY, directory)
if debug:
print(f"Copying {from_path} to {to_path}.")
shutil.copytree(from_path, to_path)
if not os.path.exists(os.path.join(KAIJU_EXTERNAL_DIRECTORY, directory)):
from_path = os.path.join(PFUNIT_HOME, directory)
to_path = os.path.join(KAIJU_EXTERNAL_DIRECTORY, directory)
if debug:
print(f"Copying {from_path} to {to_path}.")
shutil.copytree(from_path, to_path)
else:
if debug:
print(f"pFUnit directory {directory} already exists.")
# ------------------------------------------------------------------------
@@ -414,13 +418,13 @@ def unitTest(args: dict = None):
# Assemble common data to fill in the PBS templates.
pbs_options = {}
pbs_options["account"] = os.environ["DERECHO_TESTING_ACCOUNT"]
pbs_options["queue"] = os.environ["DERECHO_TESTING_QUEUE"]
pbs_options["job_priority"] = os.environ["DERECHO_TESTING_PRIORITY"]
pbs_options["modules"] = module_names
pbs_options['account'] = os.environ['DERECHO_TESTING_ACCOUNT']
pbs_options['queue'] = os.environ['DERECHO_TESTING_QUEUE']
pbs_options['job_priority'] = os.environ['DERECHO_TESTING_PRIORITY']
pbs_options['modules'] = module_names
pbs_options['kaijuhome'] = KAIJUHOME
pbs_options['branch_or_commit'] = BRANCH_OR_COMMIT
pbs_options["conda_environment"] = os.environ["CONDA_ENVIRONMENT"]
pbs_options["kaijuhome"] = KAIJUHOME
pbs_options["branch_or_commit"] = BRANCH_OR_COMMIT
# Go to the bin directory for testing.
if verbose:
@@ -430,14 +434,31 @@ def unitTest(args: dict = None):
# --------------------------------------------------------------------
# Copy in inputs for unit test data generation.
for filename in UNIT_TEST_DATA_INPUT_FILES:
from_path = os.path.join(
UNIT_TEST_DATA_INPUT_DIRECTORY, filename
)
to_path = os.path.join(".", filename)
if os.path.exists(UNIT_TEST_DATA_INPUT_DIRECTORY):
for filename in UNIT_TEST_DATA_INPUT_FILES:
from_path = os.path.join(
UNIT_TEST_DATA_INPUT_DIRECTORY, filename
)
to_path = os.path.join('.', filename)
if debug:
print(f"Copying {from_path} to {to_path}.")
shutil.copyfile(from_path, to_path)
else:
cmd = "cda2wind.py -t0 2016-08-09T09:00:00 -t1 2016-08-09T11:00:00"
if debug:
print(f"Copying {from_path} to {to_path}.")
shutil.copyfile(from_path, to_path)
print(f"cmd = {cmd}")
cproc = subprocess.run(cmd, shell=True, check=True,
text=True, capture_output=True)
cmd = "genLFM.py"
if debug:
print(f"cmd = {cmd}")
cproc = subprocess.run(cmd, shell=True, check=True,
text=True, capture_output=True)
cmd = "genRAIJU.py"
if debug:
print(f"cmd = {cmd}")
cproc = subprocess.run(cmd, shell=True, check=True,
text=True, capture_output=True)
# Set options specific to the data generation job, then render the
# template.
@@ -511,8 +532,8 @@ def unitTest(args: dict = None):
# Set options specific to the 1st non-case tests job, then render the
# template.
pbs_options["job_name"] = "runNonCaseTests1"
pbs_options["walltime"] = "00:05:00"
pbs_options['job_name'] = 'runNonCaseTests1'
pbs_options['walltime'] = '01:00:00'
if verbose:
print(f"Creating {RUN_NON_CASE_TESTS_1_PBS_SCRIPT}.")
pbs_content = run_non_case_tests_1_pbs_template.render(pbs_options)