How to use run_client_update_script method of phoromatic class

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

phoromatic.php

Source:phoromatic.php Github

copy

Full Screen

...654 break;655 case 'shutdown':656 if(isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script']))657 {658 self::run_client_update_script($json['phoromatic']['client_update_script']);659 sleep(10);660 }661 echo PHP_EOL . 'Phoromatic received a remote command to shutdown.' . PHP_EOL;662 phoromatic::update_system_status('Attempting System Shutdown');663 if(pts_client::executable_in_path('poweroff'))664 {665 shell_exec('poweroff');666 sleep(5);667 }668 break;669 case 'maintenance':670 echo PHP_EOL . 'Idling, system maintenance mode set by Phoromatic Server.' . PHP_EOL;671 phoromatic::update_system_status('Maintenance Mode');672 sleep(60);673 break;674 case 'idle':675 if(isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script']))676 {677 self::run_client_update_script($json['phoromatic']['client_update_script']);678 }679 //echo PHP_EOL . 'Idling, waiting for task.' . PHP_EOL;680 phoromatic::update_system_status('Idling, Waiting For Task');681 break;682 case 'exit':683 echo PHP_EOL . 'Phoromatic received a remote command to exit.' . PHP_EOL;684 phoromatic::update_system_status('Exiting Phoromatic');685 $do_exit = true;686 break;687 }688 }689 if(!$do_exit)690 {691 if($server_response == false)692 sleep(rand(10, 30));693 else if(self::$limit_network_communication)694 sleep(60, 240);695 else696 sleep(60);697 }698 }699 pts_client::release_lock(PTS_USER_PATH . 'phoromatic_lock');700 }701 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)702 {703 $system_logs = null;704 $system_logs_hash = null;705 // TODO: Potentially integrate this code below shared with pts_openbenchmarking_client into a unified function for validating system log files706 $system_log_dir = PTS_SAVE_RESULTS_PATH . $result_file->get_identifier() . '/system-logs/';707 if(is_dir($system_log_dir) && $upload_system_logs)708 {709 $is_valid_log = true;710 $finfo = function_exists('finfo_open') ? finfo_open(FILEINFO_MIME_TYPE) : false;711 foreach(pts_file_io::glob($system_log_dir . '*') as $log_dir)712 {713 if($is_valid_log == false || !is_dir($log_dir))714 {715 $is_valid_log = false;716 break;717 }718 foreach(pts_file_io::glob($log_dir . '/*') as $log_file)719 {720 if(!is_file($log_file))721 {722 $is_valid_log = false;723 break;724 }725 if($finfo && substr(finfo_file($finfo, $log_file), 0, 5) != 'text/')726 {727 $is_valid_log = false;728 break;729 }730 }731 }732 if($is_valid_log)733 {734 $system_logs_zip = pts_client::create_temporary_file('.zip');735 pts_compression::zip_archive_create($system_logs_zip, $system_log_dir);736 if(filesize($system_logs_zip) == 0)737 {738 pts_client::$pts_logger && pts_client::$pts_logger->log('System log ZIP file failed to generate. Missing PHP ZIP support?');739 }740 else if(filesize($system_logs_zip) < 2097152)741 {742 // If it's over 2MB, probably too big743 $system_logs = base64_encode(file_get_contents($system_logs_zip));744 $system_logs_hash = sha1($system_logs);745 }746 else747 {748 // trigger_error('The systems log attachment is too large to upload to OpenBenchmarking.org.', E_USER_WARNING);749 }750 unlink($system_logs_zip);751 }752 }753 $composite_xml = $result_file->get_xml();754 $composite_xml_hash = sha1($composite_xml);755 $composite_xml_type = 'composite_xml';756 // Compress the result file XML if it's big757 if(isset($composite_xml[50000]) && function_exists('gzdeflate'))758 {759 $composite_xml_gz = gzdeflate($composite_xml);760 if($composite_xml_gz != false)761 {762 $composite_xml = $composite_xml_gz;763 $composite_xml_type = 'composite_xml_gz';764 }765 }766 // Upload to Phoromatic767 $times_tried = 0;768 do769 {770 if($times_tried > 0)771 {772 sleep(rand(5, 20));773 }774 $res = phoromatic::upload_to_remote_server(array(775 'r' => 'result_upload',776 //'ob' => $ob_data['id'],777 'sched' => $schedule_id,778 'bid' => $benchmark_ticket_id,779 'o' => $save_identifier,780 'ts' => $trigger,781 'et' => $elapsed_time,782 $composite_xml_type => base64_encode($composite_xml),783 'composite_xml_hash' => $composite_xml_hash,784 'system_logs_zip' => $system_logs,785 'system_logs_hash' => $system_logs_hash786 ));787 $times_tried++;788 }789 while($res == false && $times_tried < 4);790 return $res;791 }792 private static function upload_stress_log($stress_log)793 {794 // Upload Logs to Phoromatic795 if($stress_log == null || self::$benchmark_ticket_id == null)796 {797 return;798 }799 $times_tried = 0;800 do801 {802 if($times_tried > 0)803 {804 sleep(rand(5, 20));805 }806 $res = phoromatic::upload_to_remote_server(array(807 'r' => 'stress_log_upload',808 'bid' => self::$benchmark_ticket_id,809 'l' => $stress_log810 ));811 $times_tried++;812 }813 while($res == false && $times_tried < 4);814 return $res;815 }816 public static function upload_stress_log_sane($stress_log)817 {818 static $last_log_upload = 0;819 if(time() > ($last_log_upload + 60))820 {821 self::upload_stress_log($stress_log);822 $last_log_upload = time();823 }824 }825 public static function recent_phoromatic_server_results()826 {827 self::setup_server_addressing();828 $server_response = phoromatic::upload_to_remote_server(array('r' => 'list_results'));829 $server_response = json_decode($server_response, true);830 if(isset($server_response['phoromatic']['results']) && !empty($server_response['phoromatic']['results']))831 {832 foreach($server_response['phoromatic']['results'] as $pprid => $result)833 {834 echo sprintf('%-26ls - %-25ls - %-30ls', $result['Title'], $pprid, date('j M H:i', strtotime($result['UploadTime']))) . PHP_EOL;835 echo sprintf(' %-20ls - %-25ls' . PHP_EOL, $result['SystemName'], $result['GroupName']) . PHP_EOL;836 }837 }838 else839 echo PHP_EOL . 'No Phoromatic Server results discovered.';840 echo PHP_EOL;841 }842 public static function clone_phoromatic_server_result($args)843 {844 self::setup_server_addressing();845 $id = $args[0];846 $server_response = phoromatic::upload_to_remote_server(array('r' => 'clone_result', 'i' => $id));847 $server_response = json_decode($server_response, true);848 if(isset($server_response['phoromatic']['result']['composite_xml']) && !empty($server_response['phoromatic']['result']['composite_xml']))849 {850 $composite_xml = base64_decode($server_response['phoromatic']['result']['composite_xml']);851 $result_file = new pts_result_file($composite_xml);852 // TODO XXX: Add system log downloading support853 pts_client::save_test_result($id . '/composite.xml', $result_file->get_xml(), true);854 echo PHP_EOL . 'Result File Saved As: ' . $id . PHP_EOL . PHP_EOL;855 }856 else857 echo PHP_EOL . 'No Phoromatic result found.' . PHP_EOL;858 }859 private static function run_client_update_script($update_script)860 {861 static $last_update_script_check_time = 0;862 // Don't keep checking it so check no more than every 20 minutes863 if($last_update_script_check_time < (time() - 1200) && !empty($update_script))864 {865 $last_update_script_check_time = time();866 $update_file = pts_client::create_temporary_file();867 $update_script = str_replace("\r", PHP_EOL, $update_script);868 file_put_contents($update_file, $update_script);869 phoromatic::update_system_status('Running Phoronix Test Suite Update Script');870 $env_vars = array();871 pts_client::shell_exec('bash ' . $update_file . ' 2>&1', $env_vars);872 }873 }...

