How to use upload_stress_log_sane method of phoromatic class

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

phoromatic.php

Source:phoromatic.php Github

copy

Full Screen

...569 if(self::$test_run_manager->initial_checks($suite_identifier, 'SHORT'))570 {571 if(self::$test_run_manager->load_tests_to_run($suite_identifier))572 {573 self::$test_run_manager->action_on_stress_log_set(array('phoromatic', 'upload_stress_log_sane'));574 self::$in_stress_mode = $phoromatic_save_identifier;575 self::$test_run_manager->multi_test_stress_run_execute($env_vars['PTS_CONCURRENT_TEST_RUNS'], $env_vars['TOTAL_LOOP_TIME']);576 self::$in_stress_mode = false;577 self::upload_stress_log(self::$test_run_manager->get_stress_log());578 }579 }580 self::$benchmark_ticket_id = null;581 break;582 }583 else584 {585 self::$test_run_manager = new pts_test_run_manager(array(586 'UploadResults' => (isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking'])),587 'SaveResults' => true,588 'RunAllTestCombinations' => false,589 'OpenBrowser' => false590 ), true);591 }592 if(self::$test_run_manager->initial_checks($suite_identifier, 'SHORT'))593 {594 // Load the tests to run595 if(self::$test_run_manager->load_tests_to_run($suite_identifier))596 {597 phoromatic::update_system_status('Tests In Run Queue: ' . implode(', ', self::$test_run_manager->get_tests_to_run_identifiers()));598 if(isset($json['phoromatic']['pre_run_set_context']))599 {600 phoromatic::set_user_context($json['phoromatic']['pre_run_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_RUN');601 }602 if(isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']))603 {604 self::$test_run_manager->auto_upload_to_openbenchmarking();605 pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs']));606 }607 // Save results?608 // Run the actual tests609 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.'));610 self::$test_run_manager->pre_execution_process();611 self::$test_run_manager->call_test_runs();612 phoromatic::update_system_status('Benchmarks Completed For: ' . $phoromatic_save_identifier);613 self::$test_run_manager->post_execution_process();614 $elapsed_benchmark_time = time() - $benchmark_timer;615 // Handle uploading data to server616 $result_file = new pts_result_file(self::$test_run_manager->get_file_name());617 $upload_system_logs = pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs']);618 $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);619 //pts_client::$pts_logger->log('DEBUG RESPONSE MESSAGE: ' . $server_response);620 if(!pts_strings::string_bool($json['phoromatic']['settings']['ArchiveResultsLocally']))621 {622 pts_client::remove_saved_result_file(self::$test_run_manager->get_file_name());623 }624 }625 if(isset($json['phoromatic']['post_run_set_context']))626 {627 phoromatic::set_user_context($json['phoromatic']['post_run_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_RUN');628 }629 }630 self::$p_schedule_id = null;631 self::$is_running_as_phoromatic_node = false;632 self::$benchmark_ticket_id = null;633 break;634 case 'reboot':635 echo PHP_EOL . 'Phoromatic received a remote command to reboot.' . PHP_EOL;636 phoromatic::update_system_status('Attempting System Reboot');637 if(pts_client::executable_in_path('reboot'))638 {639 shell_exec('reboot');640 sleep(5);641 }642 break;643 case 'shutdown-if-supports-wake':644 $supports_wol = false;645 foreach(pts_network::get_network_wol() as $net_device)646 {647 if(strpos($net_device, 'g') !== false)648 {649 $supports_wol = true;650 break;651 }652 }653 if(!$supports_wol)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']))...

Full Screen

Full Screen

upload_stress_log_sane

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic.php');2if(isset($_FILES['upload_file']))3{4 $phoromatic = new phoromatic();5 $phoromatic->upload_stress_log_sane($_FILES['upload_file']);6}7require_once('phoromatic.php');8$phoromatic = new phoromatic();9$stress_logs = $phoromatic->get_stress_logs();10foreach($stress_logs as $stress_log)11{12 echo $stress_log['stress_log_file_name'] . " " . $stress_log['user_id'] . " " . $stress_log['time'] . "<br>";13}14require_once('phoromatic.php');

Full Screen

Full Screen

upload_stress_log_sane

Using AI Code Generation

copy

Full Screen

1$phoromatic = new phoromatic();2$phoromatic->upload_stress_log_sane();3if ($_FILES['stress_log']['error'] > 0)4{5 return false;6}7if ($_FILES['stress_log']['type'] != 'text/plain')8{9 return false;10}11if ($_FILES['stress_log']['size'] > 1024 * 1024)12{13 return false;14}15$stress_log_file_name = $_FILES['stress_log']['name'];16$stress_log_file_name = str_replace(' ', '_', $stress_log_file_name);17$stress_log_file_name = str_replace('(', '_', $stress_log_file_name);18$stress_log_file_name = str_replace(')', '_', $stress_log_file_name);19$stress_log_file_name = str_replace('.', '_', $stress_log_file_name);20$stress_log_file_name = str_replace(',', '_', $stress_log_file_name);21$stress_log_file_name = str_replace(';', '_', $stress_log_file_name);22$stress_log_file_name = str_replace(':', '_', $stress_log_file_name);23$stress_log_file_name = str_replace('-', '_', $stress_log_file_name);24$stress_log_file_name = str_replace('+', '_', $stress_log_file_name);25$stress_log_file_name = str_replace('=', '_', $stress_log_file_name);26$stress_log_file_name = str_replace('/', '_', $stress_log_file_name);27$stress_log_file_name = str_replace('\\', '_', $stress_log_file_name);28$stress_log_file_name = str_replace('?', '_', $

Full Screen

Full Screen

upload_stress_log_sane

Using AI Code Generation

copy

Full Screen

1$uploaded_file_path = $phoromatic->upload_stress_log_sane($file_path);2$uploaded_file_path = $phoromatic->upload_stress_log_sane($file_path);3$uploaded_file_path = $phoromatic->upload_stress_log_sane($file_path);4$uploaded_file_path = $phoromatic->upload_stress_log_sane($file_path);5$uploaded_file_path = $phoromatic->upload_stress_log_sane($file_path);6$uploaded_file_path = $phoromatic->upload_stress_log_sane($file_path);

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