Skip to content

Commit

Permalink
testsuite: Add flux jobs annotation tests
Browse files Browse the repository at this point in the history
Add flux jobs annotation tests to t2203-job-manager-dummysched-single
and t2204-job-manager-dummysched-unlimited.

Add output header tests to t2800-jobs-cmd.t.
  • Loading branch information
chu11 committed Jul 21, 2020
1 parent 8b81904 commit c3822c8
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 7 deletions.
39 changes: 39 additions & 0 deletions t/job-manager/sched-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,42 @@ jinfo_check_annotation_exists() {
local key=$2
flux job list -A | grep ${id} | jq .annotations | jq -e ."${key}" > /dev/null
}

# verify if annotation seen via flux-jobs
#
# function will loop for up to 5 seconds in case annotation update
# arrives slowly
#
# arg1 - jobid
# arg2 - key in annotation
# arg3 - value of key in annotation
fjobs_check_annotation() {
local id=$1
local key=$2
local value="$3"
for try in $(seq 1 10); do
test "$(flux jobs -n --format={${key}} ${id})" = "${value}" && return 0
sleep 0.5
done
return 1
}

# verify that flux-jobs see no annotations
#
# arg1 - jobid
fjobs_check_no_annotations() {
local id=$1
test -z $(flux jobs -n --format="{annotations}" ${id}) && return 0
return 1
}

# verify flux-jobs sees annotation
#
# arg1 - jobid
# arg2 - key in annotation
fjobs_check_annotation_exists() {
local id=$1
local key=$2
test -z $(flux jobs -n --format="{${key}}" ${id}) && return 1
return 0
}
36 changes: 30 additions & 6 deletions t/t2203-job-manager-dummysched-single.t
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ test_expect_success HAVE_JQ 'job-manager: annotate job id 3 in job-info (RRSSS)'
jinfo_check_no_annotations $(cat job5.id)
'

test_expect_success 'job-manager: annotate job id 3 in flux-jobs (RRSSS)' '
fjobs_check_no_annotations $(cat job1.id) &&
fjobs_check_no_annotations $(cat job2.id) &&
fjobs_check_annotation $(cat job3.id) "annotations.sched.reason_pending" "no cores available" &&
fjobs_check_no_annotations $(cat job4.id) &&
fjobs_check_no_annotations $(cat job5.id)
'

test_expect_success 'job-manager: running job has alloc event' '
flux job wait-event --timeout=5.0 $(cat job1.id) alloc
'
Expand All @@ -99,12 +107,12 @@ test_expect_success HAVE_JQ 'job-manager: annotate job id 4 (RIRSS)' '
jmgr_check_no_annotations $(cat job5.id)
'

test_expect_success HAVE_JQ 'job-manager: annotate job id 4 in job-info (RRSSS)' '
jinfo_check_no_annotations $(cat job1.id) &&
jinfo_check_no_annotations $(cat job2.id) &&
jinfo_check_no_annotations $(cat job3.id) &&
jinfo_check_annotation $(cat job4.id) "sched.reason_pending" "\"no cores available\"" &&
jinfo_check_no_annotations $(cat job5.id)
test_expect_success 'job-manager: annotate job id 4 in flux jobs (RRSSS)' '
fjobs_check_no_annotations $(cat job1.id) &&
fjobs_check_no_annotations $(cat job2.id) &&
fjobs_check_no_annotations $(cat job3.id) &&
fjobs_check_annotation $(cat job4.id) "annotations.sched.reason_pending" "no cores available" &&
fjobs_check_no_annotations $(cat job5.id)
'

test_expect_success 'job-manager: first S job sent alloc, second S did not' '
Expand Down Expand Up @@ -160,6 +168,14 @@ test_expect_success HAVE_JQ 'job-manager: no annotations in job-info (RIRRR)' '
jinfo_check_no_annotations $(cat job5.id)
'

test_expect_success 'job-manager: no annotations in flux jobs (RIRRR)' '
fjobs_check_no_annotations $(cat job1.id) &&
fjobs_check_no_annotations $(cat job2.id) &&
fjobs_check_no_annotations $(cat job3.id) &&
fjobs_check_no_annotations $(cat job4.id) &&
fjobs_check_no_annotations $(cat job5.id)
'

test_expect_success 'job-manager: cancel 1' '
flux job cancel $(cat job1.id)
'
Expand Down Expand Up @@ -202,6 +218,14 @@ test_expect_success HAVE_JQ 'job-manager: no annotations in job-info (IIIII)' '
jinfo_check_no_annotations $(cat job5.id)
'

test_expect_success 'job-manager: no annotations in flux jobs (IIIII)' '
fjobs_check_no_annotations $(cat job1.id) &&
fjobs_check_no_annotations $(cat job2.id) &&
fjobs_check_no_annotations $(cat job3.id) &&
fjobs_check_no_annotations $(cat job4.id) &&
fjobs_check_no_annotations $(cat job5.id)
'

