How to track the progress of a test schedule execution?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 08:04 AM
I've written a Scripted REST API which will start a scheduled 'on-demand' test (see below code). It takes a schedule sysID as input parameter, and starts a run.
I want to be able to track the progress of the test and indicate when it's finished. What's the best way to get that information?
(function process(request, response) {
var scheduleId = request.pathParams.schedule_sys_id;
gs.info("Run schedule: scheduledId =" + scheduleId);
if (!scheduleId) {
response.setStatus(400);
return { error: "Missing schedule_sys_id in path" };
}
try {
var runId = new sn_atf.ScheduledRunsExecutor()
.setScheduleSysId(scheduleId)
//.setImpersonatingUser(gs.getUserID()) // Optional: runs as the caller
.start();
response.setStatus(202); // Accepted
return {
status: "queued",
scheduleId: scheduleId,
run_sys_id: runId
};
} catch (e) {
response.setStatus(500);
return {
error: "Failed to start schedule",
message: e.message
};
}
})(request, response);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 08:57 AM
"So referring back to my original code, the 'run_id' is actually a sysID of the record in the sys_execution_tracker table. " -> That's wrong and was not stated by me!
I wrote "by the Job created in your script." And that's the reason it's complicated. The job creates then an execution tracker. However in your foreground script you will not be able to catch this directly.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 01:06 AM
ok 'runID' is not the sysID of a record in the sys_execution_tracker table it's the source value. Using the above query, I'm able to retrieve the sys_execution_tracker record I need.
Just needed to convert that SQL query into a Scripted REST API, which I've now done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 05:15 AM
Correction, the SQL query to get the execution tracker is:
select * from sys_execution_tracker where parent='<runID>';