Skip to content

Commit

Permalink
More flaky fixes
Browse files Browse the repository at this point in the history
Tidy up logic.
Unnecessary sleeps.
Shellcheck.
  • Loading branch information
matthewrmshin committed Aug 14, 2019
1 parent ae964d2 commit f0c19d4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 71 deletions.
6 changes: 3 additions & 3 deletions flakytests/shutdown/02-no-dir.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#-------------------------------------------------------------------------------
# Test suite can shutdown successfully if its run dir is deleted
. "$(dirname "$0")/test_header"
set_test_number 3
set_test_number 4
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
Expand All @@ -26,8 +26,8 @@ SYM_SUITE_RUND="${SUITE_RUN_DIR}-sym"
SYM_SUITE_NAME="${SUITE_NAME}-sym"
ln -s "$(basename "${SUITE_NAME}")" "${SYM_SUITE_RUND}"
run_fail "${TEST_NAME_BASE}-run" cylc run "${SYM_SUITE_NAME}" --debug --no-detach
grep_ok 'CRITICAL - Suite shutting down - unable to open database file' \
"${SUITE_RUN_DIR}/log/suite/log".*
grep_ok 'CRITICAL - Suite shutting down' "${SUITE_RUN_DIR}/log/suite/log".*
grep_ok 'unable to open database file' "${SUITE_RUN_DIR}/log/suite/log".*

