Best Phoronix-test-suite code snippet using phoromatic_sched
phoromatic_sched.php
Source:phoromatic_sched.php
...14 GNU General Public License for more details.15 You should have received a copy of the GNU General Public License16 along with this program. If not, see <http://www.gnu.org/licenses/>.17*/18class phoromatic_sched implements pts_webui_interface19{20 public static function page_title()21 {22 return 'Test Scheduling';23 }24 public static function page_header()25 {26 return null;27 }28 public static function preload($PAGE)29 {30 return true;31 }32 public static function render_page_process($PATH)33 {34 if(PHOROMATIC_USER_IS_VIEWER)35 return;36 $is_new = true;37 if(!empty($PATH[0]) && is_numeric($PATH[0]))38 {39 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND ScheduleID = :schedule_id');40 $stmt->bindValue(':account_id', $_SESSION['AccountID']);41 $stmt->bindValue(':schedule_id', $PATH[0]);42 $result = $stmt->execute();43 $e_schedule = $result->fetchArray();44 if(!empty($e_schedule))45 {46 $is_new = false;47 }48 }49 if(isset($_POST['schedule_title']) && !empty($_POST['schedule_title']))50 {51 $title = phoromatic_get_posted_var('schedule_title');52 $description = phoromatic_get_posted_var('schedule_description');53 $pre_install_context = phoromatic_get_posted_var('pre_install_set_context');54 $post_install_context = phoromatic_get_posted_var('post_install_set_context');55 $pre_run_context = phoromatic_get_posted_var('pre_run_set_context');56 $post_run_context = phoromatic_get_posted_var('post_run_set_context');57 $system_all = phoromatic_get_posted_var('system_all');58 $run_target_systems = phoromatic_get_posted_var('run_on_systems', array());59 $run_target_groups = phoromatic_get_posted_var('run_on_groups', array());60 if(!is_array($run_target_systems)) $run_target_systems = array();61 if(!is_array($run_target_groups)) $run_target_groups = array();62 $run_target_systems = implode(',', $run_target_systems);63 $run_target_groups = implode(',', $run_target_groups);64 $schedule_hour = phoromatic_get_posted_var('schedule_hour');65 $schedule_minute = phoromatic_get_posted_var('schedule_minute');66 $days_active = phoromatic_get_posted_var('days_active');67 $context_files = array('SetContextPreInstall' => 'pre_install_set_context', 'SetContextPostInstall' => 'post_install_set_context', 'SetContextPreRun' => 'pre_run_set_context', 'SetContextPostRun' => 'post_run_set_context');68 foreach($context_files as $i => $context)69 $$context = $is_new ? null : $e_schedule[$i];70 foreach($context_files as $context)71 {72 $$context = null;73 if($_FILES[$context]['error'] == 0 && $_FILES[$context]['size'] > 0)74 {75 $sha1_hash = sha1_file($_FILES[$context]['tmp_name']);76 if(!is_file(phoromatic_server::phoromatic_account_path($_SESSION['AccountID']) . 'context_' . $sha1_hash))77 {78 move_uploaded_file($_FILES[$context]['tmp_name'], phoromatic_server::phoromatic_account_path($_SESSION['AccountID']) . 'context_' . $sha1_hash);79 }80 $$context = $sha1_hash;81 }82 }83 // TODO XXX: Validation of input84 // Need a unique schedule ID85 if($is_new)86 {87 do88 {89 $schedule_id = rand(10, 9999);90 $matching_schedules = phoromatic_server::$db->querySingle('SELECT ScheduleID FROM phoromatic_schedules WHERE AccountID = \'' . $_SESSION['AccountID'] . '\' AND ScheduleID = \'' . $schedule_id . '\'');91 }92 while(!empty($matching_schedules));93 // Need a unique public ID94 do95 {96 $public_key = pts_strings::random_characters(12, true);;97 $matching_schedules = phoromatic_server::$db->querySingle('SELECT ScheduleID FROM phoromatic_schedules WHERE AccountID = \'' . $_SESSION['AccountID'] . '\' AND PublicKey = \'' . $public_key . '\'');98 }99 while(!empty($matching_schedules));100 }101 else102 {103 $schedule_id = $e_schedule['ScheduleID'];104 $public_key = $e_schedule['PublicKey'];105 }106 // Add schedule107 $stmt = phoromatic_server::$db->prepare('INSERT OR REPLACE INTO phoromatic_schedules (AccountID, ScheduleID, Title, Description, State, ActiveOn, RunAt, SetContextPreInstall, SetContextPostInstall, SetContextPreRun, SetContextPostRun, LastModifiedBy, LastModifiedOn, PublicKey, RunTargetGroups, RunTargetSystems) VALUES (:account_id, :schedule_id, :title, :description, :state, :active_on, :run_at, :context_pre_install, :context_post_install, :context_pre_run, :context_post_run, :modified_by, :modified_on, :public_key, :run_target_groups, :run_target_systems)');108 $stmt->bindValue(':account_id', $_SESSION['AccountID']);109 $stmt->bindValue(':schedule_id', $schedule_id);110 $stmt->bindValue(':title', $title);111 $stmt->bindValue(':description', $description);112 $stmt->bindValue(':state', 1);113 $stmt->bindValue(':active_on', implode(',', $days_active));114 $stmt->bindValue(':run_at', $schedule_hour . '.' . $schedule_minute);115 $stmt->bindValue(':context_pre_install', $pre_install_set_context);116 $stmt->bindValue(':context_post_install', $post_install_set_context);117 $stmt->bindValue(':context_pre_run', $pre_run_set_context);118 $stmt->bindValue(':context_post_run', $post_run_set_context);119 $stmt->bindValue(':modified_by', $_SESSION['UserName']);120 $stmt->bindValue(':modified_on', phoromatic_server::current_time());121 $stmt->bindValue(':public_key', $public_key);122 $stmt->bindValue(':run_target_groups', $run_target_groups);123 $stmt->bindValue(':run_target_systems', $run_target_systems);124 $result = $stmt->execute();125 phoromatic_add_activity_stream_event('schedule', $schedule_id, ($is_new ? 'added' : 'modified'));126 if($result)127 {128 header('Location: ?schedules/' . $schedule_id);129 }130 }131 echo phoromatic_webui_header_logged_in();132 $main = '<h2>' . ($is_new ? 'Create' : 'Edit') . ' A Schedule</h2>133 <p>A test schedule is used to facilitate automatically running a set of test(s)/suite(s) on either a routine timed basis or whenever triggered by an external script or process, e.g. Git/VCS commit, manually triggered, etc.</p>';134 $main .= '<form action="' . $_SERVER['REQUEST_URI'] . '" name="add_test" id="add_test" method="post" enctype="multipart/form-data" onsubmit="return validate_schedule();">135 <h3>Title:<span style="color:red;">*</span></h3>136 <p><input type="text" name="schedule_title" value="' . (!$is_new ? $e_schedule['Title'] : null) . '" /></p>137 <h3>Pre-Install Set Context Script: <span style="font-size:12px;">(optional)</span></h3>138 <p><input type="file" name="pre_install_set_context" /></p>139 <h3>Post-Install Set Context Script: <span style="font-size:12px;">(optional)</span></h3>140 <p><input type="file" name="post_install_set_context" /></p>141 <h3>Pre-Run Set Context Script: <span style="font-size:12px;">(optional)</span></h3>142 <p><input type="file" name="pre_run_set_context" /></p>143 <h3>Post-Run Set Context Script: <span style="font-size:12px;">(optional)</span></h3>144 <p><input type="file" name="post_run_set_context" /></p>145 <h3>System Targets:</h3>146 <p>';147 $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY Title ASC');148 $stmt->bindValue(':account_id', $_SESSION['AccountID']);149 $result = $stmt->execute();150 if(!$is_new)151 {152 $e_schedule['RunTargetSystems'] = explode(',', $e_schedule['RunTargetSystems']);153 $e_schedule['RunTargetGroups'] = explode(',', $e_schedule['RunTargetGroups']);154 }155 if($row = $result->fetchArray())156 {157 $main .= '<h4>Systems: ';158 do159 {160 $main .= '<input type="checkbox" name="run_on_systems[]" value="' . $row['SystemID'] . '" ' . (!$is_new && in_array($row['SystemID'], $e_schedule['RunTargetSystems']) ? 'checked="checked" ' : null) . '/> ' . $row['Title'] . ' ';161 }162 while($row = $result->fetchArray());163 $main .= '</h4>';164 }165 $stmt = phoromatic_server::$db->prepare('SELECT GroupName FROM phoromatic_groups WHERE AccountID = :account_id ORDER BY GroupName ASC');166 $stmt->bindValue(':account_id', $_SESSION['AccountID']);167 $result = $stmt->execute();168 if($row = $result->fetchArray())169 {170 $main .= '<h4>Groups: ';171 do172 {173 $main .= '<input type="checkbox" name="run_on_groups[]" value="' . $row['GroupName'] . '" ' . (!$is_new && in_array($row['GroupName'], $e_schedule['RunTargetGroups']) ? 'checked="checked" ' : null) . '/> ' . $row['GroupName'] . ' ';174 }175 while($row = $result->fetchArray());176 $main .= '</h4>';177 }178 $main .= '</p>179 <h3>Description:<span style="color:red;">*</span></h3>180 <p><textarea name="schedule_description" id="schedule_description" cols="50" rows="3">' . (!$is_new ? $e_schedule['Description'] : null) . '</textarea></p>181 <table class="pts_phoromatic_schedule_type">182<tr>183 <td><h3>Time-Based Testing</h3><em>Time-based testing allows tests to automatically commence at a given time on a defined cycle each day/week. This option is primarly aimed for those wishing to run a set of benchmarks every morning or night or at another defined period.</em></td>184 <td><h3>Run Time:</h3>185 <p><select name="schedule_hour" id="schedule_hour">';186 if(!$is_new)187 {188 $run_at = explode('.', $e_schedule['RunAt']);189 $days_active = !empty($e_schedule['ActiveOn']) ? explode(',', $e_schedule['ActiveOn']) : array();190 }191 for($i = 0; $i <= 23; $i++)192 {193 $i_f = (strlen($i) == 1 ? '0' . $i : $i);194 $main .= '<option value="' . $i_f . '"' . (!$is_new && $run_at[0] == $i ? 'selected="selected" ' : null) . '>' . $i_f . '</option>';195 }...
phoromatic_sched
Using AI Code Generation
1include_once('phoromatic_sched.php');2$sched = new Phoromatic_sched();3$sched->run();4include_once('phoromatic_sched.php');5$sched = new Phoromatic_sched();6$sched->run();7include_once('phoromatic_sched.php');8$sched = new Phoromatic_sched();9$sched->run();10include_once('phoromatic_sched.php');11$sched = new Phoromatic_sched();12$sched->run();13include_once('phoromatic_sched.php');14$sched = new Phoromatic_sched();15$sched->run();16include_once('phoromatic_sched.php');17$sched = new Phoromatic_sched();18$sched->run();19include_once('phoromatic_sched.php');20$sched = new Phoromatic_sched();21$sched->run();22include_once('phoromatic_sched.php');23$sched = new Phoromatic_sched();24$sched->run();25include_once('phoromatic_sched.php');26$sched = new Phoromatic_sched();27$sched->run();28include_once('phoromatic_sched.php');29$sched = new Phoromatic_sched();30$sched->run();31include_once('phoromatic_sched.php');32$sched = new Phoromatic_sched();33$sched->run();
phoromatic_sched
Using AI Code Generation
1include 'phoromatic_sched.php';2$phoromatic_sched = new phoromatic_sched();3$test_name = $_GET['test_name'];4$test_args = $_GET['test_args'];5$test_profile = $_GET['test_profile'];6$test_identifier = $_GET['test_identifier'];7$test_id = $_GET['test_id'];8$test_date = $_GET['test_date'];9$test_time = $_GET['test_time'];10$test_duration = $_GET['test_duration'];11$test_result = $_GET['test_result'];
phoromatic_sched
Using AI Code Generation
1$phoromatic = new phoromatic_sched();2$phoromatic->set_sched_id(2);3$phoromatic->set_sched_name("2nd schedule");4$phoromatic->set_sched_desc("2nd schedule description");5$phoromatic->set_sched_active(1);6$phoromatic->set_sched_type("standard");7$phoromatic->set_sched_time("2013-11-17 00:00:00");8$phoromatic->set_sched_interval(1);9$phoromatic->set_sched_interval_type("day");10$phoromatic->set_sched_repeat(1);11$phoromatic->set_sched_repeat_type("week");12$phoromatic->set_sched_repeat_on("0,1,2,3,4,5,6");13$phoromatic->set_sched_test("Phoronix-Test-Suite");14$phoromatic->set_sched_test_args("install pts/pts-2.2.0");15$phoromatic->set_sched_test_args("run pts/pts-2.2.0");16$phoromatic->set_sched_test_args("install pts/pts-2.3.0");17$phoromatic->set_sched_test_args("run pts/pts-2.3.0");18$phoromatic->add_sched();19$phoromatic = new phoromatic_sched();20$phoromatic->set_sched_id(3);21$phoromatic->set_sched_name("3rd schedule");22$phoromatic->set_sched_desc("3rd schedule description");23$phoromatic->set_sched_active(1);24$phoromatic->set_sched_type("standard");25$phoromatic->set_sched_time("2013-11-17 00:00:00");26$phoromatic->set_sched_interval(1);27$phoromatic->set_sched_interval_type("day");28$phoromatic->set_sched_repeat(1);29$phoromatic->set_sched_repeat_type("week");30$phoromatic->set_sched_repeat_on("0,1,2,3,4,5,6");31$phoromatic->set_sched_test("Phoronix-Test-Suite");32$phoromatic->set_sched_test_args("install pts/pts-2.2.0");
phoromatic_sched
Using AI Code Generation
1require_once 'phoromatic_sched.php';2$phoromatic_sched = new phoromatic_sched();3$phoromatic_sched->phoromatic_sched('2.php');4$phoromatic_sched->phoromatic_sched('3.php');5$phoromatic_sched->phoromatic_sched('4.php');6$phoromatic_sched->phoromatic_sched('5.php');7$phoromatic_sched->phoromatic_sched('6.php');8$phoromatic_sched->phoromatic_sched('7.php');9$phoromatic_sched->phoromatic_sched('8.php');10$phoromatic_sched->phoromatic_sched('9.php');11$phoromatic_sched->phoromatic_sched('10.php');12$phoromatic_sched->phoromatic_sched('11.php');13$phoromatic_sched->phoromatic_sched('12.php');14$phoromatic_sched->phoromatic_sched('13.php');15$phoromatic_sched->phoromatic_sched('14.php');16$phoromatic_sched->phoromatic_sched('15.php');17$phoromatic_sched->phoromatic_sched('16.php');18$phoromatic_sched->phoromatic_sched('17.php');19$phoromatic_sched->phoromatic_sched('18.php');20$phoromatic_sched->phoromatic_sched('19.php');21$phoromatic_sched->phoromatic_sched('20.php');22$phoromatic_sched->phoromatic_sched('21.php');23$phoromatic_sched->phoromatic_sched('22.php');24$phoromatic_sched->phoromatic_sched('23.php');25$phoromatic_sched->phoromatic_sched('24.php');26$phoromatic_sched->phoromatic_sched('25.php');27$phoromatic_sched->phoromatic_sched('26.php');28$phoromatic_sched->phoromatic_sched('27.php');29$phoromatic_sched->phoromatic_sched('28.php');30$phoromatic_sched->phoromatic_sched('29.php');31$phoromatic_sched->phoromatic_sched('30.php');32$phoromatic_sched->phoromatic_sched('31.php');33$phoromatic_sched->phoromatic_sched('32.php');34$phoromatic_sched->phoromatic_sched('33.php');35$phoromatic_sched->phoromatic_sched('34.php');
phoromatic_sched
Using AI Code Generation
1require_once('phoromatic_sched.php');2require_once('phoromatic_results.php');3$tests = Phoromatic_Sched::GetAvailableTests();4print_r($tests);5$test = 'pts/graphics-2';6$system_id = '1';7$test_result = 'PASS';8$test_time = '2012-11-15 12:00:00';9$test_duration = '100';10$test_arguments = 'test';11$test_log = 'test log';12$test_description = 'test description';13$test_file = 'test file';14Phoromatic_Sched::SubmitTestResult($test, $system_id, $test_result, $test_time, $test_duration, $test_arguments, $test_log, $test_description, $test_file);15$tests = Phoromatic_Sched::GetScheduledTests();16print_r($tests);17Phoromatic_Sched::DeleteScheduledTest($test);18$tests = Phoromatic_Results::GetResults();19print_r($tests);20$tests = Phoromatic_Results::GetResult($test);21print_r($tests);22Phoromatic_Results::DeleteResult($test);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.
Test now for FreeGet 100 minutes of automation test minutes FREE!!