test_expect_success 'job-manager: simulate alloc failure' '
flux module debug --setbit 0x1 sched-dummy &&
flux job submit --flags=debug basic.json >job6.id &&
Expand Down
42 changes: 42 additions & 0 deletions t/t2204-job-manager-dummysched-unlimited.t
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ test_expect_success HAVE_JQ 'job-manager: annotate job id 3-5 in job-info (RRSSS
jinfo_check_annotation $(cat job5.id) "sched.jobs_ahead" "2"
'

# XXX: non-RFC27 defined annotations such as jobs_ahead not yet supported
test_expect_success HAVE_JQ 'job-manager: annotate job id 3-5 in flux-jobs (RRSSS)' '
fjobs_check_annotation $(cat job1.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_annotation $(cat job2.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_annotation $(cat job3.id) "annotations.sched.reason_pending" "no cores" &&
fjobs_check_annotation $(cat job4.id) "annotations.sched.reason_pending" "no cores" &&
fjobs_check_annotation $(cat job5.id) "annotations.sched.reason_pending" "no cores"
'

test_expect_success 'job-manager: cancel 2' '
flux job cancel $(cat job2.id)
'
Expand Down Expand Up @@ -119,6 +128,18 @@ test_expect_success HAVE_JQ 'job-manager: annotate job id 4-5 in job-info (RIRSS
jinfo_check_annotation $(cat job5.id) "sched.jobs_ahead" "1"
'

# compared to above, note that job id #2 retains annotations, it is
# cached in job-info
# XXX: non-RFC27 defined annotations such as jobs_ahead not yet supported
test_expect_success HAVE_JQ 'job-manager: annotate job id 4-5 in flux-jobs (RIRSS)' '
fjobs_check_annotation $(cat job1.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_annotation $(cat job2.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_annotation $(cat job3.id) "annotations.sched.resource_summary" "1core" &&
test_must_fail fjobs_check_annotation_exists $(cat job3.id) "annotations.sched.reason_pending" &&
fjobs_check_annotation $(cat job4.id) "annotations.sched.reason_pending" "no cores" &&
fjobs_check_annotation $(cat job5.id) "annotations.sched.reason_pending" "no cores"
'

test_expect_success 'job-manager: cancel 5' '
flux job cancel $(cat job5.id)
'
Expand Down Expand Up @@ -155,6 +176,18 @@ test_expect_success HAVE_JQ 'job-manager: annotate job id 4-5 in job-info (RIRSS
jinfo_check_no_annotations $(cat job5.id)
'

# compared to above, note that job id #2 retains annotations, it is
# cached in job-info
# XXX: non-RFC27 defined annotations such as jobs_ahead not yet supported
test_expect_success HAVE_JQ 'job-manager: annotate job id 4-5 in flux jobs (RIRSS)' '
fjobs_check_annotation $(cat job1.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_annotation $(cat job2.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_annotation $(cat job3.id) "annotations.sched.resource_summary" "1core" &&
test_must_fail fjobs_check_annotation_exists $(cat job3.id) "annotations.sched.reason_pending" &&
fjobs_check_annotation $(cat job4.id) "annotations.sched.reason_pending" "no cores" &&
fjobs_check_no_annotations $(cat job5.id)
'

# cancel non-running jobs first, to ensure they are not accidentally run when
# running jobs free resources.
test_expect_success 'job-manager: cancel all jobs' '
Expand Down Expand Up @@ -188,6 +221,15 @@ test_expect_success HAVE_JQ 'job-manager: no annotations in canceled jobs in job
jinfo_check_no_annotations $(cat job5.id)
'

# compared to above, note that job ids that ran retain annotations
test_expect_success HAVE_JQ 'job-manager: no annotations in canceled jobs in flux jobs (IIIII)' '
fjobs_check_annotation $(cat job1.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_annotation $(cat job2.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_annotation $(cat job3.id) "annotations.sched.resource_summary" "1core" &&
fjobs_check_no_annotations $(cat job4.id) &&
fjobs_check_no_annotations $(cat job5.id)
'

test_expect_success 'job-manager: remove sched-dummy' '
flux module remove sched-dummy
'
Expand Down
7 changes: 6 additions & 1 deletion t/t2800-jobs-cmd.t
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,12 @@ test_expect_success 'flux-jobs: header included with all custom formats' '
flux jobs --format={expiration!d:%FT%T} | head -1 | grep "EXPIRATION" &&
flux jobs --format={t_remaining} | head -1 | grep "T_REMAINING" &&
flux jobs --format={t_remaining!F} | head -1 | grep "T_REMAINING" &&
flux jobs --format={t_remaining!H} | head -1 | grep "T_REMAINING"
flux jobs --format={t_remaining!H} | head -1 | grep "T_REMAINING" &&
flux jobs --format={annotations} | head -1 | grep "ANNOTATIONS" &&
flux jobs --format={annotations.sched} | head -1 | grep "SCHED" &&
flux jobs --format={annotations.sched.reason_pending} | head -1 | grep "REASON_PENDING" &&
flux jobs --format={annotations.sched.resource_summary} | head -1 | grep "RESOURCE_SUMMARY" &&
flux jobs --format={annotations.sched.t_estimate} | head -1 | grep "T_ESTIMATE"
'

test_expect_success 'flux-jobs: header still prints with conversion spec' '
Expand Down

0 comments on commit c3822c8

Please sign in to comment.