Skip to content

Commit

Permalink
cylc job sys tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Dec 18, 2024
1 parent ec90e85 commit 52cfc67
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
39 changes: 39 additions & 0 deletions cylc-remote-tests/Jinja2Filters/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Filter provides a list of cylc tests for each job runner.
Use thus: `{{ "<job_runner>" | tests }}`
"""

BS_TESTS = """
tests/functional/cylc-poll/06-loadleveler.t
tests/functional/cylc-poll/07-pbs.t
tests/functional/cylc-poll/08-slurm.t
tests/functional/cylc-poll/09-lsf.t
tests/functional/directives/00-loadleveler.t
tests/functional/directives/02-slurm.t
tests/functional/directives/03-pbs.t
tests/functional/execution-time-limit/02-slurm.t
tests/functional/execution-time-limit/03-pbs.t
tests/functional/job-kill/02-loadleveler.t
tests/functional/job-kill/03-slurm.t
tests/functional/job-kill/04-pbs.t
""".strip().split('\n')


def tests(group='slurm'):
# Tests:
# Remove /
# Remove leading tests/functional
# Remove trailing .t
# Add the word test because cylc is not an allowed task name start
sep = ', '
tests = []
for test in BS_TESTS:
if group in test:
tests.append(test)
tests = [
f"test_{t.split('/')[2]}---{t.split('/')[3]}".replace('.t', '')
for t in tests
]

fin = sep.join(tests)
return fin
6 changes: 6 additions & 0 deletions cylc-remote-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Test Cylc Job Runner Specific tests

Run Cylc tests which use job runners.
Options for Cylc commands
* `-z groups=slurm,pbs,lsf,loadleveler`. Defaults to slurm.
* `-s 'platform="spice"'`. Defaults to spice.
10 changes: 10 additions & 0 deletions cylc-remote-tests/bin/get-test-name
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python

import sys

name = sys.argv[1]
path = name[5:].split('---')
path[1] += '.t'
print('/'.join(path))


6 changes: 6 additions & 0 deletions cylc-remote-tests/etc/readmemaker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# Create the readmefile

cylc config . -i '[meta]title' > README.md
echo "" >> README.md
cylc config . -i '[meta]description' >> README.md
62 changes: 62 additions & 0 deletions cylc-remote-tests/flow.cylc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!jinja2
{% if groups is not defined %}
{% set groups=["slurm"] %}
{% endif %}

[meta]
title = Test Cylc Job Runner Specific tests
description = """
Run Cylc tests which use job runners.
Options for Cylc commands
* `-z groups=slurm,pbs,lsf,loadleveler`. Defaults to slurm.
* `-s 'platform="spice"'`. Defaults to spice.
"""
created on = 2024-12-16T15

{% for group in groups %}
[task parameters]
{{group}}test = {{ group | tests }}
[[templates]]
{{group}}test = %({{group}}test)s
{% endfor %}

[scheduling]
cycling mode = integer
[[graph]]
{% for group in groups %}
R1 = {{ group | upper }}:succeed-all => fin
{% endfor %}

[runtime]
{% for group in groups %}
[[{{ group | upper }}]]
{% endfor %}
[[SLURM, PBS, LOADLEVELLER]]
[[TESTS]]
script = """
micromamba activate cylc.dev
set -eux pipefail
CYLC_PATH="${HOME}/repos/cylc-flow"
TEST=${CYLC_PATH}/tests/functional/$(get-test-name ${CYLC_TASK_NAME})
echo ${TEST}
${CYLC_PATH}/etc/bin/run-functional-tests -vvv -p '*' ${TEST}
if [[ $(grep NOTEST ${CYLC_TASK_LOG_ROOT}.out) ]]; then
echo "No test actually run"
cylc message -- "No test run"
exit 1
fi
"""
platform = {{ platform | default("spice", true) }}
[[[outputs]]]
no_platform = "No test run"

{% for group in groups %}
[[<{{group}}test>]]
inherit = {{ group | upper }}, TESTS
{% endfor %}

[[fin]]

0 comments on commit 52cfc67

Please sign in to comment.