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

Maik Skoddow
Tera Patron
Tera Patron

Hi @afielden 

 

There is no direct connection to the ATF executor, as this is kicked off asynchronously in the background by the Job created in your script. However, to see the progress of any running ATF executor, you can go to table sys_execution_tracker. Search in the name field for the related ATF schedule and then check the field "Percentage complete". But again: It's pretty complicated to track that value in the foreground as it is processed in the background.

 

Maik

Thanks. I'm just trying to work out the linkage here. I looked at the sys_execution_tracker table, but there's no reference to the test suite or the schedule

 

+---------------------------+--------------+------+-----+---------+-------+
| Field                     | Type         | Null | Key | Default | Extra |
+---------------------------+--------------+------+-----+---------+-------+
| name                      | varchar(250) | YES  |     | NULL    |       |
| message                   | mediumtext   | YES  |     | NULL    |       |
| detail_message            | mediumtext   | YES  |     | NULL    |       |
| type                      | varchar(255) | YES  | MUL | NULL    |       |
| state                     | int(11)      | YES  |     | NULL    |       |
| order                     | int(11)      | YES  |     | NULL    |       |
| parent                    | varchar(32)  | YES  | MUL | NULL    |       |
| source_table              | varchar(80)  | YES  |     | NULL    |       |
| source                    | char(32)     | YES  | MUL | NULL    |       |
| subtree_weight            | double(18,7) | YES  |     | NULL    |       |
| start_time                | datetime     | YES  |     | NULL    |       |
| completion_time           | datetime     | YES  |     | NULL    |       |
| percent_complete          | int(11)      | YES  |     | NULL    |       |
| result                    | mediumtext   | YES  |     | NULL    |       |
| propagate_error_to_parent | tinyint(1)   | YES  |     | NULL    |       |
| sys_id                    | char(32)     | NO   | PRI | NULL    |       |
| sys_updated_by            | varchar(40)  | YES  |     | NULL    |       |
| sys_updated_on            | datetime     | YES  |     | NULL    |       |
| sys_created_by            | varchar(40)  | YES  |     | NULL    |       |
| sys_created_on            | datetime     | YES  |     | NULL    |       |
| sys_mod_count             | int(11)      | YES  |     | NULL    |       |
+---------------------------+--------------+------+-----+---------+-------+

The back reference can be found in the fields "source" and "source_table".

 

Maik

Thanks again. So referring back to my original code, the 'run_id' is actually a sysID of the record in the sys_execution_tracker table. I'll need this to write another Scripted REST API to poll for the result. The SQL query I need to run is below. There are many records with the corresponding run_id, so I'm getting the most recent one:

 

select * from sys_execution_tracker where source='<runID>' order by start_time desc limit 1;