public static function run($r) { echo PHP_EOL . 'If you have not already registered for your free OpenBenchmarking.org account, you can do so at http://openbenchmarking.org/' . PHP_EOL . PHP_EOL . 'Once you have registered your account and clicked the link within the verification email, enter your log-in information below.' . PHP_EOL . PHP_EOL; echo 'User-Name: '; $username = pts_user_io::read_user_input(); echo 'Password: '******'s_u' => $username, 's_p' => sha1($password), 's_s' => base64_encode(phodevi::system_software(true)), 's_h' => base64_encode(phodevi::system_hardware(true))); $login_state = pts_openbenchmarking::make_openbenchmarking_request('account_login', $login_payload); $json = json_decode($login_state, true); if (isset($json['openbenchmarking']['response']['error'])) { trigger_error($json['openbenchmarking']['response']['error'], E_USER_ERROR); pts_storage_object::remove_in_file(PTS_CORE_STORAGE, 'openbenchmarking'); } else { $openbenchmarking_payload = array('user_name' => $json['openbenchmarking']['account']['user_name'], 'communication_id' => $json['openbenchmarking']['account']['communication_id'], 'sav' => $json['openbenchmarking']['account']['sav']); pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'openbenchmarking', $openbenchmarking_payload); echo PHP_EOL . PHP_EOL . 'The Account Has Been Setup.' . PHP_EOL . PHP_EOL; } }
public static function run($r) { pts_client::$display->generic_heading('System Information'); echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL; echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL; // // Processor Information // $cpu_flags = phodevi_cpu::get_cpu_flags(); echo PHP_EOL . 'PROCESSOR:' . PHP_EOL . PHP_EOL; echo 'Core Count: ' . phodevi_cpu::cpuinfo_core_count() . PHP_EOL; echo 'Thread Count: ' . phodevi_cpu::cpuinfo_thread_count() . PHP_EOL; echo 'Cache Size: ' . phodevi_cpu::cpuinfo_cache_size() . ' KB' . PHP_EOL; echo 'Instruction Set Extensions: ' . phodevi_cpu::instruction_set_extensions() . PHP_EOL; echo 'AES Encryption: ' . ($cpu_flags & phodevi_cpu::get_cpu_feature_constant('aes') ? 'YES' : 'NO') . PHP_EOL; echo 'Energy Performance Bias: ' . ($cpu_flags & phodevi_cpu::get_cpu_feature_constant('epb') ? 'YES' : 'NO') . PHP_EOL; echo 'Virtualization: ' . (phodevi_cpu::virtualization_technology() ? phodevi_cpu::virtualization_technology() : 'NO') . PHP_EOL; // Other info foreach (pts_arrays::to_array(pts_test_run_manager::pull_test_notes(true)) as $test_note_head => $test_note) { echo ucwords(str_replace('-', ' ', $test_note_head)) . ': ' . $test_note . PHP_EOL; } }
protected function process_hand_shake($user, $buffer) { $buffer_wrote = parent::process_hand_shake($user, $buffer); return $buffer_wrote; // TODO potentially don't need below code for this back-end XXX if ($buffer_wrote > 0) { $resource = substr($user->res, strrpos($user->res, '/') + 1); switch (strstr($resource . ' ', ' ', true)) { case 'start-user-session': $json = array(); $json['pts']['msg']['name'] = 'user_session_start'; $this->add_to_status('Starting Session', $json); $this->send_json_data($user->socket, $json); // Phodevi $this->add_to_status('Generating Phodevi Cache + VFS', $json); $this->send_json_data($user->socket, $json); phodevi::system_software(true); phodevi::system_hardware(true); $this->phodevi_vfs = new phodevi_vfs(); $this->phodevi_vfs->list_cache_nodes(); // Sensors $this->add_to_status('Starting Phodevi Sensor Handler', $json); $this->send_json_data($user->socket, $json); $this->sensor_logging = new phodevi_sensor_monitor(array('all')); $this->sensor_logging->sensor_logging_start(); // Test Information $this->add_to_status('Downloading Test Information', $json); $this->send_json_data($user->socket, $json); pts_openbenchmarking::available_tests(true); // Complete $this->add_to_status('Session Startup Complete', $json); $this->send_json_data($user->socket, $json); //$this->disconnect($user->socket); break; } return true; } }
public static function run($r) { $compare_tests = array(); $compare_subsystems = array(); foreach ($r as $test_object) { $test_object = pts_types::identifier_to_object($test_object); if ($test_object instanceof pts_test_profile) { array_push($compare_tests, $test_object->get_identifier(false)); if (!isset($compare_subsystems[$test_object->get_test_hardware_type()])) { $compare_subsystems[$test_object->get_test_hardware_type()] = 1; } else { $compare_subsystems[$test_object->get_test_hardware_type()] += 1; } } } if (empty($compare_tests)) { $subsystem_under_test = pts_user_io::prompt_text_menu('Sub-System To Test', array('Processor', 'Graphics', 'Disk')); } else { arsort($compare_subsystems); $compare_subsystems = array_keys($compare_subsystems); $subsystem_under_test = array_shift($compare_subsystems); } $system_info = array_merge(phodevi::system_hardware(false), phodevi::system_software(false)); $to_include = array(); $to_exclude = array(); if (isset($system_info[$subsystem_under_test])) { $compare_component = $system_info[$subsystem_under_test]; } else { return; } switch ($subsystem_under_test) { case 'Processor': self::system_component_to_format($system_info, $to_include, array('OS', 'Compiler', 'Kernel', 'Motherboard'), true); break; case 'Graphics': self::system_component_to_format($system_info, $to_include, array('OS', 'Display Driver', 'OpenGL', 'Processor', 'Kernel', 'Desktop'), true); break; case 'OS': self::system_component_to_format($system_info, $to_include, array('Processor', 'Motherboard', 'Graphics', 'Disk'), true); self::system_component_to_format($system_info, $to_exclude, array('OS')); break; case 'Disk': self::system_component_to_format($system_info, $to_include, array('Processor', 'OS', 'Chipset', 'Motherboard', 'Kernel'), true); break; } $payload = array('subsystem_under_test' => $subsystem_under_test, 'component_under_test' => $compare_component, 'include_components' => implode(',', $to_include), 'exclude_components' => implode(',', $to_exclude), 'include_tests' => implode(',', $compare_tests)); echo PHP_EOL . 'Querying test data from OpenBenchmarking.org...' . PHP_EOL; $json = pts_openbenchmarking::make_openbenchmarking_request('auto_generate_comparison', $payload); $json = json_decode($json, true); if (isset($json['auto_compare']['public_ids']) && isset($json['auto_compare']['count']) && $json['auto_compare']['count'] > 0) { echo 'Found ' . $json['auto_compare']['count'] . ' comparable results on OpenBenchmarking.org with a ' . $json['auto_compare']['accuracy'] . '% accuracy.' . PHP_EOL; $compare_results = array(); foreach ($json['auto_compare']['public_ids'] as $public_id) { $result_xml = pts_openbenchmarking::clone_openbenchmarking_result($public_id, true); if ($result_xml) { $result_file = new pts_result_file($result_xml); $result_objects = $result_file->get_result_objects(); foreach ($result_objects as $i => &$result_object) { if (!empty($compare_tests)) { if (!in_array($result_object->test_profile->get_identifier(false), $compare_tests)) { unset($result_objects[$i]); } } else { if ($result_object->test_profile->get_test_hardware_type() != $subsystem_under_test) { unset($result_objects[$i]); } } } if (count($result_objects) == 0) { continue; } $result_file->override_result_objects($result_objects); array_push($compare_results, $result_file); } } if (count($compare_results) > 0) { $result_xml = pts_merge::merge_test_results_array($compare_results); if (count($compare_results) > 2) { $result_file = new pts_result_file($result_xml); $result_objects = $result_file->get_result_objects(); $system_count = $result_file->get_system_count(); $result_count = count($result_objects); $result_match_count = array(); if ($result_count > 3) { foreach ($result_objects as $i => &$result_object) { $result_match_count[$i] = $result_object->test_result_buffer->get_count(); } arsort($result_match_count); $biggest_size = pts_arrays::first_element($result_match_count); if ($biggest_size == $system_count || $biggest_size > 3) { foreach ($result_match_count as $key => $value) { if ($value < 2) { unset($result_objects[$key]); } } } $result_file->override_result_objects($result_objects); $result_xml = pts_merge::merge_test_results_array(array($result_file)); } } pts_client::save_test_result('auto-comparison/composite.xml', $result_xml); } } pts_test_installer::standard_install(array('auto-comparison')); pts_test_run_manager::standard_run(array('auto-comparison')); }
public static function cache_hardware_calls() { phodevi::system_hardware(true); phodevi::supported_sensors(); phodevi::unsupported_sensors(); }
public static function init_account($openbenchmarking, $settings) { if (isset($openbenchmarking['user_name']) && isset($openbenchmarking['communication_id']) && isset($openbenchmarking['sav'])) { if (IS_FIRST_RUN_TODAY && pts_network::internet_support_available()) { // Might as well make sure OpenBenchmarking.org account has the latest system info // But don't do it everytime to preserve bandwidth $openbenchmarking['s_s'] = base64_encode(phodevi::system_software(true)); $openbenchmarking['s_h'] = base64_encode(phodevi::system_hardware(true)); $return_state = pts_openbenchmarking::make_openbenchmarking_request('account_verify', $openbenchmarking); $json = json_decode($return_state, true); if (isset($json['openbenchmarking']['account']['valid'])) { // The account is valid self::$openbenchmarking_account = $openbenchmarking; self::$client_settings = $json['openbenchmarking']['account']['settings']; pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'openbenchmarking_account_settings', $json['openbenchmarking']['account']['settings']); } else { pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'openbenchmarking', false); trigger_error('Invalid OpenBenchmarking.org account supplied, please re-login.', E_USER_ERROR); } } else { self::$openbenchmarking_account = $openbenchmarking; self::$client_settings = $settings; } } }
public static function run($r) { pts_client::$display->generic_heading('System Information'); echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL; echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL; }
public function save_results_prompt() { if (!$this->auto_mode) { pts_client::$display->generic_heading('System Information'); echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL; echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL; } if (($this->prompt_save_results || $this->force_save_results) && count($this->tests_to_run) > 0) { if ($this->force_save_results || pts_client::read_env('TEST_RESULTS_NAME')) { $save_results = true; } else { if ($this->batch_mode) { $save_results = $this->batch_mode['SaveResults']; } else { if (pts_client::is_debug_mode()) { $save_results = false; } else { $save_results = pts_user_io::prompt_bool_input('Would you like to save these test results', true); } } } if ($save_results) { // Prompt Save File Name $this->prompt_save_name(); // Prompt Identifier $this->prompt_results_identifier(); if (!isset($this->run_description[16]) || strpos($this->run_description, 'via the Phoronix Test Suite') !== false) { // Write the auto-description if nothing is set or attempt to auto-detect if it was a previous auto-description saved $this->run_description = self::auto_generate_description(); } // Prompt Description if (!$this->batch_mode || $this->batch_mode['PromptForTestDescription']) { if ($this->run_description == null) { $this->run_description = 'N/A'; } if (pts_client::read_env('TEST_RESULTS_DESCRIPTION')) { if (strlen(pts_client::read_env('TEST_RESULTS_DESCRIPTION')) > 1) { $this->run_description = pts_client::read_env('TEST_RESULTS_DESCRIPTION'); echo 'Test Description: ' . $this->run_description . PHP_EOL; } } else { if (!$this->auto_mode) { //echo PHP_EOL . 'Current Title: ' . $this->file_name_title . PHP_EOL; pts_client::$display->generic_heading('If you wish, enter a new description below to better describe this result set / system configuration under test.' . PHP_EOL . 'Press ENTER to proceed without changes.'); echo 'Current Description: ' . $this->run_description . PHP_EOL . PHP_EOL . 'New Description: '; $new_test_description = pts_user_io::read_user_input(); if (!empty($new_test_description)) { $this->run_description = $new_test_description; } } } } } } }
public static function run($r) { pts_openbenchmarking::refresh_repository_lists(); pts_client::$display->generic_heading('Interactive Benchmarking'); echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL; $reboot_on_exit = false; do { $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition'); if (count(pts_client::saved_test_results()) > 0) { $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage'; } $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit'; $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true); switch ($response) { case 'RUN_TEST': $supported_tests = pts_openbenchmarking::available_tests(); $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true); $longest_title_length = 0; foreach ($supported_tests as $i => &$test_profile) { if ($test_profile->get_title() == null) { unset($supported_tests[$i]); continue; } $longest_title_length = max($longest_title_length, strlen($test_profile->get_title())); } $t = array(); foreach ($supported_tests as $i => &$test_profile) { if ($test_profile instanceof pts_test_profile) { $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type()); } } $supported_tests = $t; asort($supported_tests); $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true); $tests_to_run = explode(',', $tests_to_run); pts_test_installer::standard_install($tests_to_run); $run_manager = new pts_test_run_manager(false, 2); $run_manager->standard_run($tests_to_run); if ($run_manager != false) { pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true); } break; case 'RUN_SUITE': $possible_suites = pts_openbenchmarking::available_suites(); foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) { array_push($possible_suites, 'pts/' . $subsystem); } $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true); foreach (explode(',', $suites_to_run) as $suite_to_run) { pts_test_installer::standard_install($suite_to_run); $run_manager = new pts_test_run_manager(false, 2); $run_manager->standard_run($suite_to_run); } break; case 'SELECT_DRIVE_MOUNT': self::select_drive_mount(); break; case 'RUN_SYSTEM_TEST': pts_client::$display->generic_heading('System Test'); $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark'); pts_test_installer::standard_install($system_tests); $run_manager = new pts_test_run_manager(false, 2); $run_manager->standard_run($system_tests); if ($run_manager != false) { pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true); } break; case 'SHOW_INFO': pts_client::$display->generic_heading('System Software / Hardware Information'); echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL; echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL; break; case 'SHOW_SENSORS': pts_client::$display->generic_heading('Detected System Sensors'); foreach (phodevi::supported_sensors() as $sensor) { echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL; } break; case 'SET_RUN_COUNT': $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false); putenv('FORCE_TIMES_TO_RUN=' . trim($run_count)); break; case 'BACKUP_RESULTS_TO_USB': pts_client::$display->generic_heading('Backing Up Test Results'); foreach (pts_file_io::glob('/media/*') as $media_dir) { if (!is_writable($media_dir)) { echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL; continue; } echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL; pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/'); break; } break; } echo PHP_EOL . PHP_EOL; } while ($response != 'EXIT'); if ($reboot_on_exit) { if (is_dir('/media/pts-auto-mount')) { pts_file_io::delete('/media/pts-auto-mount/pts', null, true); exec('umount /media/pts-auto-mount 2>&1'); } exec('reboot'); } }
public function add_current_system_information() { $this->xml_writer->addXmlNode('PhoronixTestSuite/System/Identifier', $this->result_identifier); $this->xml_writer->addXmlNode('PhoronixTestSuite/System/Hardware', phodevi::system_hardware(true)); $this->xml_writer->addXmlNode('PhoronixTestSuite/System/Software', phodevi::system_software(true)); $this->xml_writer->addXmlNode('PhoronixTestSuite/System/User', pts_client::current_user()); $this->xml_writer->addXmlNode('PhoronixTestSuite/System/TimeStamp', date('Y-m-d H:i:s')); $this->xml_writer->addXmlNode('PhoronixTestSuite/System/TestClientVersion', PTS_VERSION); //$this->xml_writer->addXmlNode('PhoronixTestSuite/System/Notes', pts_test_notes_manager::generate_test_notes($test_type)); }
public static function run_connection($args) { if (pts_client::create_lock(PTS_USER_PATH . 'phoromatic_lock') == false) { trigger_error('Phoromatic is already running.', E_USER_ERROR); return false; } define('PHOROMATIC_PROCESS', true); if (pts_client::$pts_logger == false) { pts_client::$pts_logger = new pts_logger(); } pts_client::$pts_logger->log(pts_title(true) . ' [' . PTS_CORE_VERSION . '] starting Phoromatic client'); if (phodevi::system_uptime() < 60) { echo 'PHOROMATIC: Sleeping for 60 seconds as system freshly started.' . PHP_EOL; pts_client::$pts_logger->log('Sleeping for 60 seconds as system freshly started'); sleep(60); } $server_setup = self::setup_server_addressing($args); //$http_comm = new phoromatic_client_comm_http(); if (!$server_setup) { if (PTS_IS_DAEMONIZED_SERVER_PROCESS) { if (pts_client::executable_in_path('reboot')) { shell_exec('reboot'); sleep(5); } } return false; } $times_failed = 0; $has_success = false; $do_exit = false; $just_started = true; self::setup_system_environment(); pts_client::$pts_logger->log('SYSTEM HARDWARE: ' . phodevi::system_hardware(true)); pts_client::$pts_logger->log('SYSTEM SOFTWARE: ' . phodevi::system_software(true)); while ($do_exit == false) { $server_response = phoromatic::upload_to_remote_server(array('r' => 'start')); if ($server_response == false) { $times_failed++; pts_client::$pts_logger->log('Server response failed'); if ($times_failed >= 2) { trigger_error('Communication with server failed.', E_USER_ERROR); if (PTS_IS_DAEMONIZED_SERVER_PROCESS == false && $times_failed > 5) { return false; } else { if (PTS_IS_DAEMONIZED_SERVER_PROCESS && $times_failed > 10) { if (pts_client::executable_in_path('reboot')) { shell_exec('reboot'); sleep(5); } } } } } else { if (substr($server_response, 0, 1) == '[') { // Likely a notice/warning from server echo PHP_EOL . substr($server_response, 0, strpos($server_response, PHP_EOL)) . PHP_EOL; } else { if (substr($server_response, 0, 1) == '{') { $times_failed = 0; $json = json_decode($server_response, true); if ($has_success == false) { $has_success = true; pts_module::save_file('last-phoromatic-server', self::$server_address . ':' . self::$server_http_port . '/' . self::$account_id); } if ($json != null) { if (isset($json['phoromatic']['error']) && !empty($json['phoromatic']['error'])) { trigger_error($json['phoromatic']['error'], E_USER_ERROR); } if (isset($json['phoromatic']['response']) && !empty($json['phoromatic']['response'])) { echo PHP_EOL . $json['phoromatic']['response'] . PHP_EOL; } } if ($just_started) { if (PTS_IS_DAEMONIZED_SERVER_PROCESS) { $pid = pcntl_fork(); if ($pid == 0) { // Start the tick thread self::tick_thread(); } } $just_started = false; } if (isset($json['phoromatic']['pre_set_sys_env_vars']) && !empty($json['phoromatic']['pre_set_sys_env_vars'])) { // pre_set_sys_env_vars was added during PTS 5.8 development // Sets environment variables on client as specified via the Phoromatic Server's systems page foreach (explode(';', $json['phoromatic']['pre_set_sys_env_vars']) as $i => $v_string) { $var = explode('=', $v_string); if (count($var) == 2) { putenv($var[0] . '=' . $var[1]); } } } switch (isset($json['phoromatic']['task']) ? $json['phoromatic']['task'] : null) { case 'install': phoromatic::update_system_status('Installing Tests'); pts_suite_nye_XmlReader::set_temporary_suite('pre-seed', $json['phoromatic']['test_suite']); pts_test_installer::standard_install('pre-seed'); break; case 'benchmark': // Make sure all latest tests are available pts_openbenchmarking::refresh_repository_lists(null, true); $benchmark_timer = time(); self::$is_running_as_phoromatic_node = true; $test_flags = pts_c::auto_mode | pts_c::batch_mode; $suite_identifier = sha1(time() . rand(2, 1000)); pts_suite_nye_XmlReader::set_temporary_suite($suite_identifier, $json['phoromatic']['test_suite']); self::$p_save_identifier = $json['phoromatic']['trigger_id']; $phoromatic_results_identifier = self::$p_save_identifier; $phoromatic_save_identifier = $json['phoromatic']['save_identifier']; self::$p_schedule_id = isset($json['phoromatic']['schedule_id']) ? $json['phoromatic']['schedule_id'] : false; self::$p_trigger_id = self::$p_save_identifier; $benchmark_ticket_id = isset($json['phoromatic']['benchmark_ticket_id']) ? $json['phoromatic']['benchmark_ticket_id'] : null; phoromatic::update_system_status('Running Benchmarks For: ' . $phoromatic_save_identifier); if (pts_strings::string_bool($json['phoromatic']['settings']['RunInstallCommand'])) { if (isset($json['phoromatic']['pre_install_set_context'])) { phoromatic::set_user_context($json['phoromatic']['pre_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_INSTALL'); } if (pts_strings::string_bool($json['phoromatic']['settings']['ForceInstallTests'])) { $test_flags |= pts_c::force_install; } pts_client::set_test_flags($test_flags); pts_test_installer::standard_install($suite_identifier); if (isset($json['phoromatic']['post_install_set_context'])) { phoromatic::set_user_context($json['phoromatic']['post_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_INSTALL'); } } $env_vars = isset($json['phoromatic']['environment_variables']) ? pts_strings::parse_value_string_vars($json['phoromatic']['environment_variables']) : array(); // Do the actual running phodevi::clear_cache(); if (pts_test_run_manager::initial_checks($suite_identifier, 0, 'SHORT')) { self::$test_run_manager = new pts_test_run_manager($test_flags); pts_test_run_manager::set_batch_mode(array('UploadResults' => isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']), 'SaveResults' => true, 'RunAllTestCombinations' => false, 'OpenBrowser' => false)); // Load the tests to run if (self::$test_run_manager->load_tests_to_run($suite_identifier)) { phoromatic::update_system_status('Tests In Run Queue: ' . implode(', ', self::$test_run_manager->get_tests_to_run_identifiers())); if (isset($json['phoromatic']['pre_run_set_context'])) { phoromatic::set_user_context($json['phoromatic']['pre_run_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_RUN'); } if (isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking'])) { self::$test_run_manager->auto_upload_to_openbenchmarking(); pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs'])); } // Save results? // Run the actual tests if (isset($env_vars['PTS_CONCURRENT_TEST_RUNS']) && $env_vars['PTS_CONCURRENT_TEST_RUNS'] > 1) { $total_loop_time = isset($env_vars['TOTAL_LOOP_TIME']) ? $env_vars['TOTAL_LOOP_TIME'] : false; pts_client::$pts_logger->log('STRESS / MULTI-TEST EXECUTION STARTED @ ' . date('Y-m-d H:i:s')); pts_client::$pts_logger->log('CONCURRENT RUNS = ' . $env_vars['PTS_CONCURRENT_TEST_RUNS'] . ' TOTAL LOOP TIME = ' . $total_loop_time); $r = self::$test_run_manager->multi_test_stress_run_execute($env_vars['PTS_CONCURRENT_TEST_RUNS'], $total_loop_time); if ($r == false) { return; } pts_client::$pts_logger->log('STRESS / MULTI-TEST EXECUTION ENDED @ ' . date('Y-m-d H:i:s')); } else { 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.'); self::$test_run_manager->pre_execution_process(); self::$test_run_manager->call_test_runs(); } phoromatic::update_system_status('Benchmarks Completed For: ' . $phoromatic_save_identifier); self::$test_run_manager->post_execution_process(); $elapsed_benchmark_time = time() - $benchmark_timer; // Handle uploading data to server $result_file = new pts_result_file(self::$test_run_manager->get_file_name()); $upload_system_logs = pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs']); $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); //pts_client::$pts_logger->log('DEBUG RESPONSE MESSAGE: ' . $server_response); if (!pts_strings::string_bool($json['phoromatic']['settings']['ArchiveResultsLocally'])) { pts_client::remove_saved_result_file(self::$test_run_manager->get_file_name()); } } if (isset($json['phoromatic']['post_install_set_context'])) { phoromatic::set_user_context($json['phoromatic']['post_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_RUN'); } } self::$p_schedule_id = null; self::$is_running_as_phoromatic_node = false; break; case 'reboot': echo PHP_EOL . 'Phoromatic received a remote command to reboot.' . PHP_EOL; phoromatic::update_system_status('Attempting System Reboot'); if (pts_client::executable_in_path('reboot')) { shell_exec('reboot'); sleep(5); } break; case 'shutdown-if-supports-wake': $supports_wol = false; foreach (pts_network::get_network_wol() as $net_device) { if (strpos($net_device, 'g') !== false) { $supports_wol = true; break; } } if (!$supports_wol) { break; } case 'shutdown': if (isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script'])) { self::run_client_update_script($json['phoromatic']['client_update_script']); sleep(10); } echo PHP_EOL . 'Phoromatic received a remote command to shutdown.' . PHP_EOL; phoromatic::update_system_status('Attempting System Shutdown'); if (pts_client::executable_in_path('poweroff')) { shell_exec('poweroff'); sleep(5); } break; case 'maintenance': echo PHP_EOL . 'Idling, system maintenance mode set by Phoromatic Server.' . PHP_EOL; phoromatic::update_system_status('Maintenance Mode'); sleep(60); break; case 'idle': if (isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script'])) { self::run_client_update_script($json['phoromatic']['client_update_script']); } //echo PHP_EOL . 'Idling, waiting for task.' . PHP_EOL; phoromatic::update_system_status('Idling, Waiting For Task'); break; case 'exit': echo PHP_EOL . 'Phoromatic received a remote command to exit.' . PHP_EOL; phoromatic::update_system_status('Exiting Phoromatic'); $do_exit = true; break; } } } } if (!$do_exit) { if ($server_response == false) { sleep(rand(10, 30)); } else { sleep(60); } } } pts_client::release_lock(PTS_USER_PATH . 'phoromatic_lock'); }
protected static function update_system_details() { $server_response = phoromatic::upload_to_remote_server(array('r' => 'update_system_details', 'h' => phodevi::system_hardware(true), 's' => phodevi::system_software(true))); self::$phoromatic_server_build = self::read_xml_value($server_response, M_PHOROMATIC_SERVER_BUILD); return self::read_xml_value($server_response, M_PHOROMATIC_GEN_RESPONSE) == M_PHOROMATIC_RESPONSE_TRUE; }
public static function run($r) { $is_moscow = pts_flags::os_identifier_hash() == 'b28d6a7148b34595c5b397dfcf5b12ac7932b3dc'; if ($is_moscow) { // Auto mount? $drives = pts_file_io::glob('/dev/sda*'); sort($drives); if (false && count($drives) > 0 && !is_dir('/media/pts-auto-mount') && is_writable('/media/')) { $last_drive = array_pop($drives); echo PHP_EOL . 'Attempting to auto-mount drive: ' . $last_drive . PHP_EOL; mkdir('/media/pts-auto-mount'); exec('mount ' . $last_drive . ' /media/pts-auto-mount'); putenv('PTS_TEST_INSTALL_ROOT_PATH=/media/pts-auto-mount/'); } // Auto save results $test_results_name = phodevi::read_property('motherboard', 'serial-number'); if ($test_results_name == null) { $test_results_name = phodevi::read_name('motherboard'); } if ($test_results_name == null) { $test_results_name = phodevi::read_property('system', 'vendor-identifier'); } putenv('TEST_RESULTS_NAME=' . str_replace(' ', null, $test_results_name)); putenv('TEST_RESULTS_IDENTIFIER=' . $test_results_name); putenv('TEST_RESULTS_DESCRIPTION=Tests using ' . phodevi::read_property('system', 'operating-system') . ' on ' . date('d F Y') . ' of ' . $test_results_name . '.'); self::select_drive_mount(); } pts_openbenchmarking::refresh_repository_lists(); pts_client::$display->generic_heading('Interactive Benchmarking'); echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL; $reboot_on_exit = pts_flags::is_live_cd() && pts_client::user_home_directory() == '/root/'; do { $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition'); if ($is_moscow) { unset($options['RUN_SUITE']); // $options['SELECT_DRIVE_MOUNT'] = 'Select Disk Drive To Use For Testing'; } if (count(pts_client::saved_test_results()) > 0) { $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage'; } $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit'; $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true); switch ($response) { case 'RUN_TEST': $supported_tests = pts_openbenchmarking::available_tests(); $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true); $longest_title_length = 0; foreach ($supported_tests as $i => &$test_profile) { if ($test_profile->get_title() == null || pts_test_run_manager::test_profile_system_compatibility_check($test_profile) == false) { unset($supported_tests[$i]); continue; } if ($is_moscow && pts_test_install_request::test_files_available_locally($test_profile) == false) { // Don't show tests where files need to be downloaded unset($supported_tests[$i]); continue; } $longest_title_length = max($longest_title_length, strlen($test_profile->get_title())); } $t = array(); foreach ($supported_tests as $i => &$test_profile) { if ($test_profile instanceof pts_test_profile) { $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type()); } } $supported_tests = $t; asort($supported_tests); $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true); $tests_to_run = explode(',', $tests_to_run); pts_test_installer::standard_install($tests_to_run); $run_manager = pts_test_run_manager::standard_run($tests_to_run, pts_c::defaults_mode | pts_c::auto_mode); if ($run_manager != false) { pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true); } break; case 'RUN_SUITE': $possible_suites = pts_openbenchmarking::available_suites(); foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) { array_push($possible_suites, 'pts/' . $subsystem); } $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true); foreach (explode(',', $suites_to_run) as $suite_to_run) { pts_test_installer::standard_install($suite_to_run); pts_test_run_manager::standard_run($suite_to_run, pts_c::defaults_mode | pts_c::auto_mode); } break; case 'SELECT_DRIVE_MOUNT': self::select_drive_mount(); break; case 'RUN_SYSTEM_TEST': pts_client::$display->generic_heading('System Test'); $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark'); pts_test_installer::standard_install($system_tests); $run_manager = pts_test_run_manager::standard_run($system_tests, pts_c::defaults_mode | pts_c::auto_mode); if ($run_manager != false) { pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true); } break; case 'SHOW_INFO': pts_client::$display->generic_heading('System Software / Hardware Information'); echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL; echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL; break; case 'SHOW_SENSORS': pts_client::$display->generic_heading('Detected System Sensors'); foreach (phodevi::supported_sensors() as $sensor) { echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL; } break; case 'SET_RUN_COUNT': $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false); putenv('FORCE_TIMES_TO_RUN=' . trim($run_count)); break; case 'BACKUP_RESULTS_TO_USB': pts_client::$display->generic_heading('Backing Up Test Results'); if ($is_moscow) { $drives = pts_file_io::glob('/dev/sd*'); sort($drives); if (count($drives) > 0 && is_writable('/media/')) { $select_drive = pts_user_io::prompt_text_menu('Select Drive / Partition To Save Results', $drives); echo PHP_EOL . 'Attempting to mount: ' . $select_drive . PHP_EOL; mkdir('/media/00-results-backup'); exec('mount ' . $select_drive . ' /media/00-results-backup'); } } foreach (pts_file_io::glob('/media/*') as $media_dir) { if (!is_writable($media_dir)) { echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL; continue; } echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL; pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/'); break; } if ($is_moscow && is_dir('/media/00-results-backup')) { exec('umount /media/00-results-backup'); rmdir('/media/00-results-backup'); } break; } echo PHP_EOL . PHP_EOL; } while ($response != 'EXIT'); if ($reboot_on_exit) { if (is_dir('/media/pts-auto-mount')) { pts_file_io::delete('/media/pts-auto-mount/pts', null, true); exec('umount /media/pts-auto-mount 2>&1'); } exec('reboot'); } }