Skip to content

Commit

Permalink
Fix func tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Sep 5, 2023
1 parent f79fb1d commit 08f83fc
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 19 deletions.
11 changes: 7 additions & 4 deletions cylc/flow/network/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,13 @@ async def _mutation_mapper(
except AttributeError:
raise ValueError(f"Command '{command}' not found")

return self.schd.queue_command(
command,
[],
kwargs
return (
True,
self.schd.queue_command(
command,
[],
kwargs
)
)

def broadcast(
Expand Down
8 changes: 4 additions & 4 deletions cylc/flow/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ def queue_command(
sep = ', ' if kwargs_string and args_string else ''
uuid = str(uuid4())
LOG.info(
f"[command] queued {uuid}:\n"
f"[command] queued: {uuid}:\n"
f"{name}({args_string}{sep}{kwargs_string})"
)
self.command_queue.put(
Expand Down Expand Up @@ -947,7 +947,7 @@ async def process_command_queue(self) -> None:
uuid, name, args, kwargs = self.command_queue.get(False)
except Empty:
break
msg = f"[command] actioned {uuid} ({name})"
msg = f"[command] actioned: {uuid} ({name})"
try:
fcn = self.get_command_method(name)
n_warnings: Optional[int]
Expand Down Expand Up @@ -1085,10 +1085,10 @@ def command_pause(self) -> None:
self.pause_workflow()

@staticmethod
def command_set_verbosity(lvl: Union[int, str]) -> None:
def command_set_verbosity(level: Union[int, str]) -> None:
"""Set workflow verbosity."""
try:
lvl = int(lvl)
lvl = int(level)
LOG.setLevel(lvl)
except (TypeError, ValueError) as exc:
raise CommandFailedError(exc)
Expand Down
5 changes: 3 additions & 2 deletions tests/functional/cli/03-set-verbosity.t
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ run_ok "${TEST_NAME}-validate" cylc validate "$WORKFLOW_NAME"
workflow_run_ok "${TEST_NAME}-run" cylc play --pause "$WORKFLOW_NAME"

run_ok "$TEST_NAME" cylc set-verbosity DEBUG "$WORKFLOW_NAME"
log_scan "${TEST_NAME}-grep" "${WORKFLOW_RUN_DIR}/log/scheduler/log" 5 1 \
'Command actioned: set_verbosity'
LOG_SCAN_GREP_OPTS="-E" \
log_scan "${TEST_NAME}-grep" "${WORKFLOW_RUN_DIR}/log/scheduler/log" 5 1 \
'\[command] actioned.*set_verbosity'

cylc stop "$WORKFLOW_NAME"
purge
2 changes: 1 addition & 1 deletion tests/functional/hold-release/00-workflow/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
script = """
cylc__job__wait_cylc_message_started
cylc hold --after=1900 "${CYLC_WORKFLOW_ID}"
cylc__job__poll_grep_workflow_log -F 'INFO - Command actioned: set_hold_point'
cylc__job__poll_grep_workflow_log -E 'INFO - \[command] actioned.*set_hold_point'
cylc release --all "${CYLC_WORKFLOW_ID}"
"""
[[foo,bar]]
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/hold-release/05-release.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__'
script = """
cylc__job__wait_cylc_message_started
cylc hold --after=0 ${CYLC_WORKFLOW_ID}
cylc__job__poll_grep_workflow_log 'Command actioned: set_hold_point'
cylc__job__poll_grep_workflow_log -E '\[command] actioned.*set_hold_point'
cylc release "${CYLC_WORKFLOW_ID}//1/*FF" # inexact fam
cylc release "${CYLC_WORKFLOW_ID}//1/TOAST" # exact fam
cylc release "${CYLC_WORKFLOW_ID}//1/cat*" # inexact tasks
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/lib/bash/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
# tries grepping for each PATTERN in turn. Tests will only pass if the
# PATTERNs appear in FILE in the correct order. Runs one test per
# pattern, each prefixed by TEST_NAME.
# set LOG_SCAN_GREP_OPTS in the environment, e.g. "-E" for "grep -E"
# make_rnd_workflow
# Create a randomly-named workflow source directory.
# mock_smtpd_init
Expand Down Expand Up @@ -579,6 +580,7 @@ log_scan () {
local FILE="$2"
local REPS=$3
local DELAY=$4
local OPTS=${LOG_SCAN_GREP_OPTS:-}
if ${CYLC_TEST_DEBUG:-false}; then
local ERR=2
else
Expand All @@ -595,7 +597,8 @@ log_scan () {
echo -n "scanning for '${pattern:0:30}'" >& $ERR
for _ in $(seq 1 "${REPS}"); do
echo -n '.' >& $ERR
newposition=$(grep -n "$pattern" "$FILE" | \
>&2 echo grep -n $OPTS "$pattern"
newposition=$(grep -n $OPTS "$pattern" "$FILE" | \
tail -n 1 | cut -d ':' -f 1)
if (( newposition > position )); then
position=$newposition
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/pause-resume/00-workflow/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
script = """
wait
cylc pause "${CYLC_WORKFLOW_ID}"
cylc__job__poll_grep_workflow_log -F 'INFO - Command actioned: pause()'
cylc__job__poll_grep_workflow_log -E 'INFO - \[command] actioned.*pause'
cylc play "${CYLC_WORKFLOW_ID}"
"""
[[foo,bar]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[[t-pause]]
script = """
cylc pause "${CYLC_WORKFLOW_ID}"
cylc__job__poll_grep_workflow_log -F 'Command actioned: pause'
cylc__job__poll_grep_workflow_log -E '\[command].*actioned.*pause'
# Poll t-submit-retry-able, should return submit-fail
cylc poll "${CYLC_WORKFLOW_ID}//*/t-submit-retry-able"
Expand Down
14 changes: 12 additions & 2 deletions tests/functional/reload/25-xtriggers.t
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,21 @@ workflow_run_ok "${TEST_NAME_BASE}-run" cylc play "${WORKFLOW_NAME}" --no-detach
# 3. the retry xtrigger for "1/broken" becomes satisfied (after the reload)
# (thus proving that the xtrigger survived the reload)
# 4. "1/broken" succeeds

log_scan "${TEST_NAME_BASE}-scan" \
"$(cylc cat-log -m p "${WORKFLOW_NAME}")" \
1 1 \
'1/broken .* (received)failed/ERR'

LOG_SCAN_GREP_OPTS="-E" \
log_scan "${TEST_NAME_BASE}-scan" \
"$(cylc cat-log -m p "${WORKFLOW_NAME}")" \
1 1 \
'\[command] actioned.*reload_workflow' \

log_scan "${TEST_NAME_BASE}-scan" \
"$(cylc cat-log -m p "${WORKFLOW_NAME}")" \
1 1 \
'1/broken .* (received)failed/ERR' \
'Command actioned: reload_workflow()' \
'xtrigger satisfied: _cylc_retry_1/broken' \
'\[1/broken .* => succeeded'

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/spawn-on-demand/05-stop-flow/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
[[bar]]
script = """
cylc stop --flow=1 ${CYLC_WORKFLOW_ID}
cylc__job__poll_grep_workflow_log 'Command actioned: stop'
cylc__job__poll_grep_workflow_log -E '\[command] actioned.*stop'
"""
2 changes: 1 addition & 1 deletion tests/functional/spawn-on-demand/06-stop-flow-2/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
script = """
if (( CYLC_TASK_SUBMIT_NUMBER == 2 )); then
cylc stop --flow=1 ${CYLC_WORKFLOW_ID}
cylc__job__poll_grep_workflow_log "Command actioned: stop"
cylc__job__poll_grep_workflow_log -E "\[command] actioned.*stop"
fi
"""
[[baz]]
Expand Down

0 comments on commit 08f83fc

Please sign in to comment.