Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI JJOB Tests using CMake #3214

Draft
wants to merge 117 commits into
base: develop
Choose a base branch
from

Conversation

TerrenceMcGuinness-NOAA
Copy link
Collaborator

@TerrenceMcGuinness-NOAA TerrenceMcGuinness-NOAA commented Jan 8, 2025

Description

Adding CI tests at the JJOB level using CMake/ctest wrappers:
These individual JJOB tests have four distinct phases:

  • Setup: Creates a EXPDIR/COMROOT just for the individual JJOB
  • Stage: Moves the specific files into the COMROOT that are needed to run the JJOB specified in ${HOMEgfs}/ci/ctest/cases/{CASE}_{JJOB}.yaml
  • Execute: Run the JJOB in batch (batch card extracted from XML via Rocoto)
  • Validate: Check the outputs also specified in the above yaml configure file (currently stubbed)

Resolves #3204

Type of change

  • Bug fix (fixes something broken)
  • New feature (adds functionality)
  • Maintenance (code refactor, clean-up, new CI test, etc.)

Change characteristics

  • Is this a breaking change (a change in existing functionality)? NO
  • Does this change require a documentation update? YES
  • Does this change require an update to any of the following submodules? NO (If YES, please add a link to any PRs that are pending.)
    • EMC verif-global
    • GDAS
    • GFS-utils
    • GSI
    • GSI-monitor
    • GSI-utils
    • UFS-utils
    • UFS-weather-model
    • wxflow

How has this been tested?

Ran with CMake/ctest:

mterry (orion-login-2) build (ctest_jjobs_framework) $ ctest -N
Test project /work2/noaa/global/mterry/global-workflow_forked/ci/ctests/build
  Test #1: test_C48_ATM_gfs_fcst_seg0_setup
  Test #2: test_C48_ATM_gfs_fcst_seg0_stage
  Test #3: test_C48_ATM_gfs_fcst_seg0_execute
  Test #4: test_C48_ATM_gfs_fcst_seg0_validate

Total Tests: 4
mterry (orion-login-2) build (ctest_jjobs_framework) $ ctest -L C48_ATM
Test project /work2/noaa/global/mterry/global-workflow_forked/ci/ctests/build
    Start 1: test_C48_ATM_gfs_fcst_seg0_setup
1/4 Test #1: test_C48_ATM_gfs_fcst_seg0_setup ......   Passed    3.25 sec
    Start 2: test_C48_ATM_gfs_fcst_seg0_stage
2/4 Test #2: test_C48_ATM_gfs_fcst_seg0_stage ......   Passed    1.90 sec
    Start 3: test_C48_ATM_gfs_fcst_seg0_execute
3/4 Test #3: test_C48_ATM_gfs_fcst_seg0_execute ....   Passed  2942.51 sec
    Start 4: test_C48_ATM_gfs_fcst_seg0_validate
4/4 Test #4: test_C48_ATM_gfs_fcst_seg0_validate ...   Passed    0.02 sec

100% tests passed, 0 tests failed out of 4

Label Time Summary:
C48_ATM          = 2947.68 sec*proc (4 tests)
gfs_fcst_seg0    = 2947.68 sec*proc (4 tests)

Total Test time (real) = 2947.68 sec

Checklist

  • Any dependent changes have been merged and published
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have documented my code, including function, input, and output descriptions
  • My changes generate no new warnings
  • New and existing tests pass with my changes
  • This change is covered by an existing CI test or a new one has been added
  • Any new scripts have been added to the .github/CODEOWNERS file with owners
  • I have made corresponding changes to the system documentation if necessary

