From 86f5a6b6583f9a0b215c5b7e45eafa5773d69b5e Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Tue, 28 Jun 2022 16:49:48 +1200 Subject: [PATCH] Fix func tests. --- tests/functional/cylc-config/09-platforms.t | 4 ++- .../cylc-config/10-platform-expansion.t | 1 + .../intelligent-host-selection/00-mixedhost.t | 6 +++++ .../01-periodic-clear-badhosts.t | 3 +++ .../intelligent-host-selection/02-badhosts.t | 7 +++++ .../intelligent-host-selection/03-polling.t | 6 +++++ .../intelligent-host-selection/04-kill.t | 6 +++++ .../05-from-platform-group.t | 7 +++++ .../06-from-platform-group-fails.t | 8 ++++++ .../lib/python/my_background.py | 26 +++++++++++++++++++ 10 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 tests/functional/intelligent-host-selection/lib/python/my_background.py diff --git a/tests/functional/cylc-config/09-platforms.t b/tests/functional/cylc-config/09-platforms.t index 06ad5001fc0..b0624db31c8 100755 --- a/tests/functional/cylc-config/09-platforms.t +++ b/tests/functional/cylc-config/09-platforms.t @@ -23,8 +23,10 @@ set_test_number 5 cat > "global.cylc" <<__HEREDOC__ [platforms] [[foo]] + job runner = slurm hosts = of_melkor, of_valar [[bar]] + job runner = slurm hosts = of_orcs, of_gondor [platform groups] [[FOO]] @@ -58,7 +60,7 @@ Platform Groups __HEREDOC__ TEST_NAME="${TEST_NAME_BASE}-s" -head -n 8 > just_platforms < global.cylc +head -n 10 > just_platforms < global.cylc run_ok "${TEST_NAME}" cylc config --platforms cmp_ok "${TEST_NAME}.stdout" "just_platforms" diff --git a/tests/functional/cylc-config/10-platform-expansion.t b/tests/functional/cylc-config/10-platform-expansion.t index 16a49805d41..519639146d1 100755 --- a/tests/functional/cylc-config/10-platform-expansion.t +++ b/tests/functional/cylc-config/10-platform-expansion.t @@ -27,6 +27,7 @@ cat > "global.cylc" <<__HEREDOC__ baz\d\d, qux\S\S \ ]] hosts = of_melkor, of_valar + job runner = slurm __HEREDOC__ export CYLC_CONF_PATH="${PWD}" diff --git a/tests/functional/intelligent-host-selection/00-mixedhost.t b/tests/functional/intelligent-host-selection/00-mixedhost.t index f5698975098..bd378d6a63f 100644 --- a/tests/functional/intelligent-host-selection/00-mixedhost.t +++ b/tests/functional/intelligent-host-selection/00-mixedhost.t @@ -24,6 +24,8 @@ export REQUIRE_PLATFORM='loc:remote fs:indep comms:tcp' #------------------------------------------------------------------------------- set_test_number 4 +# Uses a fake background job runner to get around the single host restriction. + create_test_global_config "" " [platforms] [[goodhostplatform]] @@ -32,6 +34,7 @@ create_test_global_config "" " retrieve job logs = True [[mixedhostplatform]] + job runner = my_background hosts = unreachable_host, ${CYLC_TEST_HOST} install target = ${CYLC_TEST_INSTALL_TARGET} retrieve job logs = True @@ -42,6 +45,9 @@ create_test_global_config "" " install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" +# Install the fake background job runner. +cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}" + run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" workflow_run_ok "${TEST_NAME_BASE}-run" \ diff --git a/tests/functional/intelligent-host-selection/01-periodic-clear-badhosts.t b/tests/functional/intelligent-host-selection/01-periodic-clear-badhosts.t index 3f151bfe250..bba4926a745 100644 --- a/tests/functional/intelligent-host-selection/01-periodic-clear-badhosts.t +++ b/tests/functional/intelligent-host-selection/01-periodic-clear-badhosts.t @@ -27,6 +27,9 @@ set_test_number 3 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" +# Install the fake background job runner. +cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}" + create_test_global_config '' " [scheduler] [[main loop]] diff --git a/tests/functional/intelligent-host-selection/02-badhosts.t b/tests/functional/intelligent-host-selection/02-badhosts.t index fb721530308..661c71d99d6 100644 --- a/tests/functional/intelligent-host-selection/02-badhosts.t +++ b/tests/functional/intelligent-host-selection/02-badhosts.t @@ -25,9 +25,12 @@ export REQUIRE_PLATFORM='loc:remote fs:indep comms:tcp' #------------------------------------------------------------------------------- set_test_number 6 +# Uses a fake background job runner to get around the single host restriction. + create_test_global_config "" " [platforms] [[badhostplatform]] + job runner = my_background hosts = e9755ca30f5, 3c0b4799402 install target = ${CYLC_TEST_INSTALL_TARGET} [[[selection]]] @@ -39,6 +42,7 @@ create_test_global_config "" " retrieve job logs = True [[mixedhostplatform]] + job runner = my_background hosts = unreachable_host, ${CYLC_TEST_HOST} install target = ${CYLC_TEST_INSTALL_TARGET} retrieve job logs = True @@ -51,6 +55,9 @@ create_test_global_config "" " install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" +# Install the fake background job runner. +cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}" + run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" workflow_run_ok "${TEST_NAME_BASE}-run" \ diff --git a/tests/functional/intelligent-host-selection/03-polling.t b/tests/functional/intelligent-host-selection/03-polling.t index 98ef2ddc563..e09d37e8a01 100644 --- a/tests/functional/intelligent-host-selection/03-polling.t +++ b/tests/functional/intelligent-host-selection/03-polling.t @@ -30,6 +30,8 @@ export REQUIRE_PLATFORM='loc:remote fs:indep' #------------------------------------------------------------------------------- set_test_number 4 +# Uses a fake background job runner to get around the single host restriction. + create_test_global_config "" " [scheduler] [[main loop]] @@ -46,6 +48,7 @@ create_test_global_config "" " submission polling intervals = PT0S, 5*PT2S [[mixedhostplatform]] + job runner = my_background hosts = unreachable_host, ${CYLC_TEST_HOST} install target = ${CYLC_TEST_INSTALL_TARGET} retrieve job logs = True @@ -58,6 +61,9 @@ create_test_global_config "" " #------------------------------------------------------------------------------- install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" +# Install the fake background job runner. +cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}" + run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" workflow_run_ok "${TEST_NAME_BASE}-run" \ diff --git a/tests/functional/intelligent-host-selection/04-kill.t b/tests/functional/intelligent-host-selection/04-kill.t index 7f96dc92f61..bc0b54a7e0e 100644 --- a/tests/functional/intelligent-host-selection/04-kill.t +++ b/tests/functional/intelligent-host-selection/04-kill.t @@ -24,6 +24,8 @@ export REQUIRE_PLATFORM='loc:remote fs:indep comms:tcp' #------------------------------------------------------------------------------- set_test_number 4 +# Uses a fake background job runner to get around the single host restriction. + create_test_global_config "" " [scheduler] [[main loop]] @@ -36,6 +38,7 @@ create_test_global_config "" " install target = ${CYLC_TEST_INSTALL_TARGET} [[mixedhostplatform]] + job runner = my_background hosts = unreachable_host, ${CYLC_TEST_HOST} install target = ${CYLC_TEST_INSTALL_TARGET} [[[selection]]] @@ -45,6 +48,9 @@ create_test_global_config "" " install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" +# Install the fake background job runner. +cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}" + run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" workflow_run_ok "${TEST_NAME_BASE}-run" \ diff --git a/tests/functional/intelligent-host-selection/05-from-platform-group.t b/tests/functional/intelligent-host-selection/05-from-platform-group.t index 073292b606b..68e1bdd09fa 100644 --- a/tests/functional/intelligent-host-selection/05-from-platform-group.t +++ b/tests/functional/intelligent-host-selection/05-from-platform-group.t @@ -25,14 +25,18 @@ export REQUIRE_PLATFORM='loc:remote fs:indep comms:tcp' #------------------------------------------------------------------------------- set_test_number 11 +# Uses a fake background job runner to get around the single host restriction. + create_test_global_config "" " [platforms] [[${CYLC_TEST_PLATFORM}]] # mixed host platform + job runner = my_background hosts = unreachable_host, ${CYLC_TEST_HOST} [[[selection]]] method = 'definition order' [[badhostplatform]] + job runner = my_background hosts = bad_host1, bad_host2 [[[selection]]] method = 'definition order' @@ -54,6 +58,9 @@ create_test_global_config "" " install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" +# Install the fake background job runner. +cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}" + run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" workflow_run_ok "${TEST_NAME_BASE}-run" \ diff --git a/tests/functional/intelligent-host-selection/06-from-platform-group-fails.t b/tests/functional/intelligent-host-selection/06-from-platform-group-fails.t index f7594d185b2..4bc0ecd3043 100644 --- a/tests/functional/intelligent-host-selection/06-from-platform-group-fails.t +++ b/tests/functional/intelligent-host-selection/06-from-platform-group-fails.t @@ -22,11 +22,16 @@ . "$(dirname "$0")/test_header" set_test_number 12 #------------------------------------------------------------------------------- + +# Uses a fake background job runner to get around the single host restriction. + create_test_global_config "" " [platforms] [[badhostplatform1]] + job runner = my_background hosts = bad_host1, bad_host2 [[badhostplatform2]] + job runner = my_background hosts = bad_host3, bad_host4 [platform groups] @@ -36,6 +41,9 @@ create_test_global_config "" " install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" +# Install the fake background job runner. +cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}" + run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" workflow_run_fail "${TEST_NAME_BASE}-run" \ diff --git a/tests/functional/intelligent-host-selection/lib/python/my_background.py b/tests/functional/intelligent-host-selection/lib/python/my_background.py new file mode 100644 index 00000000000..a264b0b94e0 --- /dev/null +++ b/tests/functional/intelligent-host-selection/lib/python/my_background.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +# 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 . + +from cylc.flow.job_runner_handlers.background import BgCommandHandler + + +class MyBgCommandHandler(BgCommandHandler): + pass + + +JOB_RUNNER_HANDLER = MyBgCommandHandler()