From 99a86e8fd596d759aeb15a32c6a34f4aed1427c0 Mon Sep 17 00:00:00 2001 From: David Sutherland Date: Thu, 3 Aug 2023 00:22:57 +1200 Subject: [PATCH] test added --- .../n-window/01-past-present-future.t | 67 +++++++++++++++++++ .../n-window/01-past-present-future/flow.cylc | 41 ++++++++++++ tests/functional/n-window/02-big-window.t | 57 ++++++++++++++++ .../n-window/02-big-window/flow.cylc | 52 ++++++++++++++ tests/functional/n-window/test_header | 1 + 5 files changed, 218 insertions(+) create mode 100644 tests/functional/n-window/01-past-present-future.t create mode 100644 tests/functional/n-window/01-past-present-future/flow.cylc create mode 100644 tests/functional/n-window/02-big-window.t create mode 100644 tests/functional/n-window/02-big-window/flow.cylc create mode 120000 tests/functional/n-window/test_header diff --git a/tests/functional/n-window/01-past-present-future.t b/tests/functional/n-window/01-past-present-future.t new file mode 100644 index 00000000000..183b9343b14 --- /dev/null +++ b/tests/functional/n-window/01-past-present-future.t @@ -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 . +#------------------------------------------------------------------------------- + +# 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 diff --git a/tests/functional/n-window/01-past-present-future/flow.cylc b/tests/functional/n-window/01-past-present-future/flow.cylc new file mode 100644 index 00000000000..a032274a41e --- /dev/null +++ b/tests/functional/n-window/01-past-present-future/flow.cylc @@ -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 +""" diff --git a/tests/functional/n-window/02-big-window.t b/tests/functional/n-window/02-big-window.t new file mode 100644 index 00000000000..2dc41f239a1 --- /dev/null +++ b/tests/functional/n-window/02-big-window.t @@ -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 . +#------------------------------------------------------------------------------- + +# 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 diff --git a/tests/functional/n-window/02-big-window/flow.cylc b/tests/functional/n-window/02-big-window/flow.cylc new file mode 100644 index 00000000000..09e4d8181fc --- /dev/null +++ b/tests/functional/n-window/02-big-window/flow.cylc @@ -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" +""" diff --git a/tests/functional/n-window/test_header b/tests/functional/n-window/test_header new file mode 120000 index 00000000000..90bd5a36f92 --- /dev/null +++ b/tests/functional/n-window/test_header @@ -0,0 +1 @@ +../lib/bash/test_header \ No newline at end of file