本文整理汇总了PHP中pts_client::release_lock方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::release_lock方法的具体用法?PHP pts_client::release_lock怎么用?PHP pts_client::release_lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_client
的用法示例。
在下文中一共展示了pts_client::release_lock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: standard_install
public static function standard_install($items_to_install, $force_install = false, $no_prompts = false, $skip_tests_with_missing_dependencies = false)
{
// Refresh the pts_client::$display in case we need to run in debug mode
if (pts_client::$display == false || !pts_client::$display instanceof pts_websocket_display_mode) {
pts_client::init_display_mode();
}
// Create a lock
$lock_path = pts_client::temporary_directory() . '/phoronix-test-suite.active';
pts_client::create_lock($lock_path);
// Get the test profiles
$unknown_tests = array();
$test_profiles = pts_types::identifiers_to_test_profile_objects($items_to_install, true, true, $unknown_tests);
// Any external dependencies?
pts_external_dependencies::install_dependencies($test_profiles, $no_prompts, $skip_tests_with_missing_dependencies);
// Install tests
if (!is_writable(pts_client::test_install_root_path())) {
trigger_error('The test installation directory is not writable.' . PHP_EOL . 'Location: ' . pts_client::test_install_root_path(), E_USER_ERROR);
return false;
}
pts_test_installer::start_install($test_profiles, $unknown_tests, $force_install, $no_prompts);
pts_client::release_lock($lock_path);
return $test_profiles;
}
示例2: run_test
public static function run_test(&$test_run_manager, &$test_run_request)
{
$test_identifier = $test_run_request->test_profile->get_identifier();
$extra_arguments = $test_run_request->get_arguments();
$arguments_description = $test_run_request->get_arguments_description();
$full_output = pts_config::read_bool_config('PhoronixTestSuite/Options/General/FullOutput', 'FALSE');
// Do the actual test running process
$test_directory = $test_run_request->test_profile->get_install_dir();
if (!is_dir($test_directory)) {
return false;
}
$lock_file = $test_directory . 'run_lock';
if (pts_client::create_lock($lock_file) == false && $test_run_manager->is_multi_test_stress_run() == false) {
self::test_run_error($test_run_manager, $test_run_request, 'The ' . $test_identifier . ' test is already running.');
return false;
}
$active_result_buffer = new pts_test_result_buffer_active();
$test_run_request->active =& $active_result_buffer;
$execute_binary = $test_run_request->test_profile->get_test_executable();
$times_to_run = $test_run_request->test_profile->get_times_to_run();
$ignore_runs = $test_run_request->test_profile->get_runs_to_ignore();
$test_type = $test_run_request->test_profile->get_test_hardware_type();
$allow_cache_share = $test_run_request->test_profile->allow_cache_share();
$min_length = $test_run_request->test_profile->get_min_length();
$max_length = $test_run_request->test_profile->get_max_length();
if ($test_run_request->test_profile->get_environment_testing_size() > 1 && ceil(disk_free_space($test_directory) / 1048576) < $test_run_request->test_profile->get_environment_testing_size()) {
// Ensure enough space is available on disk during testing process
self::test_run_error($test_run_manager, $test_run_request, 'There is not enough space (at ' . $test_directory . ') for this test to run.');
pts_client::release_lock($lock_file);
return false;
}
$to_execute = $test_run_request->test_profile->get_test_executable_dir();
$pts_test_arguments = trim($test_run_request->test_profile->get_default_arguments() . ' ' . str_replace($test_run_request->test_profile->get_default_arguments(), '', $extra_arguments) . ' ' . $test_run_request->test_profile->get_default_post_arguments());
$extra_runtime_variables = pts_tests::extra_environmental_variables($test_run_request->test_profile);
// Start
$cache_share_pt2so = $test_directory . 'cache-share-' . PTS_INIT_TIME . '.pt2so';
$cache_share_present = $allow_cache_share && is_file($cache_share_pt2so);
$test_run_request->set_used_arguments_description($arguments_description);
pts_module_manager::module_process('__pre_test_run', $test_run_request);
$time_test_start = time();
pts_client::$display->test_run_start($test_run_manager, $test_run_request);
if (!$cache_share_present) {
$pre_output = pts_tests::call_test_script($test_run_request->test_profile, 'pre', 'Running Pre-Test Script', $pts_test_arguments, $extra_runtime_variables, true);
if ($pre_output != null && (pts_client::is_debug_mode() || $full_output)) {
pts_client::$display->test_run_instance_output($pre_output);
}
if (is_file($test_directory . 'pre-test-exit-status')) {
// If the pre script writes its exit status to ~/pre-test-exit-status, if it's non-zero the test run failed
$exit_status = pts_file_io::file_get_contents($test_directory . 'pre-test-exit-status');
unlink($test_directory . 'pre-test-exit-status');
if ($exit_status != 0) {
self::test_run_instance_error($test_run_manager, $test_run_request, 'The pre run script exited with a non-zero exit status.' . PHP_EOL);
self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');
return false;
}
}
}
pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_pre_run_message());
$runtime_identifier = time();
$execute_binary_prepend = '';
if ($test_run_request->exec_binary_prepend != null) {
$execute_binary_prepend = $test_run_request->exec_binary_prepend;
}
if (!$cache_share_present && $test_run_request->test_profile->is_root_required()) {
if (phodevi::is_root() == false) {
pts_client::$display->test_run_error('This test must be run as the root / administrator account.');
}
$execute_binary_prepend .= ' ' . PTS_CORE_STATIC_PATH . 'root-access.sh ';
}
if ($allow_cache_share && !is_file($cache_share_pt2so)) {
$cache_share = new pts_storage_object(false, false);
}
if ($test_run_manager->get_results_identifier() != null && $test_run_manager->get_file_name() != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveTestLogs', 'FALSE')) {
$backup_test_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/test-logs/active/' . $test_run_manager->get_results_identifier() . '/';
pts_file_io::delete($backup_test_log_dir);
pts_file_io::mkdir($backup_test_log_dir, 0777, true);
} else {
$backup_test_log_dir = false;
}
for ($i = 0, $abort_testing = false, $time_test_start_actual = time(), $defined_times_to_run = $times_to_run; $i < $times_to_run && $i < 256 && !$abort_testing; $i++) {
pts_client::$display->test_run_instance_header($test_run_request);
$test_log_file = $test_directory . basename($test_identifier) . '-' . $runtime_identifier . '-' . ($i + 1) . '.log';
$is_expected_last_run = $i == $times_to_run - 1;
$test_extra_runtime_variables = array_merge($extra_runtime_variables, array('LOG_FILE' => $test_log_file, 'DISPLAY' => getenv('DISPLAY'), 'PATH' => getenv('PATH')));
$restored_from_cache = false;
if ($cache_share_present) {
$cache_share = pts_storage_object::recover_from_file($cache_share_pt2so);
if ($cache_share) {
$test_result = $cache_share->read_object('test_results_output_' . $i);
$test_extra_runtime_variables['LOG_FILE'] = $cache_share->read_object('log_file_location_' . $i);
if ($test_extra_runtime_variables['LOG_FILE'] != null) {
file_put_contents($test_extra_runtime_variables['LOG_FILE'], $cache_share->read_object('log_file_' . $i));
$test_run_time = 0;
// This wouldn't be used for a cache share since it would always be the same, but declare the value so the variable is at least initialized
$restored_from_cache = true;
}
}
unset($cache_share);
}
if ($restored_from_cache == false) {
//.........这里部分代码省略.........
示例3: call_test_runs
public function call_test_runs()
{
// Create a lock
$lock_path = pts_client::temporary_directory() . '/phoronix-test-suite.active';
pts_client::create_lock($lock_path);
if ($this->pre_run_message != null) {
pts_client::$display->display_interrupt_message($this->pre_run_message);
}
// Hook into the module framework
self::$test_run_process_active = true;
pts_module_manager::module_process('__pre_run_process', $this);
pts_file_io::unlink(PTS_USER_PATH . 'halt-testing');
pts_file_io::unlink(PTS_USER_PATH . 'skip-test');
$continue_test_flag = true;
$tests_to_run_count = $this->get_test_count();
pts_client::$display->test_run_process_start($this);
$total_loop_count = ($t = pts_client::read_env('TOTAL_LOOP_COUNT')) && is_numeric($t) && $t > 0 ? $t : 1;
$total_loop_time = ($t = pts_client::read_env('TOTAL_LOOP_TIME')) && is_numeric($t) && $t > 9 ? $t * 60 : -1;
$loop_end_time = $total_loop_time != -1 ? time() + $total_loop_time : false;
$this->test_run_count = $tests_to_run_count * $total_loop_count;
for ($loop = 1; $loop <= $total_loop_count && $continue_test_flag; $loop++) {
for ($i = 0; $i < $tests_to_run_count && $continue_test_flag; $i++) {
$this->test_run_pos = $i;
$continue_test_flag = $this->process_test_run_request($i);
if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/RemoveTestInstallOnCompletion', 'FALSE')) {
// Remove the installed test if it's no longer needed in this run queue
$this_test_profile_identifier = $this->get_test_to_run($this->test_run_pos)->test_profile->get_identifier();
$still_in_queue = false;
for ($j = $this->test_run_pos + 1; $j < $tests_to_run_count && $still_in_queue == false; $j++) {
if ($this->get_test_to_run($j)->test_profile->get_identifier() == $this_test_profile_identifier) {
$still_in_queue = true;
}
}
if ($still_in_queue == false) {
pts_client::remove_installed_test($this->get_test_to_run($this->test_run_pos)->test_profile);
}
}
if ($loop_end_time) {
if (time() > $loop_end_time) {
$continue_test_flag = false;
} else {
if ($this->test_run_count == $i + 1) {
// There's still time remaining so increase the run count....
$this->test_run_count += $tests_to_run_count;
}
}
}
}
}
pts_file_io::unlink(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/active.xml');
foreach ($this->tests_to_run as &$run_request) {
// Remove cache shares
foreach (pts_file_io::glob($run_request->test_profile->get_install_dir() . 'cache-share-*.pt2so') as $cache_share_file) {
unlink($cache_share_file);
}
}
if ($this->post_run_message != null) {
pts_client::$display->display_interrupt_message($this->post_run_message);
}
self::$test_run_process_active = -1;
pts_module_manager::module_process('__post_run_process', $this);
pts_client::release_lock($lock_path);
// Report any tests that failed to properly run
if (pts_client::is_debug_mode() || $this->get_test_count() > 3) {
if (count($this->failed_tests_to_run) > 0) {
echo PHP_EOL . PHP_EOL . 'The following tests failed to properly run:' . PHP_EOL . PHP_EOL;
foreach ($this->failed_tests_to_run as &$run_request) {
echo "\t- " . $run_request->test_profile->get_identifier() . ($run_request->get_arguments_description() != null ? ': ' . $run_request->get_arguments_description() : null) . PHP_EOL;
}
echo PHP_EOL;
}
}
}
示例4: pts_define
if ($replaced == false) {
// Show help command, since there are no valid commands
$sent_command = 'help';
}
}
pts_define('PTS_USER_LOCK', function_exists('posix_getpid') ? PTS_USER_PATH . 'run-lock-' . posix_getpid() : tempnam(PTS_USER_PATH, 'run-lock-'));
if (QUICK_START == false) {
if (pts_client::create_lock(PTS_USER_LOCK) == false) {
//trigger_error('It appears that the Phoronix Test Suite is already running.' . PHP_EOL . 'For proper results, only run one instance at a time.', E_USER_WARNING);
}
register_shutdown_function(array('pts_client', 'process_shutdown_tasks'));
//pcntl_signal(SIGTERM, array('pts_client', 'exit_client'));
if (pts_client::read_env('PTS_IGNORE_MODULES') == false) {
pts_client::module_framework_init();
// Initialize the PTS module system
}
}
// Read passed arguments
for ($i = 2; $i < $argc && isset($argv[$i]); $i++) {
$pass_args[] = $argv[$i];
}
if (QUICK_START == false) {
pts_client::user_agreement_check($sent_command);
// OpenBenchmarking.org
pts_openbenchmarking::refresh_repository_lists();
}
pts_client::execute_command($sent_command, $pass_args);
// Run command
if (QUICK_START == false) {
pts_client::release_lock(PTS_USER_LOCK);
}
示例5: run_connection
//.........这里部分代码省略.........
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');
}
示例6: user_system_process
//.........这里部分代码省略.........
$communication_attempts = 0;
}
$communication_attempts++;
}
echo ' [' . $response . ']' . PHP_EOL;
switch ($response) {
case M_PHOROMATIC_RESPONSE_RUN_TEST:
$test_flags = pts_c::auto_mode | pts_c::recovery_mode;
do {
$suite_identifier = 'phoromatic-' . rand(1000, 9999);
} while (is_file(PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml'));
file_put_contents(PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml', $server_response);
$phoromatic_schedule_id = $xml_parser->getXMLValue(M_PHOROMATIC_ID);
$phoromatic_results_identifier = $xml_parser->getXMLValue(M_PHOROMATIC_SYS_NAME);
$phoromatic_trigger = $xml_parser->getXMLValue(M_PHOROMATIC_TRIGGER);
if (pts_strings::string_bool($xml_parser->getXMLValue(M_PHOROMATIC_RUN_INSTALL_COMMAND, M_PHOROMATIC_RESPONSE_TRUE))) {
phoromatic::set_user_context($xml_parser->getXMLValue(M_PHOROMATIC_SET_CONTEXT_PRE_INSTALL), $phoromatic_trigger, $phoromatic_schedule_id, 'INSTALL');
pts_client::set_test_flags($test_flags);
pts_test_installer::standard_install($suite_identifier);
}
phoromatic::set_user_context($xml_parser->getXMLValue(M_PHOROMATIC_SET_CONTEXT_PRE_RUN), $phoromatic_trigger, $phoromatic_schedule_id, 'INSTALL');
// Do the actual running
if (pts_test_run_manager::initial_checks($suite_identifier)) {
$test_run_manager = new pts_test_run_manager($test_flags);
// Load the tests to run
if ($test_run_manager->load_tests_to_run($suite_identifier)) {
if (pts_strings::string_bool($xml_parser->getXMLValue(M_PHOROMATIC_UPLOAD_TO_GLOBAL, 'FALSE'))) {
$test_run_manager->auto_upload_to_openbenchmarking();
}
// Save results?
$test_run_manager->auto_save_results(date('Y-m-d H:i:s'), $phoromatic_results_identifier, 'A Phoromatic run.');
// Run the actual tests
$test_run_manager->pre_execution_process();
$test_run_manager->call_test_runs();
$test_run_manager->post_execution_process();
// Upload to Phoromatic
pts_file_io::unlink(PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml');
// Upload test results
if (is_file(PTS_SAVE_RESULTS_PATH . $save_identifier . '/composite.xml')) {
phoromatic::update_system_status('Uploading Test Results');
$times_tried = 0;
do {
if ($times_tried > 0) {
echo PHP_EOL . 'Connection to server failed. Trying again in 60 seconds...' . PHP_EOL;
sleep(60);
}
$uploaded_test_results = phoromatic::upload_test_results($save_identifier, $phoromatic_schedule_id, $phoromatic_results_identifier, $phoromatic_trigger);
$times_tried++;
} while ($uploaded_test_results == false && $times_tried < 5);
if ($uploaded_test_results == false) {
echo 'Server connection failed. Exiting...' . PHP_EOL;
return false;
}
if (pts_strings::string_bool($xml_parser->getXMLValue(M_PHOROMATIC_ARCHIVE_RESULTS_LOCALLY, M_PHOROMATIC_RESPONSE_TRUE)) == false) {
pts_client::remove_saved_result_file($save_identifier);
}
}
}
}
break;
case M_PHOROMATIC_RESPONSE_EXIT:
echo PHP_EOL . 'Phoromatic received a remote command to exit.' . PHP_EOL;
phoromatic::update_system_status('Exiting Phoromatic');
pts_client::release_lock(PTS_USER_PATH . 'phoromatic_lock');
$exit_loop = true;
break;
case M_PHOROMATIC_RESPONSE_SERVER_MAINTENANCE:
// The Phoromatic server is down for maintenance, so don't bother updating system status and wait longer before checking back
echo PHP_EOL . 'The Phoromatic server is currently down for maintenance. Waiting for service to be restored.' . PHP_EOL;
sleep((15 - date('i') % 15) * 60);
break;
case M_PHOROMATIC_RESPONSE_SHUTDOWN:
echo PHP_EOL . 'Shutting down the system.' . PHP_EOL;
$exit_loop = true;
shell_exec('poweroff');
// Currently assuming root
break;
case M_PHOROMATIC_RESPONSE_REBOOT:
echo PHP_EOL . 'Rebooting the system.' . PHP_EOL;
$exit_loop = true;
shell_exec('reboot');
// Currently assuming root
break;
case M_PHOROMATIC_RESPONSE_IDLE:
default:
phoromatic::update_system_status('Idling, Waiting For Task');
sleep((10 - date('i') % 10) * 60);
// Check with server every 10 minutes
break;
}
if (phodevi::system_hardware(true) != $current_hw || phodevi::system_software(true) != $current_sw) {
// Hardware and/or software has changed while PTS/Phoromatic has been running, update the Phoromatic Server
echo 'Updating Installed Hardware / Software With Phoromatic Server' . PHP_EOL;
phoromatic::update_system_details();
$current_hw = phodevi::system_hardware(true);
$current_sw = phodevi::system_software(true);
}
} while ($exit_loop == false);
phoromatic::update_system_status('Offline');
}