The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to track the progress of a test schedule execution?

afielden
Tera Contributor

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);
7 REPLIES 7

"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

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.

 

Correction, the SQL query to get the execution tracker is:

 

select * from sys_execution_tracker where parent='<runID>';