Skip to content

Commit

Permalink
t:rose-suite-run: basic tests.
Browse files Browse the repository at this point in the history
Test with or without suite hosts.
Check initial run OK.
While suite running, check subsequence install, run, restart fails.
While suite running, check reload works.

And remove unnecessary test headers.
  • Loading branch information
matthewrmshin committed Jun 27, 2013
1 parent 7a475d4 commit 50cd2d3
Show file tree
Hide file tree
Showing 26 changed files with 138 additions and 172 deletions.
1 change: 1 addition & 0 deletions t/lib/bash/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function file_grep() {
ROSE_HOME=${ROSE_HOME:-$(cd $(dirname $BASH_SOURCE)/../../.. && pwd)}
PATH=$ROSE_HOME/bin:$PATH

TEST_KEY_BASE=$(basename $0 .t)
TEST_SOURCE_DIR=$(cd $(dirname $0) && pwd)
TEST_DIR=$(mktemp -d)
cd $TEST_DIR
Expand Down
1 change: 0 additions & 1 deletion t/rose-app-run/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides init, setup and teardown functions for rose app-run tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function init() {
mkdir $TEST_DIR/config
Expand Down
1 change: 0 additions & 1 deletion t/rose-app-upgrade/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides init, setup and teardown functions for rose macro tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function init() {
mkdir -p $TEST_DIR/config
Expand Down
1 change: 0 additions & 1 deletion t/rose-config-dump/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides header for "rose config-dump" tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function setup() {
mkdir $TEST_DIR/run
Expand Down
1 change: 0 additions & 1 deletion t/rose-config/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides header for "rose config-dump" tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function setup() {
mkdir $TEST_DIR/run
Expand Down
23 changes: 0 additions & 23 deletions t/rose-date/test_header

This file was deleted.

1 change: 1 addition & 0 deletions t/rose-date/test_header
1 change: 0 additions & 1 deletion t/rose-env-cat/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides header for "rose config-dump" tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function setup() {
mkdir $TEST_DIR/run
Expand Down
23 changes: 0 additions & 23 deletions t/rose-host-select/test_header

This file was deleted.

1 change: 1 addition & 0 deletions t/rose-host-select/test_header
1 change: 0 additions & 1 deletion t/rose-macro/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides init, setup and teardown functions for rose macro tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function init() {
mkdir -p $TEST_DIR/config
Expand Down
1 change: 0 additions & 1 deletion t/rose-metadata-check/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides init, setup and teardown functions for rose metadata-check tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function init() {
mkdir -p $TEST_DIR/config
Expand Down
1 change: 0 additions & 1 deletion t/rose-metadata-gen/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides init, setup and teardown functions for rose metadata-gen tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function init() {
mkdir $TEST_DIR/config
Expand Down
1 change: 0 additions & 1 deletion t/rose-mpi-launch/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
# Provides header for "rose date" tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)
export ROSE_CONF_PATH=$TEST_SOURCE_DIR/etc
export PATH=$TEST_SOURCE_DIR/bin:$PATH
1 change: 0 additions & 1 deletion t/rose-namelist-dump/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides init, setup and teardown functions for rose app-run tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function setup() {
mkdir $TEST_DIR/run
Expand Down
23 changes: 0 additions & 23 deletions t/rose-rug-brief-tour/test_header

This file was deleted.

1 change: 1 addition & 0 deletions t/rose-rug-brief-tour/test_header
23 changes: 0 additions & 23 deletions t/rose-suite-hook/test_header

This file was deleted.

1 change: 1 addition & 0 deletions t/rose-suite-hook/test_header
23 changes: 0 additions & 23 deletions t/rose-suite-log/test_header

This file was deleted.

1 change: 1 addition & 0 deletions t/rose-suite-log/test_header
86 changes: 86 additions & 0 deletions t/rose-suite-run/00-run-basic.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# (C) British Crown Copyright 2012-3 Met Office.
#
# This file is part of Rose, a framework for scientific suites.
#
# Rose 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.
#
# Rose 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 Rose. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test "rose suite-run", with and without site/user configurations.
#-------------------------------------------------------------------------------
. $(dirname $0)/test_header

#-------------------------------------------------------------------------------
N_TESTS=10
tests $N_TESTS
#-------------------------------------------------------------------------------
# Run the suite.
if [[ $TEST_KEY_BASE == *conf ]]; then
if ! rose config -q 'rose-suite-run' 'hosts'; then
skip $N_TESTS '[rose-suite-run]hosts not defined'
exit 0
fi
else
export ROSE_CONF_IGNORE=true
fi
TEST_KEY=$TEST_KEY_BASE
SUITE_RUN_DIR=$(mktemp -d --tmpdir=$HOME/cylc-run 'rose-test-battery.XXXXXX')
NAME=$(basename $SUITE_RUN_DIR)
run_pass "$TEST_KEY" \
rose suite-run -C $TEST_SOURCE_DIR/$TEST_KEY_BASE --name=$NAME --no-gcontrol
HOST=$(<$SUITE_RUN_DIR/log/rose-suite-run.host)
#-------------------------------------------------------------------------------
# "rose suite-run" should not work while suite is running.
# except --reload mode.
TEST_KEY=$TEST_KEY_BASE-running-run
run_fail "$TEST_KEY" rose suite-run -i \
-C $TEST_SOURCE_DIR/$TEST_KEY_BASE --name=$NAME --no-gcontrol
file_cmp "$TEST_KEY.err" "$TEST_KEY.err" <<__ERR__
[FAIL] $NAME: is already running on $HOST
__ERR__
run_fail "$TEST_KEY" rose suite-run \
-C $TEST_SOURCE_DIR/$TEST_KEY_BASE --name=$NAME --no-gcontrol
file_cmp "$TEST_KEY.err" "$TEST_KEY.err" <<__ERR__
[FAIL] $NAME: is already running on $HOST
__ERR__
TEST_KEY=$TEST_KEY_BASE-running-restart
run_fail "$TEST_KEY" rose suite-run --restart \
-C $TEST_SOURCE_DIR/$TEST_KEY_BASE --name=$NAME --no-gcontrol
file_cmp "$TEST_KEY.err" "$TEST_KEY.err" <<__ERR__
[FAIL] $NAME: is already running on $HOST
__ERR__
TEST_KEY=$TEST_KEY_BASE-running-reload
run_pass "$TEST_KEY" rose suite-run --reload \
-C $TEST_SOURCE_DIR/$TEST_KEY_BASE --name=$NAME --no-gcontrol
#-------------------------------------------------------------------------------
# Wait for the suite to complete
TEST_KEY=$TEST_KEY_BASE-suite-run-wait
touch $SUITE_RUN_DIR/flag # allow the task to die
TIMEOUT=$(($(date +%s) + 300)) # wait 5 minutes
OK=false
while [[ -e $HOME/.cylc/ports/$NAME ]] && (($(date +%s) < TIMEOUT)); do
sleep 1
done
if [[ -e $HOME/.cylc/ports/$NAME ]]; then
fail "$TEST_KEY"
exit 1
else
OK=true
pass "$TEST_KEY"
fi
#-------------------------------------------------------------------------------
TEST_KEY=$TEST_KEY_BASE-clean
run_pass "$TEST_KEY" rose suite-clean -y $NAME
rmdir $SUITE_RUN_DIR || true
exit 0
1 change: 1 addition & 0 deletions t/rose-suite-run/00-run-basic/01-run-basic-conf
Empty file.
40 changes: 40 additions & 0 deletions t/rose-suite-run/00-run-basic/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!jinja2
[cylc]
UTC mode = True
[[event hooks]]
timeout handler = "rose suite-hook --shutdown"
timeout = 2
[scheduling]
initial cycle time = 2013010100
final cycle time = 2013010200
[[dependencies]]
[[[ 0, 12 ]]]
graph = """
my_task_1
"""

[runtime]
[[root]]
command scripting = """
I=0
OLD_I=
while [[ ! -e $CYLC_SUITE_RUN_DIR/flag ]]; do
sleep 1
((++I))
if [[ -n $OLD_I ]]; then
echo -n $(tr '[:print:]' '\b' <<<"$OLD_I")
fi
echo -n $I
OLD_I=$I
done
echo
"""
[[[event hooks]]]
succeeded handler = "rose suite-hook"
failed handler = "rose suite-hook --shutdown"
submission failed handler = "rose suite-hook --shutdown"
submission timeout handler = "rose suite-hook"
execution timeout handler = "rose suite-hook"
submission timeout = 1
execution timeout = 1
[[my_task_1]]
1 change: 1 addition & 0 deletions t/rose-suite-run/01-run-basic-conf
1 change: 1 addition & 0 deletions t/rose-suite-run/01-run-basic-conf.t
1 change: 1 addition & 0 deletions t/rose-suite-run/test_header
23 changes: 0 additions & 23 deletions t/rose-task-run/test_header

This file was deleted.

1 change: 1 addition & 0 deletions t/rose-task-run/test_header
1 change: 0 additions & 1 deletion t/rose.variable/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Provides init, setup and teardown functions for rose metadata-gen tests.
#-------------------------------------------------------------------------------
. $(dirname $0)/../lib/bash/test_header
TEST_KEY_BASE=$(basename $0 .t)

function init() {
mkdir $TEST_DIR/config
Expand Down
Loading

0 comments on commit 50cd2d3

Please sign in to comment.