| <?php |
| /////////////////////////////////////////////////////////////////////////////// |
| // bugs_test.php // |
| // // |
| // Generates test data for the bugs table inside bugs database... // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_bugs_rw.class.php"; |
| require_once "utils.php"; |
| |
| #Connection to Eclipse Database |
| $db_connection = new DBConnectionBugs(); |
| $db_handle = $db_connection->connect(); |
| |
| #Read groups.txt File |
| $testFile = "groups.txt"; |
| $fileObject = fopen($testFile,'r'); |
| |
| #Clean the table for fresh data |
| $deleteData = mysql_query("DELETE FROM `bugs`",$db_handle); |
| |
| #Set seeds for Randoms |
| mt_srand((double)microtime()*1000000); |
| |
| #Get all the projects avaiable |
| $test_products_array = array(); |
| while (!feof($fileObject)){ |
| $line=fgets($fileObject); |
| $firstChar = substr($line,0,1); |
| if($firstChar<>"#"){ |
| $separatedLine = explode("|",$line); |
| array_push($test_products_array,$separatedLine[0]); |
| } |
| } |
| |
| #Table Feed begins... |
| for($index_date = 181;$index_date>0;$index_date--){ |
| $bugs_per_day = mt_rand(3,20); |
| $test_create_date = getDateBefore($index_date); |
| $test_create_date = substr($test_create_date,0,4)."-".substr($test_create_date,4,2)."-".substr($test_create_date,6,2); |
| $test_hour = 0; |
| $test_minute = 0; |
| $test_second = 0; |
| for($day=0;$day<=$bugs_per_day;$day++){ |
| $test_hour = mt_rand($test_hour,23); |
| $test_minute = mt_rand($test_minute,59); |
| $test_second = mt_rand($test_second,59); |
| $test_create_time = $test_hour.":".$test_minute.":".$test_second; |
| $test_create_stamp = $test_create_date." ".$test_create_time; |
| |
| $test_product = sizeof($test_products_array)-1; |
| $test_product = mt_rand(1,$test_product); |
| |
| $test_priority = mt_rand(1,5); |
| $test_priority = "P".$test_priority; |
| |
| $test_status = mt_rand(1,7); |
| if($test_status==1){ |
| $test_status = "RESOLVED"; |
| }else if($test_status==2){ |
| $test_status = "VERIFIED"; |
| }else if($test_status==3){ |
| $test_status = "CLOSED"; |
| }else if($test_status==4){ |
| $test_status = "UNCONFIRMED"; |
| }else if($test_status==5){ |
| $test_status = "NEW"; |
| }else if($test_status==6){ |
| $test_status = "ASSIGNED"; |
| }else if($test_status==7){ |
| $test_status = "REOPENED"; |
| } |
| |
| $test_severity = mt_rand(1,7); |
| if($test_severity==1){ |
| $test_severity = "critical"; |
| }else if($test_severity==2){ |
| $test_severity = "blocker"; |
| }else if($test_severity==3){ |
| $test_severity = "major"; |
| }else if($test_severity==4){ |
| $test_severity = "normal"; |
| }else if($test_severity==5){ |
| $test_severity = "minor"; |
| }else if($test_severity==6){ |
| $test_severity = "trivial"; |
| }else if($test_severity==7){ |
| $test_severity = "enchancement"; |
| } |
| |
| $create_bug = mysql_query("INSERT INTO `bugs` ( `product_id` , `bug_status` , `priority` , `creation_ts` , `bug_severity` , `reporter`,`assigned_to`)VALUES ($test_product, '$test_status', '$test_priority', '$test_create_stamp', '$test_severity',1,2);", $db_handle)or die("MySQL Error: ".mysql_error()); |
| } |
| } |
| |
| $db_handle = null; |
| $db_connection = null; |
| ?> |