Skip to content

Commit

Permalink
test added
Browse files Browse the repository at this point in the history
  • Loading branch information
dwsutherland committed Aug 3, 2023
1 parent 60d6c7d commit 99a86e8
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/functional/n-window/01-past-present-future.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------

# Test window size using graphql and cylc-show for all tasks.

. "$(dirname "$0")/test_header"

set_test_number 7

install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

TEST_NAME="${TEST_NAME_BASE}-validate"
run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}"

# First run: task c shuts the scheduler down then fails.
TEST_NAME="${TEST_NAME_BASE}-run"
# 'a => b => c => d => e', 'a' sets window size to 2, 'c' uses cylc show on all.
workflow_run_ok "${TEST_NAME}" cylc play --no-detach --debug "${WORKFLOW_NAME}"

TEST_NAME="${TEST_NAME_BASE}-show-a.past"
contains_ok "$WORKFLOW_RUN_DIR/show-a.txt" <<__END__
state: succeeded
prerequisites: (None)
__END__

TEST_NAME="${TEST_NAME_BASE}-show-b.past"
contains_ok "$WORKFLOW_RUN_DIR/show-b.txt" <<__END__
state: succeeded
prerequisites: (n/a for past tasks)
__END__

TEST_NAME="${TEST_NAME_BASE}-show-c.present"
contains_ok "${WORKFLOW_RUN_DIR}/show-c.txt" <<__END__
prerequisites: ('-': not satisfied)
+ 1/b succeeded
__END__

TEST_NAME="${TEST_NAME_BASE}-show-d.future"
contains_ok "${WORKFLOW_RUN_DIR}/show-d.txt" <<__END__
state: waiting
prerequisites: ('-': not satisfied)
- 1/c succeeded
__END__

TEST_NAME="${TEST_NAME_BASE}-show-e.future"
contains_ok "${WORKFLOW_RUN_DIR}/show-e.txt" <<__END__
state: waiting
prerequisites: ('-': not satisfied)
- 1/d succeeded
__END__

purge
41 changes: 41 additions & 0 deletions tests/functional/n-window/01-past-present-future/flow.cylc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[scheduler]
allow implicit tasks = True
[[events]]
inactivity timeout = PT1M
abort on inactivity timeout = True
[scheduling]
[[graph]]
R1 = """
a => b => c => d => e
"""
[runtime]
[[a]]
script = """
set +e
read -r -d '' gqlDoc <<_DOC_
{"request_string": "
mutation {
setGraphWindowExtent (
workflows: [\"${CYLC_WORKFLOW_ID}\"],
nEdgeDistance: 2) {
result
}
}",
"variables": null}
_DOC_
echo "${gqlDoc}"
cylc client "$CYLC_WORKFLOW_ID" graphql < <(echo ${gqlDoc}) 2>/dev/null
set -e
"""
[[c]]
script = """
cylc show "$CYLC_WORKFLOW_ID//1/a" >> $CYLC_WORKFLOW_RUN_DIR/show-a.txt
cylc show "$CYLC_WORKFLOW_ID//1/b" >> $CYLC_WORKFLOW_RUN_DIR/show-b.txt
cylc show "$CYLC_WORKFLOW_ID//1/c" >> $CYLC_WORKFLOW_RUN_DIR/show-c.txt
cylc show "$CYLC_WORKFLOW_ID//1/d" >> $CYLC_WORKFLOW_RUN_DIR/show-d.txt
cylc show "$CYLC_WORKFLOW_ID//1/e" >> $CYLC_WORKFLOW_RUN_DIR/show-e.txt
"""
57 changes: 57 additions & 0 deletions tests/functional/n-window/02-big-window.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------

# Test large window size using graphql and find tasks in window.
# This is helpful with coverage by using most the no-rewalk mechanics.

. "$(dirname "$0")/test_header"

set_test_number 5

install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

TEST_NAME="${TEST_NAME_BASE}-validate"
run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}"

# First run: task c shuts the scheduler down then fails.
TEST_NAME="${TEST_NAME_BASE}-run"
# 'a => b => . . . f => g => h', 'a' sets window size to 5,
# 'b => i => j => f', 'c' finds 'a', 'j', 'h'
workflow_run_ok "${TEST_NAME}" cylc play --no-detach --debug "${WORKFLOW_NAME}"

TEST_NAME="${TEST_NAME_BASE}-show-a.past"
contains_ok "$WORKFLOW_RUN_DIR/show-a.txt" <<__END__
state: succeeded
prerequisites: (None)
__END__

TEST_NAME="${TEST_NAME_BASE}-show-j.parallel"
contains_ok "${WORKFLOW_RUN_DIR}/show-j.txt" <<__END__
state: waiting
prerequisites: ('-': not satisfied)
- 1/i succeeded
__END__

TEST_NAME="${TEST_NAME_BASE}-show-h.future"
contains_ok "${WORKFLOW_RUN_DIR}/show-h.txt" <<__END__
state: waiting
prerequisites: ('-': not satisfied)
- 1/g succeeded
__END__

purge
52 changes: 52 additions & 0 deletions tests/functional/n-window/02-big-window/flow.cylc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[scheduler]
allow implicit tasks = True
[[events]]
inactivity timeout = PT1M
abort on inactivity timeout = True
[scheduling]
[[graph]]
R1 = """
a => b => c => d => e => f => g => h
b => i => j => f
"""
[runtime]
[[a]]
script = """
set +e
read -r -d '' gqlDoc <<_DOC_
{"request_string": "
mutation {
setGraphWindowExtent (
workflows: [\"${CYLC_WORKFLOW_ID}\"],
nEdgeDistance: 5) {
result
}
}",
"variables": null}
_DOC_
echo "${gqlDoc}"
cylc client "$CYLC_WORKFLOW_ID" graphql < <(echo ${gqlDoc}) 2>/dev/null
set -e
"""
[[c]]
script = """
cylc show "$CYLC_WORKFLOW_ID//1/a" >> $CYLC_WORKFLOW_RUN_DIR/show-a.txt
cylc show "$CYLC_WORKFLOW_ID//1/j" >> $CYLC_WORKFLOW_RUN_DIR/show-j.txt
cylc show "$CYLC_WORKFLOW_ID//1/h" >> $CYLC_WORKFLOW_RUN_DIR/show-h.txt
"""

[[i]]
script = """
# Slow 2nd branch down
sleep 5
"""

[[f]]
script = """
# test re-trigger of old point
cylc trigger "$CYLC_WORKFLOW_ID//1/b"
"""
1 change: 1 addition & 0 deletions tests/functional/n-window/test_header

0 comments on commit 99a86e8

Please sign in to comment.