Full Screen

Full Screen

run_client_update_script

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic = new phoromatic();3$phoromatic->run_client_update_script();4require_once('phoromatic.php');5$phoromatic = new phoromatic();6$phoromatic->run_client_update_script();7require_once('phoromatic.php');8$phoromatic = new phoromatic();9$phoromatic->run_client_update_script();10require_once('phoromatic.php');11$phoromatic = new phoromatic();12$phoromatic->run_client_update_script();13require_once('phoromatic.php');14$phoromatic = new phoromatic();15$phoromatic->run_client_update_script();16require_once('phoromatic.php');17$phoromatic = new phoromatic();18$phoromatic->run_client_update_script();19require_once('phoromatic.php');20$phoromatic = new phoromatic();21$phoromatic->run_client_update_script();22require_once('phoromatic.php');23$phoromatic = new phoromatic();24$phoromatic->run_client_update_script();25require_once('phoromatic.php');26$phoromatic = new phoromatic();27$phoromatic->run_client_update_script();28require_once('phoromatic.php');29$phoromatic = new phoromatic();30$phoromatic->run_client_update_script();

Full Screen

Full Screen

run_client_update_script

Using AI Code Generation

copy

Full Screen

1$phoromatic = new phoromatic();2$phoromatic->run_client_update_script($client_id);3public function run_client_update_script($client_id)4{5 $client = $this->db->querySingle("SELECT * FROM phoromatic_clients WHERE AccountID = :account_id AND SystemID = :system_id", array('account_id' => $_SESSION['AccountID'], 'system_id' => $client_id));6 $client['SystemID'] = $client_id;7 $this->run_script('client_update', $client);8}9public function run_script($script, $client)10{11 $script_path = PHOROMATIC_SCRIPT_PATH . $script . '.php';12 if (file_exists($script_path))13 {14 $script_output = array();15 $script_return = 0;16 $command = 'php ' . $script_path . ' ' . $client['SystemID'];17 $this->system->exec($command, $script_output, $script_return);18 if ($script_return != 0)19 {20 $this->db->exec("UPDATE phoromatic_clients SET LastCommunication = :last_communication, LastCommunicationResult = :last_communication_result WHERE AccountID = :account_id AND SystemID = :system_id", array('last_communication' => time(), 'last_communication_result' => 'Error', 'account_id' => $_SESSION['AccountID'], 'system_id' => $client['SystemID']));21 $this->system->logger->log('Error: ' . $command . ' returned ' . $script_return . ' - ' . implode("\n", $script_output));22 }23 }24 {25 $this->system->logger->log('Error: Unable to find ' . $script_path . ' for ' . $client['SystemID']);26 }27}28public function get_client($client_id)29{30 $client = $this->db->querySingle("SELECT * FROM phoromatic_clients WHERE AccountID = :account_id AND SystemID = :system_id", array('account_id' => $_SESSION['AccountID'], 'system_id' => $client_id));

Full Screen

Full Screen

run_client_update_script

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2$phoromatic = new phoromatic();3$phoromatic->run_client_update_script();4Recommended Posts: PHP | Phoromatic | run_client_update_script() Method5PHP | Phoromatic | get_client_info() Method6PHP | Phoromatic | get_client_status() Method7PHP | Phoromatic | get_client_update_script() Method8PHP | Phoromatic | get_client_update_script_status() Method

Full Screen

Full Screen

run_client_update_script

Using AI Code Generation

copy

Full Screen

1include 'phoromatic.php';2$phoromatic = new phoromatic();3$phoromatic->run_client_update_script();4include 'phoromatic.php';5$phoromatic = new phoromatic();6$phoromatic->run_client_update_script();7include 'phoromatic.php';8$phoromatic = new phoromatic();9$phoromatic->run_client_update_script();10include 'phoromatic.php';11$phoromatic = new phoromatic();12$phoromatic->run_client_update_script();13include 'phoromatic.php';14$phoromatic = new phoromatic();15$phoromatic->run_client_update_script();16include 'phoromatic.php';17$phoromatic = new phoromatic();18$phoromatic->run_client_update_script();19include 'phoromatic.php';20$phoromatic = new phoromatic();21$phoromatic->run_client_update_script();22include 'phoromatic.php';23$phoromatic = new phoromatic();24$phoromatic->run_client_update_script();25include 'phoromatic.php';26$phoromatic = new phoromatic();27$phoromatic->run_client_update_script();

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