Skip to content

Commit

Permalink
Add status value to report events, update tests. [#137]
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Feb 17, 2011
1 parent ef691d9 commit 3852511
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
1 change: 1 addition & 0 deletions docs/en/09-api/01-chapter10.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ Result: an Item List of `events`. Each `event` has this form:

<event starttime="[unixtime]" endtime="[unixtime]">
<title>[job title, or "adhoc"]</title>
<status>[status]</status>
<summary>[summary text]</summary>
<node-summary succeeded="[X]" failed="[Y]" total="[Z]"/>
<user>[user]</user>
Expand Down
4 changes: 4 additions & 0 deletions rundeckapp/grails-app/controllers/ReportsController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ class ReportsController {
def model=reportService.getCombinedReports(query)
model = reportService.finishquery(query,params,model)

def statusMap=[succeed:ExecutionController.EXECUTION_SUCCEEDED,
cancel:ExecutionController.EXECUTION_ABORTED,
fail:ExecutionController.EXECUTION_FAILED]
return new ApiController().success{ delegate->
delegate.'events'(count:model.reports.size(),total:model.total, max: model.max, offset: model.offset){
model.reports.each{ rpt->
Expand All @@ -404,6 +407,7 @@ class ReportsController {
}
event(starttime:rpt.dateStarted.time,endtime:rpt.dateCompleted.time){
title(rpt.reportId?:'adhoc')
status(statusMap[rpt.status]?:rpt.status)
summary(rpt.adhocScript?:rpt.title)
delegate.'node-summary'(succeeded:nodesum[0],failed:nodesum[1],total:nodesum[2])
user(rpt.author)
Expand Down
35 changes: 14 additions & 21 deletions test/api/test-history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ echo "TEST: output from /api/history should be valid"
params="project=${proj}"

# get listing
$CURL --header "$VERSHEADER" ${runurl}?${params} > $DIR/curl.out
if [ 0 != $? ] ; then
errorMsg "ERROR: failed query request"
exit 2
fi
$CURL ${runurl}?${params} > $DIR/curl.out || fail "failed request: ${runurl}"

sh $DIR/api-test-success.sh $DIR/curl.out || exit 2

#Check projects list
itemcount=$($XMLSTARLET sel -T -t -v "/result/events/@count" $DIR/curl.out)
if [ "" == "$itemcount" ] ; then
errorMsg "FAIL: expected events count"
exit 2
fi
itemcount=$(xmlsel "/result/events/@count" $DIR/curl.out)
[ "" == "$itemcount" ] && fail "expected events count"

EXPECTED="title summary user status @starttime @endtime node-summary/@succeeded node-summary/@failed node-summary/@total user project date-started date-ended"
for i in $EXPECTED ; do
evalue=$($XMLSTARLET sel -T -t -m "/result/events/event[1]" -v "$i" $DIR/curl.out)
[ "" == "$evalue" ] && fail "expected $i"
evalue=""
done


echo "OK"

Expand All @@ -54,11 +55,7 @@ echo "OK"
echo "TEST: /api/history using valid \"end\" date format parameter"
params="project=${proj}&end=2011-02-04T21:38:02Z"

$CURL --header "$VERSHEADER" ${runurl}?${params} > $DIR/curl.out
if [ 0 != $? ] ; then
errorMsg "ERROR: failed query request"
exit 2
fi
$CURL ${runurl}?${params} > $DIR/curl.out || fail "failed request: ${runurl}"

sh $DIR/api-test-success.sh $DIR/curl.out || exit 2
echo "OK"
Expand All @@ -67,14 +64,10 @@ echo "OK"
echo "TEST: /api/history using valid \"begin\" date format parameter"
params="project=${proj}&begin=2011-02-04T21:03:34Z"

$CURL --header "$VERSHEADER" ${runurl}?${params} > $DIR/curl.out
if [ 0 != $? ] ; then
errorMsg "ERROR: failed query request"
exit 2
fi
$CURL ${runurl}?${params} > $DIR/curl.out || fail "failed request: ${runurl}"

sh $DIR/api-test-success.sh $DIR/curl.out || exit 2
echo "OK"

#rm $DIR/curl.out
rm $DIR/curl.out

0 comments on commit 3852511

Please sign in to comment.