Monday, November 21, 2011

Testlink: Timeout Exception in reports after setting up integration with Bug tracking system

We are using testlink and already did setup for integration with bug tracking system that we are using, trac. While doing testing after this step we found out that some reports are not working and it is giving timeout exception

after digging into the code looking for why this is happening, I found out that there is some loop that is calling the bug tracking system for each bug attached to test case.

The function that is called to get the bug is called get_bugs_for_exec, found in exec.inc.php file

This function is not causing any problem when opening the test cases, it is listing the bugs and getting the bug data from bug tracking system without any problems

To workaround the error I am getting in the reports, I have created another function called get_bugs_for_exec_reports with the same implementation but instead of calling the bug interface to get bug details, I just commented this part and only displayed the bug number, this will be enough for the reports, then in reports files, I changed instead of calling get_bugs_for_exec, I am calling get_bugs_for_exec_reports

files where I have done this change

\lib\functions\results.class.php

\lib\results\resultsByStatus.php

\lib\results\resultsBugs.php

Function:

function get_bugs_for_exec_report(&$db,&$bug_interface,$execution_id)
{
    $tables['execution_bugs'] = DB_TABLE_PREFIX . 'execution_bugs';
    $tables['executions'] = DB_TABLE_PREFIX . 'executions';
    $tables['builds'] = DB_TABLE_PREFIX . 'builds';
   
    $bug_list=array();
    $sql = "SELECT execution_id,bug_id,builds.name AS build_name " .
        "FROM {$tables['execution_bugs']}, {$tables['executions']} executions, " .
        " {$tables['builds']} builds ".
        "WHERE execution_id={$execution_id} " .
        "AND   execution_id=executions.id " .
        "AND   executions.build_id=builds.id " .
        "ORDER BY builds.name,bug_id";
    $map = $db->get_recordset($sql);
   
    // BUGID 3440 - added is_object() check
    if( !is_null($map) && is_object($bug_interface))
    {     
        foreach($map as $elem)
        {
            $bug_list[$elem['bug_id']]['link_to_bts'] = $elem['bug_id'];#$bug_interface->buildViewBugLink($elem['bug_id'],GET_BUG_SUMMARY);
            $bug_list[$elem['bug_id']]['build_name'] = $elem['build_name'];
        }
    }   
    return($bug_list);
}