Terry McGUinness and others added 30 commits December 6, 2024 10:55
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShellCheck found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
ci/ctests/scripts/execute.sh.in Fixed Show fixed Hide fixed
mkdir:
- "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input"
copy:
- ["{{ STAGED_FUNCTIONAL_TEST_DIR }}/{{ TEST_NAME }}/gfs.{{ PDY }}/{{ HH }}/model/atmos/input/gfs_ctrl.nc", "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input/gfs_ctrl.nc"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ["{{ STAGED_FUNCTIONAL_TEST_DIR }}/{{ TEST_NAME }}/gfs.{{ PDY }}/{{ HH }}/model/atmos/input/gfs_ctrl.nc", "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input/gfs_ctrl.nc"]
- ["{{ STAGED_FUNCTIONAL_TEST_DIR }}/{{ TEST_NAME }}/gfs.{{ TEST_DATE | to_YMD }}/{{ HH }}/model/atmos/input/gfs_ctrl.nc", "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input/gfs_ctrl.nc"]

- "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input"
copy:
- ["{{ STAGED_FUNCTIONAL_TEST_DIR }}/{{ TEST_NAME }}/gfs.{{ PDY }}/{{ HH }}/model/atmos/input/gfs_ctrl.nc", "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input/gfs_ctrl.nc"]
- ["{{ STAGED_FUNCTIONAL_TEST_DIR }}/{{ TEST_NAME }}/gfs.{{ PDY }}/{{ HH }}/model/atmos/input/gfs_data.tile1.nc", "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input/gfs_data.tile1.nc"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ["{{ STAGED_FUNCTIONAL_TEST_DIR }}/{{ TEST_NAME }}/gfs.{{ PDY }}/{{ HH }}/model/atmos/input/gfs_data.tile1.nc", "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input/gfs_data.tile1.nc"]
- ["{{ STAGED_FUNCTIONAL_TEST_DIR }}/{{ TEST_NAME }}/gfs.{{ PDY }}/{{ TEST_DATE | strftime('%H') }}/model/atmos/input/gfs_data.tile1.nc", "{{RUNTESTS}}/COMROOT/{{ TEST_NAME }}//gfs.{{PDY}}/{{HH}}/model/atmos/input/gfs_data.tile1.nc"]

@@ -0,0 +1,17 @@
input_files:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input_files:
{% set RUNTESTS = RUNTESTS | getenv %}
input_files:

something like this if one needs test specific local info. For e.g. in the DA jobs, we will need prior dates that are 6 hours behind TEST_DATE.


AddFunctionalTest(
CASE "C48_ATM"
JOB "gfs_fcst_seg0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JOB "gfs_fcst_seg0"
JOB "gfs_fcst_seg0"
DATE "2020011200" # Test date

…CMakeLists.txt to use PROJECT_SOURCE_DIR for HOMEgfs in templiting bash wrapper sripts
rm -f ./*.db
rm -f ./jobcard

job_card=$(yes | "${rocotoboot_dryrun}" -d "${TEST_NAME}.db" -w "${TEST_NAME}.xml" -v 10 -c "${idate}00" -t "${JOB}" 2> jobcard) || true

Check warning

Code scanning / shellcheck

job_card appears unused. Verify use (or export if used externally). Warning

job_card appears unused. Verify use (or export if used externally).
rm -f ./jobcard

job_card=$(yes | "${rocotoboot_dryrun}" -d "${TEST_NAME}.db" -w "${TEST_NAME}.xml" -v 10 -c "${idate}00" -t "${JOB}" 2> jobcard) || true
cat jobcard | sed '/^{{\|^}}/d' | sed '1d' > "${TEST_NAME}.sub" || true

Check notice

Code scanning / shellcheck

Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. Note

Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
TEST_NAME=${1:?"Name of the test is required"}

# CMake to fill these variables
STAGED_FUNCTIONAL_TEST_DIR="@STAGED_FUNCTIONAL_TEST_DIR@"

Check warning

Code scanning / shellcheck

STAGED_FUNCTIONAL_TEST_DIR appears unused. Verify use (or export if used externally). Warning

STAGED_FUNCTIONAL_TEST_DIR appears unused. Verify use (or export if used externally).

# CMake to fill these variables
STAGED_FUNCTIONAL_TEST_DIR="@STAGED_FUNCTIONAL_TEST_DIR@"
RUNTESTS="@RUNTESTS@"

Check warning

Code scanning / shellcheck

RUNTESTS appears unused. Verify use (or export if used externally). Warning

RUNTESTS appears unused. Verify use (or export if used externally).

TEST_NAME=${1:?"Name of the test is required"}
YAML_FILE=${2:?"Name of the CI yaml file for the test"}
TEST_DATE=${3:?"idate of the test is required"}

Check warning

Code scanning / shellcheck

TEST_DATE appears unused. Verify use (or export if used externally). Warning

TEST_DATE appears unused. Verify use (or export if used externally).

# CMake to fill these variables
STAGED_FUNCTIONAL_TEST_DIR="@STAGED_FUNCTIONAL_TEST_DIR@"
RUNTESTS="@RUNTESTS@"

Check warning

Code scanning / shellcheck

RUNTESTS appears unused. Verify use (or export if used externally). Warning

RUNTESTS appears unused. Verify use (or export if used externally).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Functional Tests Framework for JJOBS using CMake ctests
2 participants