X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=rantest%2Fweb%2Fphp%2FRantestDB.php;fp=rantest%2Fweb%2Fphp%2FRantestDB.php;h=3a0f54822efb3cb76faab6cd5de7a9b1c12b4897;hb=8ec853edfd2e5666d8e76fb58bb95da7b4ccfbf6;hp=0000000000000000000000000000000000000000;hpb=b1f5fe3b3f099b5d0ffbf406dd4bee2c35522813;p=clearscm.git diff --git a/rantest/web/php/RantestDB.php b/rantest/web/php/RantestDB.php new file mode 100644 index 0000000..3a0f548 --- /dev/null +++ b/rantest/web/php/RantestDB.php @@ -0,0 +1,1013 @@ +N/A"; + +$failureTypes = array ( + "Aborted", + "Exit", + "Incomplete", + "Other", + "p2pDataVal", + "Parsing", + "Timed out", + "valMsgs.pl" +); + +$nonFailures = array ( + "Success", + "In progress", + "Logging started" +); + +$testTypes = array ( + "All", + "Normal", + "Regression", + "Run for Record" +); + +function dbError ($msg, $statement) { + $errno = mysql_errno (); + $errmsg = mysql_error (); + + print <<ERROR: $msg +Error #$errno:
+
$errmsg
+SQL Statement:
+
$statement
+END; + + exit ($errno); +} // dbError + +function openDB () { + global $dbserver; + global $userid; + global $password; + global $dbname; + + $db = mysql_connect ($dbserver, $userid, $password) + or dbError (__FUNCTION__ . ": Unable to connect to database server $dbserver", "Connect"); + + mysql_select_db ($dbname) + or dbError (__FUNCTION__ . ": Unable to select the $dbname database", "$dbname"); +} // openDB + +function getDays () { + $days = array (); + + $statement = "select start from testrun group by left (start, 10) order by start desc"; + + $result = mysql_query ($statement) + or dbError (__FUNCTION__ . ": Unable to execute query: ", $statement); + + while ($row = mysql_fetch_array ($result)) { + array_push ($days, YMD2MDY ($row["start"])); + } // while + + return $days; +} // getDays + +function setRowColor ($result) { + if ($result == "Success") { + return " class=success"; + } elseif ($result == "Failure") { + return " class=failure"; + } elseif ($result == "Timed out") { + return " class=timed_out"; + } elseif ($result == "In progress" || + $result == "Logging started") { + return " class=in_progress"; + } else { + return " class=white"; + } // if +} // setRowColor + +function colorResult ($result) { + if ($result == "Success") { + return "$result"; + } elseif ($result == "Failure") { + return "$result"; + } else { + return $result; + } // if +} // colorResult + +function sortPassed ($a, $b) { + global $direction; + + return cmpNbr ($a, $b, "Passed", $direction); +} // sortPassed + +function sortFailed ($a, $b) { + global $direction; + + return cmpNbr ($a, $b, "Failed", $direction); +} // sortFailed + +function sortSuccess ($a, $b) { + global $direction; + + return cmpNbr ($a, $b, "Success", $direction); +} // sortSuccess + +function sortFailure ($a, $b) { + global $direction; + + return cmpNbr ($a, $b, "Failure", $direction); +} // sortFailure + +function sortTotal ($a, $b) { + global $direction; + + return cmpNbr ($a, $b, "Total", $direction); +} // sortTotal + +function sortSuite ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "Suite", $direction); +} // sortSuite + +function sortStart ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "Start", $direction); +} // sortStart + +function sortDate ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "Start", $direction); +} // sortDate + +function sortEnd ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "End", $direction); +} // sortEnd + +function sortTestcase ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "Testcase", $direction); +} // sortTestcase + +function sortType ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "Type", $direction); +} // sortType + +function sortUnitVersion ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "Unit/Version", $direction); +} // sortUnitVersion + +function sortUnit ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "Unit", $direction); +} // sortUnit + +function sortStatus ($a, $b) { + global $direction; + + return cmpStr ($a, $b, "Status", $direction); +} // sortStatus + +function sortDuration ($a, $b) { + global $direction; + + return cmpNbr ($a, $b, "Duration", $direction); +} // sortDuration + +function getName ($table, $id) { + $statement = "select name from $table where id=$id"; + + $result = mysql_query ($statement) + or dbError (__FUNCTION__ . ": Unable to execute query: ", $statement); + + $row = mysql_fetch_array ($result); + + return $row["name"]; +} // getName + +function getTestNames () { + $statement = "select name from test order by name"; + + $result = mysql_query ($statement) + or dbError (__FUNCTION__ . ": Unable to execute query: ", $statement); + + $names = array ("<All Tests>"); + + while ($row = mysql_fetch_array ($result)) { + array_push ($names, $row["name"]); + } // while + + return $names; +} // getTestNames + +function getBuildNbr ($runid) { + global $na; + + $statement = "select name from version where type=\"ran_version\" and runid=$runid"; + + $result = mysql_query ($statement) + or dbError (__FUNCTION__ . ": Unable to execute query: ", $statement); + + $row = mysql_fetch_array ($result); + + if (isset ($row["name"])) { + $buildNbr = preg_replace ("/.*\-(\w+)/", "$1", $row["name"]); + return $buildNbr; + } else { + return $na; + } // if +} // getBuildNbr + +function getVersion ($type, $runid) { + global $na; + + $statement = "select name from version where type=\"$type\" and runid=$runid"; + + $result = mysql_query ($statement) + or dbError (__FUNCTION__ . ": Unable to execute query: ", $statement); + + $row = mysql_fetch_array ($result); + + if (isset ($row["name"])) { + return $row["name"]; + } else { + return $na; + } // if +} // getVersion + +function getVersions ($type) { + $statement = "select name from version where type=\"$type\" group by name"; + + $result = mysql_query ($statement) + or dbError (__FUNCTION__ . ": Unable to execute query: ", $statement); + +// $names = array ("<All Versions>"); + $names = array (); + + while ($row = mysql_fetch_array ($result)) { + array_push ($names, $row["name"]); + } // while + + return $names; +} // getVersions + +function getTestVersions ($testcase) { + if (isset ($testcase)) { + $testcase = preg_replace ("/\*/", "%", $testcase); + $condition = "and test.name like \"$testcase\""; + } else { + $condition = ""; + } // if + + $statement = <<"; + + if (count ($days) < 2) { + $day = $days[0]; + } elseif (!isset ($day)) { + $day = date ("m/d/Y"); + } // if + + foreach ($days as $d) { + $dateDropdown .= ""; + } // if + } else { + if ($forEmail) { + return "No"; + } else { + return ""; + return $na; + } // if + } // if +} # logs + +function getStatus ($startDate, $endDate, $type = "") { + $dateCond = ""; + + if (isset ($startDate)) { + $startDate = MDY2YMD ($startDate); + } // if + + if (isset ($endDate)) { + $endDate = MDY2YMD ($endDate); + } // if + + if (isset ($startDate) and isset ($endDate)) { + $dateCond = "and left (testrun.start, 10) >= \"$startDate\" " . + "and left (testruns.end, 10) <= \"$endDate\"" ; + } elseif ($startDate) { + $dateCond = "and left (testrun.start, 10) >= \"$startDate\""; + } elseif ($endDate) { + $dateCond = "and left (testruns.end, 10) <= \"$endDate\""; + } # if + + $exectypeCond = ""; + + if ($type != "" and $type != "All") { + $exectypeCond = "and testruns.exectype = \"$type\""; + } // if + + $statement = << $value) { + $data["Date"] = $key; + $data["Success"] = $value["Success"]; + $data["Failure"] = $value["Failure"]; + $data["Total"] = $value["Total"]; + + array_push ($stats, $data); + } // foreach + + return $stats; +} // getStatus + +function getStepFailures ($runid) { + global $failureTypes, $nonFailures; + + $statement = <<") { + unset ($version); + } // if + + if (isset ($version)) { + $condition = "and version.name = \"$version\""; + } else { + $condition = ""; + } // if + + $statement = <<