How to use update_system_status method of phoromatic class

Best Phoronix-test-suite code snippet using phoromatic.update_system_status

phoromatic.php

Source:phoromatic.php Github

copy

Full Screen

...255 $to_post['n'] = phodevi::read_property('system', 'hostname');256 $to_post['msi'] = PTS_MACHINE_SELF_ID;257 return pts_network::http_upload_via_post('http://' . $server_address . ':' . $server_http_port . '/phoromatic.php', $to_post, false);258 }259 protected static function update_system_status($current_task, $estimated_time_remaining = 0, $percent_complete = 0, $for_schedule = null, $estimate_to_next_comm = 0)260 {261 static $last_msg = null;262 // Avoid an endless flow of "idling" messages, etc263 if($current_task != $last_msg)264 pts_client::$pts_logger && pts_client::$pts_logger->log($current_task);265 $last_msg = $current_task;266 if(self::$limit_network_communication)267 {268 static $last_comm_time = 0;269 if(time() > ($last_comm_time + 800 + rand(0, 180)))270 {271 // It's been at least half hour since last update, so report in state...272 $last_comm_time = time();273 }274 else275 {276 return;277 }278 }279 return phoromatic::upload_to_remote_server(array(280 'r' => 'update_system_status',281 'a' => $current_task,282 'time' => $estimated_time_remaining,283 'pc' => $percent_complete,284 'sched' => (!empty($for_schedule) ? $for_schedule : self::$p_schedule_id),285 'bid' => (!empty(self::$benchmark_ticket_id) ? self::$benchmark_ticket_id : 0),286 'o' => $estimate_to_next_comm287 ));288 }289 public static function startup_ping_check($server_ip, $http_port)290 {291 $server_response = phoromatic::upload_to_remote_server(array(292 'r' => 'ping',293 ), $server_ip, $http_port);294 }295 protected static function setup_server_addressing($server_string = null)296 {297 self::$has_run_server_setup_func = true;298 if(isset($server_string[0]) && strpos($server_string[0], '/', strpos($server_string[0], ':')) > 6)299 {300 pts_client::$pts_logger && pts_client::$pts_logger->log('Attempting to connect to Phoromatic Server: ' . $server_string[0]);301 self::$account_id = substr($server_string[0], strrpos($server_string[0], '/') + 1);302 self::$server_address = substr($server_string[0], 0, strpos($server_string[0], ':'));303 self::$server_http_port = substr($server_string[0], strlen(self::$server_address) + 1, -1 - strlen(self::$account_id));304 pts_client::$display->generic_heading('Server IP: ' . self::$server_address . PHP_EOL . 'Server HTTP Port: ' . self::$server_http_port . PHP_EOL . 'Account ID: ' . self::$account_id);305 pts_client::register_phoromatic_server(self::$server_address, self::$server_http_port);306 }307 else if(($last_server = trim(pts_module::read_file('last-phoromatic-server'))) && !empty($last_server))308 {309 pts_client::$pts_logger && pts_client::$pts_logger->log('Attempting to connect to last server connection: ' . $last_server);310 $last_account_id = substr($last_server, strrpos($last_server, '/') + 1);311 $last_server_address = substr($last_server, 0, strpos($last_server, ':'));312 $last_server_http_port = substr($last_server, strlen($last_server_address) + 1, -1 - strlen($last_account_id));313 pts_client::$pts_logger && pts_client::$pts_logger->log('Last Server IP: ' . $last_server_address . ' Last Server HTTP Port: ' . $last_server_http_port . ' Last Account ID: ' . $last_account_id);314 for($i = 0; $i < 10; $i++)315 {316 $server_response = phoromatic::upload_to_remote_server(array(317 'r' => 'ping',318 ), $last_server_address, $last_server_http_port, $last_account_id);319 $server_response = json_decode($server_response, true);320 if($server_response && isset($server_response['phoromatic']['ping']))321 {322 self::$server_address = $last_server_address;323 self::$server_http_port = $last_server_http_port;324 self::$account_id = $last_account_id;325 pts_client::$pts_logger && pts_client::$pts_logger->log('Phoromatic Server connection restored');326 pts_client::register_phoromatic_server(self::$server_address, self::$server_http_port);327 break;328 }329 else330 {331 pts_client::$pts_logger && pts_client::$pts_logger->log('Phoromatic Server connection failed');332 sleep((12 * ($i + 1)));333 }334 }335 }336 if(self::$server_address == null)337 {338 $archived_servers = pts_client::available_phoromatic_servers();339 if(!empty($archived_servers))340 {341 pts_client::$pts_logger && pts_client::$pts_logger->log('Attempting to auto-discover Phoromatic Servers');342 self::attempt_phoromatic_server_auto_discover($archived_servers);343 }344 }345 if(self::$server_address == null || self::$server_http_port == null || self::$account_id == null)346 {347 pts_client::$pts_logger && pts_client::$pts_logger->log('Phoromatic Server connection setup failed');348 echo PHP_EOL . 'You must pass the Phoromatic Server information as an argument to phoromatic.connect, or otherwise configure your network setup.' . PHP_EOL . ' e.g. phoronix-test-suite phoromatic.connect 192.168.1.2:5555/I0SSJY' . PHP_EOL . PHP_EOL;349 if(PTS_IS_DAEMONIZED_SERVER_PROCESS && !empty($archived_servers))350 {351 echo 'The Phoromatic client appears to be running as a system service/daemon so will attempt to continue auto-polling to find the Phoromatic Server.' . PHP_EOL . PHP_EOL;352 $success = false;353 do354 {355 pts_client::$pts_logger && pts_client::$pts_logger->log('Will auto-poll connected servers every 90 seconds looking for a claim by a Phoromatic Server');356 sleep(90);357 $success = self::attempt_phoromatic_server_auto_discover($archived_servers);358 }359 while($success == false);360 }361 else362 {363 return false;364 }365 }366 return true;367 }368 protected static function attempt_phoromatic_server_auto_discover(&$phoromatic_servers)369 {370 foreach($phoromatic_servers as &$archived_server)371 {372 pts_client::$pts_logger && pts_client::$pts_logger->log('Attempting to auto-discover Phoromatic Server on: ' . $archived_server['ip'] . ': ' . $archived_server['http_port']);373 $server_response = phoromatic::upload_to_remote_server(array(374 'r' => 'ping',375 ), $archived_server['ip'], $archived_server['http_port']);376 $server_response = json_decode($server_response, true);377 if($server_response && isset($server_response['phoromatic']['account_id']))378 {379 self::$server_address = $archived_server['ip'];380 self::$server_http_port = $archived_server['http_port'];381 self::$account_id = $server_response['phoromatic']['account_id'];382 return true;383 }384 }385 return false;386 }387 protected static function setup_system_environment()388 {389 if(is_writable('/boot/grub/grubenv') && pts_client::executable_in_path('grub-editenv'))390 {391 // In case system fails or reboots in process and don't want to hang on GRUB recordfail392 shell_exec('grub-editenv /boot/grub/grubenv unset recordfail 2>&1');393 }394 }395 public static function run_connection($args)396 {397 if(pts_client::create_lock(PTS_USER_PATH . 'phoromatic_lock') == false)398 {399 trigger_error('Phoromatic is already running.', E_USER_ERROR);400 return false;401 }402 define('PHOROMATIC_PROCESS', true);403 if(pts_client::$pts_logger == false)404 {405 pts_client::$pts_logger = new pts_logger();406 }407 pts_client::$pts_logger->log(pts_core::program_title(true) . ' [' . PTS_CORE_VERSION . '] starting Phoromatic client');408 if(phodevi::system_uptime() < 60)409 {410 echo 'PHOROMATIC: Sleeping for 60 seconds as system freshly started.' . PHP_EOL;411 pts_client::$pts_logger->log('Sleeping for 60 seconds as system freshly started');412 sleep(60);413 }414 $server_setup = self::setup_server_addressing($args);415 //$http_comm = new phoromatic_client_comm_http();416 /*417 if(!$server_setup)418 {419 if(getenv('PTS_NO_REBOOT_ON_NETWORK_FAILURE') == false && PTS_IS_DAEMONIZED_SERVER_PROCESS)420 {421 phodevi::reboot();422 }423 return false;424 }425 */426 $times_failed = 0;427 $has_success = false;428 $do_exit = false;429 $just_started = true;430 self::setup_system_environment();431 pts_client::$pts_logger->log('SYSTEM HARDWARE: ' . phodevi::system_hardware(true));432 pts_client::$pts_logger->log('SYSTEM SOFTWARE: ' . phodevi::system_software(true));433 while($do_exit == false)434 {435 $server_response = phoromatic::upload_to_remote_server(array(436 'r' => 'start',437 ));438 if($server_response == false)439 {440 $times_failed++;441 pts_client::$pts_logger->log('Server response failed');442 if($times_failed >= 2)443 {444 trigger_error('Communication with server failed.', E_USER_ERROR);445 if(PTS_IS_DAEMONIZED_SERVER_PROCESS == false && $times_failed > 5)446 {447 return false;448 }449 else if(PTS_IS_DAEMONIZED_SERVER_PROCESS && $times_failed > 10)450 {451 if(getenv('PTS_NO_REBOOT_ON_NETWORK_FAILURE') == false)452 {453 phodevi::reboot();454 }455 }456 }457 }458 else if(substr($server_response, 0, 1) == '[')459 {460 // Likely a notice/warning from server461 echo PHP_EOL . substr($server_response, 0, strpos($server_response, PHP_EOL)) . PHP_EOL;462 }463 else if(substr($server_response, 0, 1) == '{')464 {465 $times_failed = 0;466 $json = json_decode($server_response, true);467 if($has_success == false)468 {469 $has_success = true;470 pts_module::save_file('last-phoromatic-server', self::$server_address . ':' . self::$server_http_port . '/' . self::$account_id);471 }472 if($json != null)473 {474 if(isset($json['phoromatic']['error']) && !empty($json['phoromatic']['error']))475 {476 trigger_error($json['phoromatic']['error'], E_USER_ERROR);477 }478 if(isset($json['phoromatic']['response']) && !empty($json['phoromatic']['response']))479 {480 echo PHP_EOL . $json['phoromatic']['response'] . PHP_EOL;481 }482 }483 self::$limit_network_communication = isset($json['phoromatic']['settings']['LimitNetworkCommunication']) && pts_strings::string_bool($json['phoromatic']['settings']['LimitNetworkCommunication']);484 if(self::$limit_network_communication)485 {486 // Sleep to ensure network communication is somewhat random in case all systems started at same time487 sleep(0, 20);488 }489 if($just_started)490 {491 if(PTS_IS_DAEMONIZED_SERVER_PROCESS && !self::$limit_network_communication && function_exists('pcntl_fork'))492 {493 $pid = pcntl_fork();494 if($pid == 0)495 {496 // Start the tick thread497 self::tick_thread();498 }499 }500 $just_started = false;501 }502 pts_tests::clear_extra_env_vars();503 if(isset($json['phoromatic']['pre_set_sys_env_vars']) && !empty($json['phoromatic']['pre_set_sys_env_vars']))504 {505 // pre_set_sys_env_vars was added during PTS 5.8 development506 // Sets environment variables on client as specified via the Phoromatic Server's systems page507 foreach(explode(';', $json['phoromatic']['pre_set_sys_env_vars']) as $i => $v_string)508 {509 $var = explode('=', $v_string);510 if(count($var) == 2)511 {512 putenv($var[0] . '=' . $var[1]);513 pts_tests::add_extra_env_var($var[0], $var[1]);514 }515 }516 }517 switch(isset($json['phoromatic']['task']) ? $json['phoromatic']['task'] : null)518 {519 case 'install':520 phoromatic::update_system_status('Installing Tests');521 pts_test_suite::set_temporary_suite('pre-seed', $json['phoromatic']['test_suite']);522 pts_test_installer::standard_install('pre-seed', false, true);523 break;524 case 'benchmark':525 // Make sure all latest tests are available526 pts_openbenchmarking::refresh_repository_lists(null, true);527 $benchmark_timer = time();528 self::$is_running_as_phoromatic_node = true;529 $suite_identifier = sha1(time() . rand(2, 1000));530 pts_test_suite::set_temporary_suite($suite_identifier, $json['phoromatic']['test_suite']);531 self::$p_save_identifier = $json['phoromatic']['trigger_id'];532 $phoromatic_results_identifier = self::$p_save_identifier;533 $phoromatic_save_identifier = $json['phoromatic']['save_identifier'];534 self::$p_schedule_id = isset($json['phoromatic']['schedule_id']) ? $json['phoromatic']['schedule_id'] : false;535 self::$p_trigger_id = self::$p_save_identifier;536 $benchmark_ticket_id = isset($json['phoromatic']['benchmark_ticket_id']) ? $json['phoromatic']['benchmark_ticket_id'] : null;537 self::$benchmark_ticket_id = $benchmark_ticket_id;538 phoromatic::update_system_status('Running Benchmarks For: ' . $phoromatic_save_identifier);539 if(pts_strings::string_bool($json['phoromatic']['settings']['RunInstallCommand']))540 {541 if(isset($json['phoromatic']['pre_install_set_context']))542 {543 phoromatic::set_user_context($json['phoromatic']['pre_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_INSTALL');544 }545 pts_test_installer::standard_install($suite_identifier, pts_strings::string_bool($json['phoromatic']['settings']['ForceInstallTests']), true);546 if(isset($json['phoromatic']['post_install_set_context']))547 {548 phoromatic::set_user_context($json['phoromatic']['post_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_INSTALL');549 }550 }551 $env_vars = isset($json['phoromatic']['environment_variables']) ? pts_strings::parse_value_string_vars($json['phoromatic']['environment_variables']) : array();552 $is_stress_run = isset($env_vars['PTS_CONCURRENT_TEST_RUNS']) && $env_vars['PTS_CONCURRENT_TEST_RUNS'] > 1;553 // Do the actual running554 phodevi::clear_cache();555 if($is_stress_run)556 {557 self::$test_run_manager = new pts_stress_run_manager(array(558 'UploadResults' => false,559 'SaveResults' => false,560 'PromptForTestDescription' => false,561 'RunAllTestCombinations' => false,562 'PromptSaveName' => false,563 'PromptForTestIdentifier' => false,564 'OpenBrowser' => false565 ), true);566 if(self::$test_run_manager->initial_checks($suite_identifier, 'SHORT'))567 {568 if(self::$test_run_manager->load_tests_to_run($suite_identifier))569 {570 self::$test_run_manager->action_on_stress_log_set(array('phoromatic', 'upload_stress_log_sane'));571 self::$in_stress_mode = $phoromatic_save_identifier;572 self::$test_run_manager->multi_test_stress_run_execute($env_vars['PTS_CONCURRENT_TEST_RUNS'], $env_vars['TOTAL_LOOP_TIME']);573 self::$in_stress_mode = false;574 self::upload_stress_log(self::$test_run_manager->get_stress_log());575 }576 }577 self::$benchmark_ticket_id = null;578 break;579 }580 else581 {582 self::$test_run_manager = new pts_test_run_manager(array(583 'UploadResults' => (isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking'])),584 'SaveResults' => true,585 'RunAllTestCombinations' => false,586 'OpenBrowser' => false587 ), true);588 }589 if(self::$test_run_manager->initial_checks($suite_identifier, 'SHORT'))590 {591 // Load the tests to run592 if(self::$test_run_manager->load_tests_to_run($suite_identifier))593 {594 phoromatic::update_system_status('Tests In Run Queue: ' . implode(', ', self::$test_run_manager->get_tests_to_run_identifiers()));595 if(isset($json['phoromatic']['pre_run_set_context']))596 {597 phoromatic::set_user_context($json['phoromatic']['pre_run_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_RUN');598 }599 if(isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']))600 {601 self::$test_run_manager->auto_upload_to_openbenchmarking();602 pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs']));603 }604 // Save results?605 // Run the actual tests606 self::$test_run_manager->auto_save_results($phoromatic_save_identifier, $phoromatic_results_identifier, (isset($json['phoromatic']['test_description']) ? $json['phoromatic']['test_description'] : 'A Phoromatic run.'));607 self::$test_run_manager->pre_execution_process();608 self::$test_run_manager->call_test_runs();609 phoromatic::update_system_status('Benchmarks Completed For: ' . $phoromatic_save_identifier);610 self::$test_run_manager->post_execution_process();611 $elapsed_benchmark_time = time() - $benchmark_timer;612 // Handle uploading data to server613 $result_file = new pts_result_file(self::$test_run_manager->get_file_name());614 $upload_system_logs = pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs']);615 $server_response = self::upload_test_result($result_file, $upload_system_logs, (isset($json['phoromatic']['schedule_id']) ? $json['phoromatic']['schedule_id'] : null), $phoromatic_save_identifier, $json['phoromatic']['trigger_id'], $elapsed_benchmark_time, $benchmark_ticket_id);616 //pts_client::$pts_logger->log('DEBUG RESPONSE MESSAGE: ' . $server_response);617 if(!pts_strings::string_bool($json['phoromatic']['settings']['ArchiveResultsLocally']))618 {619 pts_client::remove_saved_result_file(self::$test_run_manager->get_file_name());620 }621 }622 if(isset($json['phoromatic']['post_run_set_context']))623 {624 phoromatic::set_user_context($json['phoromatic']['post_run_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_RUN');625 }626 }627 self::$p_schedule_id = null;628 self::$is_running_as_phoromatic_node = false;629 self::$benchmark_ticket_id = null;630 break;631 case 'reboot':632 echo PHP_EOL . 'Phoromatic received a remote command to reboot.' . PHP_EOL;633 phoromatic::update_system_status('Attempting System Reboot');634 phodevi::reboot();635 break;636 case 'shutdown-if-supports-wake':637 $supports_wol = false;638 foreach(pts_network::get_network_wol() as $net_device)639 {640 if(strpos($net_device, 'g') !== false)641 {642 $supports_wol = true;643 break;644 }645 }646 if(!$supports_wol)647 break;648 case 'shutdown':649 if(isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script']))650 {651 self::run_client_update_script($json['phoromatic']['client_update_script']);652 sleep(10);653 }654 echo PHP_EOL . 'Phoromatic received a remote command to shutdown.' . PHP_EOL;655 phoromatic::update_system_status('Attempting System Shutdown');656 phodevi::shutdown();657 break;658 case 'maintenance':659 echo PHP_EOL . 'Idling, system maintenance mode set by Phoromatic Server.' . PHP_EOL;660 phoromatic::update_system_status('Maintenance Mode' . self::check_for_separate_pts_thread_process());661 sleep(60);662 break;663 case 'idle':664 if(isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script']))665 {666 self::run_client_update_script($json['phoromatic']['client_update_script']);667 }668 //echo PHP_EOL . 'Idling, waiting for task.' . PHP_EOL;669 phoromatic::update_system_status('Idling, Waiting For Task' . self::check_for_separate_pts_thread_process());670 break;671 case 'exit':672 echo PHP_EOL . 'Phoromatic received a remote command to exit.' . PHP_EOL;673 phoromatic::update_system_status('Exiting Phoromatic');674 $do_exit = true;675 break;676 }677 }678 if(!$do_exit)679 {680 if($server_response == false)681 sleep(rand(10, 30));682 else if(self::$limit_network_communication)683 sleep(60, 240);684 else685 sleep(60);686 }687 }688 pts_client::release_lock(PTS_USER_PATH . 'phoromatic_lock');689 }690 private static function check_for_separate_pts_thread_process()691 {692 $report = null;693 $log_file = pts_logger::default_log_file_path() . 'phoronix-test-suite-benchmark.log';694 if(is_file($log_file) && filemtime($log_file) > (time() - 1200))695 {696 $log_file = pts_file_io::file_get_contents($log_file);697 $log_file = substr($log_file, strrpos($log_file, PHP_EOL) + 1);698 if(($x = strpos($log_file, ']')) !== false)699 {700 $log_file = substr($log_file, ($x + 1));701 }702 $report .= '; Separate Process: ' . trim($log_file);703 }704 return $report;705 }706 private static function upload_test_result(&$result_file, $upload_system_logs = true, $schedule_id = 0, $save_identifier = null, $trigger = null, $elapsed_time = 0, $benchmark_ticket_id = null)707 {708 $system_logs = null;709 $system_logs_hash = null;710 // TODO: Potentially integrate this code below shared with pts_openbenchmarking_client into a unified function for validating system log files711 $system_log_dir = PTS_SAVE_RESULTS_PATH . $result_file->get_identifier() . '/system-logs/';712 if(is_dir($system_log_dir) && $upload_system_logs)713 {714 $is_valid_log = true;715 $finfo = function_exists('finfo_open') ? finfo_open(FILEINFO_MIME_TYPE) : false;716 foreach(pts_file_io::glob($system_log_dir . '*') as $log_dir)717 {718 if($is_valid_log == false || !is_dir($log_dir))719 {720 $is_valid_log = false;721 break;722 }723 foreach(pts_file_io::glob($log_dir . '/*') as $log_file)724 {725 if(!is_file($log_file))726 {727 $is_valid_log = false;728 break;729 }730 if($finfo && substr(finfo_file($finfo, $log_file), 0, 5) != 'text/')731 {732 $is_valid_log = false;733 break;734 }735 }736 }737 if($is_valid_log)738 {739 $system_logs_zip = pts_client::create_temporary_file('.zip');740 pts_compression::zip_archive_create($system_logs_zip, $system_log_dir);741 if(filesize($system_logs_zip) == 0)742 {743 pts_client::$pts_logger && pts_client::$pts_logger->log('System log ZIP file failed to generate. Missing PHP ZIP support?');744 }745 else if(filesize($system_logs_zip) < 2097152)746 {747 // If it's over 2MB, probably too big748 $system_logs = base64_encode(file_get_contents($system_logs_zip));749 $system_logs_hash = sha1($system_logs);750 }751 else752 {753 // trigger_error('The systems log attachment is too large to upload to OpenBenchmarking.org.', E_USER_WARNING);754 }755 unlink($system_logs_zip);756 }757 }758 $composite_xml = $result_file->get_xml();759 $composite_xml_hash = sha1($composite_xml);760 $composite_xml_type = 'composite_xml';761 // Compress the result file XML if it's big762 if(isset($composite_xml[50000]) && function_exists('gzdeflate'))763 {764 $composite_xml_gz = gzdeflate($composite_xml);765 if($composite_xml_gz != false)766 {767 $composite_xml = $composite_xml_gz;768 $composite_xml_type = 'composite_xml_gz';769 }770 }771 // Upload to Phoromatic772 $times_tried = 0;773 do774 {775 if($times_tried > 0)776 {777 sleep(rand(5, 20));778 }779 $res = phoromatic::upload_to_remote_server(array(780 'r' => 'result_upload',781 //'ob' => $ob_data['id'],782 'sched' => $schedule_id,783 'bid' => $benchmark_ticket_id,784 'o' => $save_identifier,785 'ts' => $trigger,786 'et' => $elapsed_time,787 $composite_xml_type => base64_encode($composite_xml),788 'composite_xml_hash' => $composite_xml_hash,789 'system_logs_zip' => $system_logs,790 'system_logs_hash' => $system_logs_hash791 ));792 $times_tried++;793 }794 while($res == false && $times_tried < 4);795 return $res;796 }797 private static function upload_stress_log($stress_log)798 {799 // Upload Logs to Phoromatic800 if($stress_log == null || self::$benchmark_ticket_id == null)801 {802 return;803 }804 $times_tried = 0;805 do806 {807 if($times_tried > 0)808 {809 sleep(rand(5, 20));810 }811 $res = phoromatic::upload_to_remote_server(array(812 'r' => 'stress_log_upload',813 'bid' => self::$benchmark_ticket_id,814 'l' => pts_user_io::strip_ansi_escape_sequences($stress_log)815 ));816 $times_tried++;817 }818 while($res == false && $times_tried < 4);819 return $res;820 }821 public static function upload_stress_log_sane($stress_log)822 {823 static $last_log_upload = 0;824 if(time() > ($last_log_upload + 60))825 {826 self::upload_stress_log($stress_log);827 $last_log_upload = time();828 }829 }830 public static function recent_phoromatic_server_results()831 {832 self::setup_server_addressing();833 $server_response = phoromatic::upload_to_remote_server(array('r' => 'list_results'));834 $server_response = json_decode($server_response, true);835 if(isset($server_response['phoromatic']['results']) && !empty($server_response['phoromatic']['results']))836 {837 foreach($server_response['phoromatic']['results'] as $pprid => $result)838 {839 echo sprintf('%-26ls - %-25ls - %-30ls', $result['Title'], $pprid, date('j M H:i', strtotime($result['UploadTime']))) . PHP_EOL;840 echo sprintf(' %-20ls - %-25ls' . PHP_EOL, $result['SystemName'], $result['GroupName']) . PHP_EOL;841 }842 }843 else844 echo PHP_EOL . 'No Phoromatic Server results discovered.';845 echo PHP_EOL;846 }847 public static function clone_phoromatic_server_result($args)848 {849 self::setup_server_addressing();850 $id = $args[0];851 $server_response = phoromatic::upload_to_remote_server(array('r' => 'clone_result', 'i' => $id));852 $server_response = json_decode($server_response, true);853 if(isset($server_response['phoromatic']['result']['composite_xml']) && !empty($server_response['phoromatic']['result']['composite_xml']))854 {855 $composite_xml = base64_decode($server_response['phoromatic']['result']['composite_xml']);856 $result_file = new pts_result_file($composite_xml);857 // TODO XXX: Add system log downloading support858 pts_client::save_test_result($id . '/composite.xml', $result_file->get_xml(), true);859 echo PHP_EOL . 'Result File Saved As: ' . $id . PHP_EOL . PHP_EOL;860 }861 else862 echo PHP_EOL . 'No Phoromatic result found.' . PHP_EOL;863 }864 private static function run_client_update_script($update_script)865 {866 static $last_update_script_check_time = 0;867 // Don't keep checking it so check no more than every 20 minutes868 if($last_update_script_check_time < (time() - 1200) && !empty($update_script))869 {870 $last_update_script_check_time = time();871 $update_file = pts_client::create_temporary_file();872 $update_script = str_replace("\r", PHP_EOL, $update_script);873 file_put_contents($update_file, $update_script);874 phoromatic::update_system_status('Running Phoronix Test Suite Update Script');875 $env_vars = array();876 pts_client::shell_exec('bash ' . $update_file . ' 2>&1', $env_vars);877 }878 }879 private static function set_user_context($context_script, $trigger, $schedule_id, $process)880 {881 if(!empty($context_script))882 {883 $context_file = pts_client::create_temporary_file();884 file_put_contents($context_file, $context_script);885 chmod($context_file, 0755);886 pts_file_io::mkdir(pts_module::save_dir());887 $storage_path = pts_module::save_dir() . 'memory.pt2so';888 $storage_object = pts_storage_object::recover_from_file($storage_path);889 $notes_log_file = pts_module::save_dir() . sha1($trigger . $schedule_id . $process);890 // We check to see if the context was already set but the system rebooted or something in that script891 if($storage_object == false)892 {893 $storage_object = new pts_storage_object(true, true);894 }895 else if($storage_object->read_object('last_set_context_trigger') == $trigger && $storage_object->read_object('last_set_context_schedule') == $schedule_id && $storage_object->read_object('last_set_context_process') == $process)896 {897 // If the script already ran once for this trigger, don't run it again898 self::check_user_context_log($trigger, $schedule_id, $process, $notes_log_file, null);899 return false;900 }901 $storage_object->add_object('last_set_context_trigger', $trigger);902 $storage_object->add_object('last_set_context_schedule', $schedule_id);903 $storage_object->add_object('last_set_context_process', $process);904 $storage_object->save_to_file($storage_path);905 phoromatic::update_system_status('Setting context for: ' . $schedule_id . ' - ' . $trigger . ' - ' . $process);906 // Run the set context script907 $env_vars['PHOROMATIC_TRIGGER'] = $trigger;908 $env_vars['PHOROMATIC_SCHEDULE_ID'] = $schedule_id;909 $env_vars['PHOROMATIC_SCHEDULE_PROCESS'] = $process;910 $env_vars['PHOROMATIC_LOG_FILE'] = $notes_log_file;911 $log_output = pts_client::shell_exec('./' . $context_script . ' ' . $trigger . ' 2>&1', $env_vars);912 self::check_user_context_log($trigger, $schedule_id, $process, $notes_log_file, $log_output);913 // Just simply return true for now, perhaps check exit code status and do something914 return true;915 }916 return false;917 }918 private static function check_user_context_log($trigger, $schedule_id, $process, $log_file, $log_output)919 {920 if(is_file($log_file) && ($lf_conts = pts_file_io::file_get_contents($log_file)) != null)921 {922 $context_log = $lf_conts;923 unlink($log_file);924 }925 else926 {927 $context_log = trim($log_output);928 }929 if($context_log != null)930 {931 $server_response = phoromatic::upload_to_remote_server(array(932 'r' => 'user_context_log',933 'sched' => $schedule_id,934 'ts' => $trigger,935 'i' => $process,936 'o' => $context_log,937 ));938 }939 }940 public static function __pre_test_install(&$test_install_request)941 {942 /* if(self::$has_run_server_setup_func == false)943 {944 self::setup_server_addressing();945 }946 */947 // XXX finish wiring in the above code to various parts for making auto-reporting from clients948 if(!self::$is_running_as_phoromatic_node)949 {950 return false;951 }952 static $last_update_time = 0;953 if(time() > ($last_update_time + 30))954 {955 phoromatic::update_system_status('Installing: ' . $test_install_request->test_profile->get_identifier());956 $last_update_time = time();957 }958 }959 public static function __pre_test_run($pts_test_result)960 {961 if(!self::$is_running_as_phoromatic_node)962 {963 return false;964 }965 if(self::$in_stress_mode)966 {967 static $time_in_stress_run = 0;968 $msg = 'Stress-Run Testing';969 if(($time_in_stress_run + (60 * 60)) > time())970 {971 // Don't report this same string so often...972 return;973 }974 $time_in_stress_run = time();975 }976 else977 {978 $msg = 'Running: ' . $pts_test_result->test_profile->get_identifier() . ($pts_test_result->get_arguments_description() != null ? ' [' . $pts_test_result->get_arguments_description() . ']' : null);979 }980 phoromatic::update_system_status($msg,981 ceil(self::$test_run_manager->get_estimated_run_time() / 60),982 self::$test_run_manager->get_percent_complete(),983 null,984 ceil($pts_test_result->test_profile->get_estimated_run_time() / 60));985 }986 public static function __event_results_saved($test_run_manager)987 {988 /*if(pts_module::read_variable('AUTO_UPLOAD_RESULTS_TO_PHOROMATIC') && pts_module::is_module_setup())989 {990 phoromatic::upload_unscheduled_test_results($test_run_manager->get_file_name());991 }*/992 }993 public static function __event_run_error($error_obj)994 {...

Full Screen

Full Screen

update_system_status

Using AI Code Generation

copy

Full Screen

1$phoromatic = new phoromatic();2$phoromatic->update_system_status($system_id, $status);3$phoromatic = new phoromatic();4$phoromatic->get_system_status($system_id);5$phoromatic = new phoromatic();6$phoromatic->get_systems($system_id);7$phoromatic = new phoromatic();8$phoromatic->get_systems_count($system_id);9$phoromatic = new phoromatic();10$phoromatic->get_systems_by_status($system_id);11$phoromatic = new phoromatic();12$phoromatic->get_systems_by_status_count($system_id);13$phoromatic = new phoromatic();14$phoromatic->get_systems_by_group($system_id);15$phoromatic = new phoromatic();16$phoromatic->get_systems_by_group_count($system_id);17$phoromatic = new phoromatic();18$phoromatic->get_systems_by_group_status($system_id);19$phoromatic = new phoromatic();20$phoromatic->get_systems_by_group_status_count($system_id);21$phoromatic = new phoromatic();22$phoromatic->get_systems_by_group_status($system_id);

Full Screen

Full Screen

update_system_status

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic = new phoromatic();3$phoromatic->update_system_status($_POST['system_id'], $_POST['system_status'], $_POST['system_status_message']);4require_once('phoromatic.php');5$phoromatic = new phoromatic();6$phoromatic->update_system_status($_POST['system_id'], $_POST['system_status'], $_POST['system_status_message']);7require_once('phoromatic.php');8$phoromatic = new phoromatic();9$phoromatic->update_system_status($_POST['system_id'], $_POST['system_status'], $_POST['system_status_message']);10require_once('phoromatic.php');11$phoromatic = new phoromatic();12$phoromatic->update_system_status($_POST['system_id'], $_POST['system_status'], $_POST['system_status_message']);13require_once('phoromatic.php');14$phoromatic = new phoromatic();15$phoromatic->update_system_status($_POST['system_id'], $_POST['system_status'], $_POST['system_status_message']);16require_once('phoromatic.php');17$phoromatic = new phoromatic();18$phoromatic->update_system_status($_POST['system_id'], $_POST['system_status'], $_POST['system_status_message']);19require_once('phoromatic.php');20$phoromatic = new phoromatic();21$phoromatic->update_system_status($_POST['system_id'], $_POST['system_status'], $_POST['system_status_message']);22require_once('phoromatic.php');23$phoromatic = new phoromatic();24$phoromatic->update_system_status($_POST['system_id'], $_POST['system

Full Screen

Full Screen

update_system_status

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic = new phoromatic;3$phoromatic->update_system_status($_GET['system_id'], $_GET['status'], $_GET['current_task']);4require_once('phoromatic.php');5$phoromatic = new phoromatic;6$phoromatic->update_system_status($_GET['system_id'], $_GET['status'], $_GET['current_task']);7require_once('phoromatic.php');8$phoromatic = new phoromatic;9$phoromatic->update_system_status($_GET['system_id'], $_GET['status'], $_GET['current_task']);10require_once('phoromatic.php');11$phoromatic = new phoromatic;12$phoromatic->update_system_status($_GET['system_id'], $_GET['status'], $_GET['current_task']);13require_once('phoromatic.php');14$phoromatic = new phoromatic;15$phoromatic->update_system_status($_GET['system_id'], $_GET['status'], $_GET['current_task']);16require_once('phoromatic.php');17$phoromatic = new phoromatic;18$phoromatic->update_system_status($_GET['system_id'], $_GET['status'], $_GET['current_task']);19require_once('phoromatic.php');20$phoromatic = new phoromatic;21$phoromatic->update_system_status($_GET['system_id'], $_GET['status'], $_GET['current_task']);22require_once('phoromatic.php');23$phoromatic = new phoromatic;24$phoromatic->update_system_status($_GET['system_id'], $_GET['status'], $_GET['current_task']);

Full Screen

Full Screen

update_system_status

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic = new phoromatic();3$phoromatic->update_system_status($_POST['system_id'], $_POST['last_ping'], $_POST['status'], $_POST['status_message'], $_POST['openbenchmarking_id']);4require_once('phoromatic.php');5$phoromatic = new phoromatic();6$phoromatic->update_system_status($_POST['system_id'], $_POST['last_ping'], $_POST['status'], $_POST['status_message'], $_POST['openbenchmarking_id']);7require_once('phoromatic.php');8$phoromatic = new phoromatic();9$phoromatic->update_system_status($_POST['system_id'], $_POST['last_ping'], $_POST['status'], $_POST['status_message'], $_POST['openbenchmarking_id']);10require_once('phoromatic.php');11$phoromatic = new phoromatic();12$phoromatic->update_system_status($_POST['system_id'], $_POST['last_ping'], $_POST['status'], $_POST['status_message'], $_POST['openbenchmarking_id']);13require_once('phoromatic.php');14$phoromatic = new phoromatic();15$phoromatic->update_system_status($_POST['system_id'], $_POST['last_ping'], $_POST['status'], $_POST['status_message'], $_POST['openbenchmarking_id']);16require_once('phoromatic.php');17$phoromatic = new phoromatic();18$phoromatic->update_system_status($_POST['system_id'], $_POST['last_ping'], $_POST['status'], $_POST['status_message'], $_POST['openbenchmarking_id']);19require_once('phoromatic.php');20$phoromatic = new phoromatic();21$phoromatic->update_system_status($_POST['system

Full Screen

Full Screen

update_system_status

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$system_id = $_GET['system_id'];3$system = phoromatic::system_information($system_id);4$system_status = $_GET['system_status'];5$system_notes = $_GET['system_notes'];6phoromatic::update_system_status($system_id, $system_status, $system_notes);7require_once('phoromatic.php');8$system_id = $_GET['system_id'];9$system = phoromatic::system_information($system_id);10$system_status = $_GET['system_status'];11$system_notes = $_GET['system_notes'];12phoromatic::update_system_status($system_id, $system_status, $system_notes);13require_once('phoromatic.php');14$system_id = $_GET['system_id'];15$system = phoromatic::system_information($system_id);16$system_status = $_GET['system_status'];17$system_notes = $_GET['system_notes'];18phoromatic::update_system_status($system_id, $system_status, $system_notes);19require_once('phoromatic.php');20$system_id = $_GET['system_id'];21$system = phoromatic::system_information($system_id);22$system_status = $_GET['system_status'];23$system_notes = $_GET['system_notes'];24phoromatic::update_system_status($system_id, $system_status, $system_notes);25require_once('phoromatic.php');26$system_id = $_GET['system_id'];27$system = phoromatic::system_information($system_id);28$system_status = $_GET['system_status'];29$system_notes = $_GET['system_notes'];30phoromatic::update_system_status($system_id, $system_status, $system_notes);

Full Screen

Full Screen

update_system_status

Using AI Code Generation

copy

Full Screen

1$phoromatic = new Phoromatic();2$phoromatic->update_system_status($system_id, $status);3$phoromatic = new Phoromatic();4$system_status = $phoromatic->get_system_status($system_id);5$phoromatic = new Phoromatic();6$system_status = $phoromatic->get_system_status($system_id);

Full Screen

Full Screen

update_system_status

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic = new phoromatic();3$phoromatic->update_system_status($_POST['system_id'], $_POST['status']);4require_once('phoromatic.php');5$phoromatic = new phoromatic();6$system_status = $phoromatic->get_system_status($_POST['system_id']);7require_once('phoromatic.php');8$phoromatic = new phoromatic();9$phoromatic->update_system_status($_POST['system_id'], $_POST['status']);10require_once('phoromatic.php');11$phoromatic = new phoromatic();12$system_status = $phoromatic->get_system_status($_POST['system_id']);13require_once('phoromatic.php');14$phoromatic = new phoromatic();15$phoromatic->update_system_status($_POST['system_id'], $_POST['status']);16require_once('phoromatic.php');17$phoromatic = new phoromatic();18$system_status = $phoromatic->get_system_status($_POST['system_id']);

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful