Skip to content

Commit

Permalink
Merge branch 'agsalin/test/run_acme_ctest_2' into next
Browse files Browse the repository at this point in the history
Created a simple CMake project that will run the test
script for run_acme and post result to ACME-Climate
CDash site.

Michael had a script inside of jenkins to run run_acme
and check for pass/fail return code. That logic is now
inside runAcmeTest_template.csh.

Current usage should just be:
cmake <path to ACME/cime/scripts/tests/run_acme_ctest>
ctest -D Experimental

Tested on penn, melvin, skybridge, edison, blues

Used xmlquery BATCH_SYSTEM to automate the
batch-system specific parts of the script.
Now a single script works, and no need for
any argument toe CMake.

Tested manually -- see CDash rows.

PR #1716
[BFB]
  • Loading branch information
mfdeakin-sandia committed Sep 12, 2017
2 parents 711e733 + fe16846 commit 5777176
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/acme/allactive/config_pesall.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7053,7 +7053,7 @@
</mach>
</grid>
<grid name="a%ne4np4_l%ne4np4_oi%oQU240_r%r05_m%oQU240_g%null_w%null">
<mach name="melvin">
<mach name="melvin|sandia-srn-sems">
<pes compset="any" pesize="any">
<comment>none</comment>
<ntasks>
Expand Down
35 changes: 35 additions & 0 deletions scripts/tests/run_acme_ctest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Mini CMake project to test the run_acme script AND
# post the values on ACME-Climate CDash site.
#
# From any directory, do:
# cmake <path_to_this_dir>
# ctest -D Experimental
#
# Note: running ctest without -D will run test but not post to CDash site
#
# Questions to: Deakin (test script), Salinger (cmake)
#
cmake_minimum_required(VERSION 2.8)
set(BUILDNAME "run_acme_script_test" CACHE STRING "*Build Name* string on CDash")

# This script requires no language support, syntax has changed in CMake
if(${CMAKE_VERSION} VERSION_GREATER 3.3.0)
set (LANG "LANGUAGES")
else()
set (LANG "")
endif()

project(runAcmeScriptTest ${LANG} NONE)

# Turn on testing and reporting to CDash -- see CTestConfig.cmake
ENABLE_TESTING()
INCLUDE(CTest)

# Get absolute path to dir where run_acme resides
set(RUN_ACME_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../.. CACHE PATH "Path to run_acme script")
# Create test script using configure_file to inject RUN_ACME_DIR path
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/runAcmeTest_template.sh
${CMAKE_CURRENT_BINARY_DIR}/runAcmeTest.sh @ONLY)

add_test (run_acme_script_test runAcmeTest.sh)
17 changes: 17 additions & 0 deletions scripts/tests/run_acme_ctest/CTestConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## This file should be placed in the root directory of your cmake project.
## Then modify the CMakeLists.txt file in the root directory of your
## project to incorporate the testing dashboard.
##
## # The following are required to submit to the CDash dashboard:
## ENABLE_TESTING()
## INCLUDE(CTest)
#
# No modification should be needed for specific machines

set(CTEST_PROJECT_NAME "ACME_Climate")
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")

set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "my.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=ACME_Climate")
set(CTEST_DROP_SITE_CDASH TRUE)
98 changes: 98 additions & 0 deletions scripts/tests/run_acme_ctest/runAcmeTest_template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash
# Script to test run_acme.template.csh
# Absolute path to RUN_ACME_DIR is supplied by CMake configuration
# Includes Batch-system specific method for checking queue
# Supports: pbs, slurm, none
#

#Case directories are in HOME unless SCRATCH is specified
if [ -z "$SCRATCH" ]; then
SCRATCH=${HOME}
fi

if [ ! -d "${SCRATCH}/ACME_simulations" ]; then
mkdir ${SCRATCH}/ACME_simulations
fi

case_name="default.A_WCYCL1850_template.ne4np4_oQU240"
case_scratch="${SCRATCH}/ACME_simulations/${case_name}"
case_dir="${case_scratch}/case_scripts"
public_scratch="${SCRATCH}"
run_acme_log="${public_scratch}/run_acme.log"

#Verify the case is already deleted
rm -rf ${case_scratch}

# Change to ACME dir, where script must be run, using CMake for absolute path
cd @RUN_ACME_DIR@

# Run run_acme
echo "CTEST_FULL_OUTPUT" #This magic string stops CDash from truncating output
echo
echo "**********************************************"
echo "Running run_acme.template.csh :"
echo

./run_acme.template.csh > ${run_acme_log}
exitcode=$?
cat ${run_acme_log}
# Verify the script didn't fail
if [ $exitcode -ne 0 ]
then exit $exitcode
fi

# cat CaseStatus so it is seen on CDash
echo
echo "**********************************************"
echo "cat ${case_dir}/CaseStatus :"
echo
cat "${case_dir}/CaseStatus"

# We want to wait for the last job to have been submitted to be complete
# Note that this assumes that only one job is submitted per case.submit;
# any more would require us to loop and wait for each of them
echo
echo "**********************************************"
echo "Wait for job to finish, if using batch system"
echo
jobid=`grep "Submitted job id is " ${run_acme_log} | cut -d' ' -f5 | tail -n1`

# CaseStatus doesn't report when the job has finished yet; let the queue tell us instead
# Query batch system name from case directory env_batch.xml
pushd ${case_dir}
batchsystem=$(./xmlquery BATCH_SYSTEM | sed "s/ //g" | sed "s/ //g" | sed "s/BATCH_SYSTEM://g")
popd

# Wait for job to finish using batch_system specific command
if [ "$batchsystem" == "none" ]; then
echo "BATCH_SYSTEM = none ; No need to wait for batch job to finish"

elif [ "$batchsystem" == "pbs" ]; then
echo "BATCH_SYSTEM = pbs ; Waiting for batch job to finish"
while [ `qstat ${jobid} | wc -l` -eq 3 ]
do sleep 5
done

elif [ "$batchsystem" == "slurm" ]; then
echo "BATCH_SYSTEM = slurm ; Waiting for batch job to finish"
while [ `squeue -j ${jobid} | wc -l` -eq 2 ]
do sleep 5
done

else
echo "ERROR: Unrecognized BATCH_SYSTEM = "$batchsystem
echo " Expected values are: none, pbs, slurm"
echo "Not waiting for batch job to finish before checking for success"
fi
#
# Paranoid delay to ensure we get the most up to date acme and coupler logs
sleep 5
sync

# Judging success by existence of specific string in cpl.log
# The log files are typically gzipped, so use less to read them
find ${case_scratch}/run/ -iname "cpl.log.*" | xargs less | grep "SUCCESSFUL TERMINATION"
exitcode=$?
if [ $exitcode -ne 0 ]
then exit $exitcode
fi

0 comments on commit 5777176

Please sign in to comment.