예제 #1
0
function createDataForRegBuild($build)
{
    $buildDataArr = array();
    #      if ($build < 18344 || $build > 99999) return;
    // establish connection to DB
    $linkID = connectDB();
    // get a list of runIDs for this build
    $runIDsArr = getLatestRegRunsForBuild($build);
    if ($runIDsArr == "") {
        return " has NO RUNS!<br>PLEASE SEARCH ANOTHER BUILD!";
    }
    foreach ($runIDsArr as $runID => $build) {
        $caseDataArr = array();
        $passed = $running = $failed = $time = 0;
        $caseIDsArr = getCasesNoPlatform($runID);
        if (!$caseIDsArr) {
            continue;
        }
        ereg("([0-9]+\\.[0-9]+).+", $build[version], $regs);
        $release = $regs[1];
        foreach ($caseIDsArr as $caseID) {
            $caseStatusRow = getCaseStatusWithModules($runID, $caseID);
            if (!ereg('^SETUP', $caseStatusRow['caseName']) && !ereg('^CLEANUP', $caseStatusRow['caseName'])) {
                $buildDataArr[$release][builds][$build[build]][version] = $build[version];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][title] = formatCaseTitle($caseStatusRow['caseName']);
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][component] = $caseStatusRow['component'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][category] = $caseStatusRow['category'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][script] = $caseStatusRow['script'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][status] = $caseStatusRow['caseStatus'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][started] = $caseStatusRow['startedCase'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][time] = $caseStatusRow['caseExecutionTime'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][log] = $build[runlog] . $caseStatusRow['scriptlog'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][notes] = $caseStatusRow['caseRunComments'];
            }
        }
        //end case
    }
    //end run
    foreach ($buildDataArr as $release => $releaseData) {
        $time_release = 0;
        foreach ($releaseData[builds] as $versionID => $build) {
            $case_count = 0;
            foreach ($build[cases] as $caseID => $case) {
                $i = 0;
                foreach ($case[runs] as $runID => $run) {
                    if ($case_count == 0) {
                        $runArr = end($buildDataArr[$release][builds][$versionID][cases][$caseID][runs]);
                        $buildDataArr[$release][builds][$versionID][started] = $runArr[started];
                    }
                    if ($i == 0) {
                        // get runStatus from runID
                        $buildDataArr[$release][builds][$versionID][runstatus] = getRunStatusForReg($versionID);
                        if ($run[status] == "PASSED" || $run[status] == "RUNNING") {
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][status] = $run[status];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][time] = $run[time];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][started] = $run[started];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][log] = $run[log];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][notes] = $run[notes];
                            break;
                        } else {
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][status] = $run[status];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][time] = $run[time];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][started] = $run[started];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][log] = $run[log];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][notes] = $run[notes];
                        }
                    }
                    if ($run[status] == "PASSED") {
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][status] = $run[status];
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][time] = $run[time];
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][started] = $run[started];
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][log] = $run[log];
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][notes] = $run[notes];
                        break;
                    }
                    $i++;
                }
                $case_count++;
            }
            $passed = $failed = $running = 0;
            foreach ($buildDataArr[$release][builds][$versionID][cases] as $caseID => $case) {
                if (!ereg('^SETUP', $case[title]) && !ereg('^CLEANUP', $case[title])) {
                    if ($case[status] == "PASSED") {
                        $passed++;
                    } elseif ($case[status] == "RUNNING") {
                        $running++;
                    } else {
                        $failed++;
                    }
                }
                $time_release += $case['time'];
            }
            $total = $passed + $failed;
            if ($total != 0) {
                $buildDataArr[$release][builds][$versionID][total] = $total;
                $buildDataArr[$release][builds][$versionID][passed] = $passed;
                $buildDataArr[$release][builds][$versionID][running] = $running;
                $buildDataArr[$release][builds][$versionID][failed] = $failed;
                $buildDataArr[$release][builds][$versionID][status] = getPassFailStatus($failed, $buildDataArr[$release][builds][$versionID][runstatus]);
            }
        }
        //end build
        $buildDataArr[$release][time] = Sec2Time($time_release);
    }
    //end release
    mysql_close($linkID);
    insertRegressionToDB($buildDataArr);
    return $buildDataArr;
}
예제 #2
0
function createDataForPhaseBuild($phase, $dataType = "smoke")
{
    $buildDataArr = array();
    $SC_TIMES = array();
    $linkID = connectDB();
    $build = getBuildFromTable($phase);
    if ($dataType == "phase") {
        $runIDsArr = getLatestPhaseRunsForBuild($build, $phase);
        $tableQuery = "phaseResults";
    } else {
        $runIDsArr = getLatestRegRunsForBuild($build);
        $tableQuery = "regressionResults";
    }
    if ($runIDsArr == "") {
        return " has NO RUNS!<br>PLEASE SEARCH ANOTHER BUILD!";
    }
    foreach ($runIDsArr as $runID => $build) {
        $caseDataArr = array();
        $passed = $running = $failed = $time = 0;
        $caseIDsArr = getPhaseCasesNoPlatform($runID);
        if (!$caseIDsArr) {
            continue;
        }
        ereg("([0-9]+\\.[0-9]+).+", $build[version], $regs);
        $release = $regs[1];
        foreach ($caseIDsArr as $caseID) {
            $caseStatusRow = getPhaseCaseStatusWithModules($runID, $caseID);
            if ($caseStatusRow['caseStatus'] != 'NOTATTEMPTED' && !ereg('^SETUP', $caseStatusRow['caseName']) && !ereg('^CLEANUP', $caseStatusRow['caseName'])) {
                $buildDataArr[$release][phase] = $phase;
                $buildDataArr[$release][version] = $build[version];
                $buildDataArr[$release][builds][$build[build]][version] = $build[version];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][title] = formatCaseTitle($caseStatusRow['caseName']);
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][component] = $caseStatusRow['component'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][category] = $caseStatusRow['category'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][script] = $caseStatusRow['script'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][status] = $caseStatusRow['caseStatus'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][started] = $caseStatusRow['startedCase'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][time] = $caseStatusRow['caseExecutionTime'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][log] = $build[runlog] . $caseStatusRow['scriptlog'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][notes] = $caseStatusRow['caseRunComments'];
                $buildDataArr[$release][builds][$build[build]][cases][$caseID][runs][$runID][inbuild] = $build[inbuild];
                // CASE RUN TIME: ALL RUNS + SETUP/CLEANUP
                //
                if (!isset($buildDataArr[$release][builds][$build[build]][cases][$caseID][time])) {
                    $buildDataArr[$release][builds][$build[build]][cases][$caseID][time] = $caseStatusRow['caseExecutionTime'];
                } else {
                    $buildDataArr[$release][builds][$build[build]][cases][$caseID][time] += $caseStatusRow['caseExecutionTime'];
                }
            } else {
                if (!isset($SC_TIMES[$caseStatusRow['script']][time])) {
                    $SC_TIMES[$caseStatusRow['script']][time] = $caseStatusRow['caseExecutionTime'];
                } else {
                    $SC_TIMES[$caseStatusRow['script']][time] += $caseStatusRow['caseExecutionTime'];
                }
            }
        }
        //end case
    }
    //end run
    foreach ($buildDataArr as $release => $releaseData) {
        $time_release = 0;
        foreach ($releaseData[builds] as $versionID => $build) {
            $case_count = 0;
            foreach ($build[cases] as $caseID => $case) {
                $i = 0;
                foreach ($case[runs] as $runID => $run) {
                    if ($case_count == 0) {
                        $runArr = end($buildDataArr[$release][builds][$versionID][cases][$caseID][runs]);
                        $buildDataArr[$release][builds][$versionID][started] = $runArr[started];
                    }
                    if ($i == 0) {
                        // get runStatus from runID
                        $buildDataArr[$release][builds][$versionID][runstatus] = getRunStatusForReg($versionID, $tableQuery);
                        if ($run[status] == "PASSED" || $run[status] == "RUNNING") {
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][status] = $run[status];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][started] = $run[started];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][log] = $run[log];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][notes] = $run[notes];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][inbuild] = $run[inbuild];
                            break;
                        } else {
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][status] = $run[status];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][started] = $run[started];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][log] = $run[log];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][notes] = $run[notes];
                            $buildDataArr[$release][builds][$versionID][cases][$caseID][inbuild] = $run[inbuild];
                        }
                    }
                    if ($run[status] == "PASSED") {
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][status] = $run[status];
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][started] = $run[started];
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][log] = $run[log];
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][notes] = $run[notes];
                        $buildDataArr[$release][builds][$versionID][cases][$caseID][inbuild] = $run[inbuild];
                        break;
                    }
                    $i++;
                }
                $case_count++;
            }
            $passed = $failed = $running = 0;
            foreach ($buildDataArr[$release][builds][$versionID][cases] as $caseID => $case) {
                if (!ereg('^SETUP', $case[title]) && !ereg('^CLEANUP', $case[title])) {
                    if ($case[status] == "PASSED") {
                        $passed++;
                    } elseif ($case[status] == "RUNNING") {
                        $running++;
                    } else {
                        $failed++;
                    }
                }
                if (!$SC_TIMES[$case[script]][used]) {
                    $buildDataArr[$release][builds][$versionID][cases][$caseID][time] += $SC_TIMES[$case[script]][time];
                    $SC_TIMES[$case[script]][used] = 1;
                }
                $time_release += $buildDataArr[$release][builds][$versionID][cases][$caseID][time];
            }
            $total = $passed + $failed;
            if ($total != 0) {
                $buildDataArr[$release][builds][$versionID][total] = $total;
                $buildDataArr[$release][builds][$versionID][passed] = $passed;
                $buildDataArr[$release][builds][$versionID][running] = $running;
                $buildDataArr[$release][builds][$versionID][failed] = $failed;
                $buildDataArr[$release][builds][$versionID][status] = getPassFailStatus($failed, $buildDataArr[$release][builds][$versionID][runstatus]);
            }
        }
        //end build
        $buildDataArr[$release][time] = Sec2Time($time_release);
    }
    //end release
    mysql_close($linkID);
    insertPhaseToDB($buildDataArr, $tableQuery);
    return $buildDataArr;
}