rm -f "${SYM_SUITE_RUND}"
purge_suite "${SUITE_NAME}"
Expand Down
2 changes: 1 addition & 1 deletion flakytests/special/06-clock-triggered-iso.t
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ run_fail "${TEST_NAME_BASE}-run-later" \
-s 'OFFSET=PT0S' \
-s 'TIMEOUT=PT12S'
#-------------------------------------------------------------------------------
purge_suite "{$SUITE_NAME}"
purge_suite "${SUITE_NAME}"
exit
41 changes: 12 additions & 29 deletions tests/cyclers/40-integer_exclusions_advanced.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test intercycle dependencies.
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
if [[ -f "$TEST_SOURCE_DIR/$TEST_NAME_BASE-find.out" ]]; then
set_test_number 4
else
set_test_number 3
fi
#-------------------------------------------------------------------------------
CHOSEN_SUITE=$(basename $0 | sed "s/^.*-\(.*\)\.t/\1/g")
install_suite $TEST_NAME_BASE $CHOSEN_SUITE
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-validate
run_ok $TEST_NAME cylc validate "$SUITE_NAME"
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-graph
graph_suite "$SUITE_NAME" "$SUITE_NAME.graph.plain"
cmp_ok "$SUITE_NAME.graph.plain" "$TEST_SOURCE_DIR/$CHOSEN_SUITE/graph.plain.ref"
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug --no-detach $SUITE_NAME
#-------------------------------------------------------------------------------
if [[ -f "$TEST_SOURCE_DIR/$TEST_NAME_BASE-find.out" ]]; then
TEST_NAME="$TEST_NAME_BASE-find"
SUITE_DIR="$(cylc get-global-config --print-run-dir)/$SUITE_NAME"
(cd "$SUITE_DIR"; find log/job work -type f | sort -V) >"$TEST_NAME"
cmp_ok "$TEST_NAME" "$TEST_SOURCE_DIR/$TEST_NAME_BASE-find.out"
fi
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME
. "$(dirname "$0")/test_header"
set_test_number 3
install_suite "${TEST_NAME_BASE}" 'integer_exclusions_advanced'
#-------------------------------------------------------------------------------
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
graph_suite "${SUITE_NAME}" "${SUITE_NAME}.graph.plain"
cmp_ok "${SUITE_NAME}.graph.plain" 'graph.plain.ref'
suite_run_ok "${TEST_NAME_BASE}-run" \
cylc run --reference-test --debug --no-detach "${SUITE_NAME}"
#-------------------------------------------------------------------------------
purge_suite "${SUITE_NAME}"
exit
11 changes: 4 additions & 7 deletions tests/cyclers/integer_exclusions_advanced/suite.rc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
[runtime]
[[foo]]
script = """
sleep 5
cylc task message "the cheese is ready"
sleep 5
touch typing
"""
wait
cylc message -- "${CYLC_SUITE_NAME}" "${CYLC_TASK_JOB}" 'the cheese is ready'
"""
[[[outputs]]]
out1 = "the cheese is ready"

out1 = the cheese is ready
[visualization]
initial cycle point = 1
final cycle point = 16
56 changes: 25 additions & 31 deletions tests/reload/17-graphing-change.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,77 +16,71 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test that removing a task from the graph works OK.
. $(dirname $0)/test_header
. "$(dirname "$0")/test_header"
#-------------------------------------------------------------------------------
set_test_number 13
#-------------------------------------------------------------------------------
# test reporting of added tasks

# install suite
install_suite $TEST_NAME_BASE graphing-change
LOG_FILE="$HOME/cylc-run/$SUITE_NAME/log/suite/log"
TEST_NAME=$TEST_NAME_BASE-add-run
install_suite "${TEST_NAME_BASE}" 'graphing-change'
LOG_FILE="${SUITE_RUN_DIR}/log/suite/log"

# start suite in held mode
run_ok $TEST_NAME cylc run --hold $SUITE_NAME
sleep 5
run_ok "${TEST_NAME_BASE}-add-run" cylc run --hold "${SUITE_NAME}"

# change the suite.rc file
cp "$TEST_SOURCE_DIR/graphing-change/suite-1.rc" "$TEST_DIR/$SUITE_NAME/suite.rc"
cp "${TEST_SOURCE_DIR}/graphing-change/suite-1.rc" \
"${TEST_DIR}/${SUITE_NAME}/suite.rc"

# reload suite
TEST_NAME=$TEST_NAME_BASE-add-reload
run_ok $TEST_NAME cylc reload $SUITE_NAME
run_ok "${TEST_NAME_BASE}-add-reload" cylc reload "${SUITE_NAME}"
while (($(grep -c 'Reload completed' "${LOG_FILE}" || true) < 1)); do
sleep 1 # make sure reload 1 completes
done

# check suite log
grep_ok "Added task: 'one'" $LOG_FILE
grep_ok "Added task: 'one'" "${LOG_FILE}"
#-------------------------------------------------------------------------------
# test reporting or removed tasks

# change the suite.rc file
cp "$TEST_SOURCE_DIR/graphing-change/suite.rc" "$TEST_DIR/$SUITE_NAME/suite.rc"
cp "${TEST_SOURCE_DIR}/graphing-change/suite.rc" \
"${TEST_DIR}/${SUITE_NAME}/suite.rc"

# reload suite
TEST_NAME=$TEST_NAME_BASE-remove-reload
run_ok $TEST_NAME cylc reload $SUITE_NAME
run_ok "${TEST_NAME_BASE}-remove-reload" cylc reload "${SUITE_NAME}"
while (($(grep -c 'Reload completed' "${LOG_FILE}" || true) < 2)); do
sleep 1 # make sure reload 2 completes
done

# check suite log
grep_ok "Removed task: 'one'" $LOG_FILE
grep_ok "Removed task: 'one'" "${LOG_FILE}"
#-------------------------------------------------------------------------------
# test reporting of adding / removing / swapping tasks

# set suite running
TEST_NAME=$TEST_NAME_BASE-unhold
run_ok $TEST_NAME cylc unhold $SUITE_NAME
run_ok "${TEST_NAME_BASE}-release" cylc release "${SUITE_NAME}"

# change the suite.rc file
cp "$TEST_SOURCE_DIR/graphing-change/suite-2.rc" "$TEST_DIR/$SUITE_NAME/suite.rc"
cp "${TEST_SOURCE_DIR}/graphing-change/suite-2.rc" \
"${TEST_DIR}/${SUITE_NAME}/suite.rc"

# reload suite
TEST_NAME=$TEST_NAME_BASE-swap-reload
run_ok $TEST_NAME cylc reload $SUITE_NAME
run_ok "${TEST_NAME_BASE}-swap-reload" cylc reload "${SUITE_NAME}"
while (($(grep -c 'Reload completed' "${LOG_FILE}" || true) < 3)); do
sleep 1 # make sure reload 3 completes
done

# check suite log
TEST_NAME=$TEST_NAME_BASE-swap-log
grep_ok "Added task: 'one'" $LOG_FILE
grep_ok "Added task: 'add'" $LOG_FILE
grep_ok "Added task: 'boo'" $LOG_FILE
grep_ok "\[bar.*\].*orphaned" $LOG_FILE
grep_ok "\[bol.*\].*orphaned" $LOG_FILE
grep_ok "Added task: 'one'" "${LOG_FILE}"
grep_ok "Added task: 'add'" "${LOG_FILE}"
grep_ok "Added task: 'boo'" "${LOG_FILE}"
grep_ok "\\[bar.*\\].*orphaned" "${LOG_FILE}"
grep_ok "\\[bol.*\\].*orphaned" "${LOG_FILE}"

# shutdown suite
TEST_NAME=$TEST_NAME_BASE-shutdown
run_ok $TEST_NAME cylc shutdown $SUITE_NAME
run_ok "${TEST_NAME_BASE}-stop" \
cylc stop --max-polls=10 --interval=2 "${SUITE_NAME}"

# tidy up
purge_suite $SUITE_NAME
#-------------------------------------------------------------------------------
purge_suite "${SUITE_NAME}"
exit

0 comments on commit f0c19d4

Please sign in to comment.