diff --git a/doc/test.html b/doc/test.html index c0d1873a84..7886468651 100644 --- a/doc/test.html +++ b/doc/test.html @@ -48,7 +48,11 @@ The framework will create subdirectories as follows: boinc_projects/ proj1/ cgi/ - download/ + download/ /*this is where the real download directory*/ + download0/ /*these are optional, they are soft links to the + real download directory*/ + download1/ + ... html_ops/ html_user/ keys/ @@ -84,7 +88,10 @@ class Project { // represents a project function add_user($user); // add a User to project's DB function add_app($app); // add an application function add_app_version($app_version); // add an app version - function install(); // set up directories and DB + function install(optional: $echeduler_file); + //set up directories and DB. If $scheduler_file is provided, then + //there will be installed schedulers at the directories pointed by + //the schedulers function start(); // start feeder function stop(); // stop feeder function compare_file($out, $correct); // verify that a result file @@ -92,6 +99,50 @@ class Project { // represents a project function check_results($n, $result); // check that there are n results // and that they match "result" // (for all fields that are defined) + + //The functions below are used to interrupt or remove certain + //functionalities of the project for a desired time in order to be + //able to test persistance across these failures. All the + //parameters of the functions below are optional. If $time is not + //then action will be taken immediately, otherwise we sleep for + //$time seconds and then take action. $cgi_num,$download_dir_num, + //$handler_num refer to the number of the corresponding parts of + //the system to be disabled temporarily. if they are not + //the default cgi, download, and file_upload_handler respectively. + //multiple cgis can be handles with passing in a file with + //scheduler_urls to project->install. Multiple download URLS are + //handled by adding a numer in between the download_url and the + //file to be downloaded in the wu_template file of the Work class + //for example: 0/, in which + //a link from project_dir/download0/ will be added to project_dir/download + //Similiar action can be taken by modifying the result_template file + //of a Work class to handle multiple upload URLs: + //for example: 0, in which case + //file_upload_handler0 will be added to project_dir/cgi + + function delete_masterindex($time) //deletes the index.php for + //this project + function reestablish_masterindex($time) //reestablished the master + //index.php + function delete_scheduler($time,$cgi_num) + //deletes project_dir/cgi/cgi$cgi$num + function reinstall_scheduler($time,$cgi_num) + //copies the cgi program into + //project_dir/cgi/cgi$cgi$num + function delete_downloaddir($time,$download_dir_number) + //removes + //project_dir/download$download_dir_num + function reinstall_downloaddir($time,$download_dir_num) + //reestablished + //project_dir/download$download_dir_num + function remove_file_upload_handler($time,$handler_num) + //deletes + //project_dir/cgi/file_upload_handdler$handler_num + function reinstall_file_upload_handler($time, $handler_num) + //reinstalls + //project_dir/cgi/file_upload_handdler$handler_num + function kill_file_upload_hanlder() //blocks until a file_upload_handler is + //running in the system, kills it and returns } class User { // represents an account on a project @@ -104,7 +155,21 @@ class Host { // represents a (virtual) host function Host($user); function add_project($project); function install(); - function run($flags); + + //There are two run functions, one that blocks until the client + //being run by this host finishes exection: run() and then there + //run_asynch which spawns a new php process running the client + //and returns to the thread of exection of the parent php process + //the php process_id of the child. This process_id can then be + //used for a call to pcntl_waitpid() to block until the execution + //of the client. + function run($args); + function run_asynch($args); + + function get_new_client_pid($client_pid) + //returns a pid for a client process running in the system that is + //different from $client_pid. This call blocks until such process is started. + function check_file_present($project, $name); // check that a file exists } @@ -233,8 +298,12 @@ project directories html_user and html_ops. scheduler URL.
  • Create symbolic links (with the project name) from the main HTML and CGI directories to the project directory. +
  • If a $scheduler_file is provided, then the contents of this file +will be macro substituted in index.php and there will be corresponding +cgi files in project_dir/cgi : cgi, cgi0, cgi1 ... +

    Host->install() does the following:

    diff --git a/html/user/index.php b/html/user/index.php index 77095b4314..eed7d91a3b 100644 --- a/html/user/index.php +++ b/html/user/index.php @@ -38,10 +38,7 @@ and give it your account key.
  • Top teams - - diff --git a/test/test.inc b/test/test.inc index 1139f74b2f..382548f8da 100644 --- a/test/test.inc +++ b/test/test.inc @@ -136,13 +136,14 @@ class Project { // Set up the database and directory structures for a project // - function Install() { + function Install($scheduler_file = null) { $base_dir = get_env_var("BOINC_PROJECTS_DIR"); $source_dir = get_env_var("BOINC_SRC_DIR"); $cgi_url = get_env_var("BOINC_CGI_URL")."/".$this->name; $this->download_url = get_env_var("BOINC_HTML_URL")."/".$this->name."/download"; + //link download1...downloadn to download. Get this from reading the reading how many s in the template. For uploads $this->upload_url = $cgi_url."/file_upload_handler"; - $this->scheduler_url = $cgi_url."/cgi"; + $this->scheduler_url = $cgi_url."/cgi"; $this->project_dir = $base_dir."/".$this->name; $this->master_url = get_env_var("BOINC_HTML_URL")."/".$this->name."/html_user/index.php"; PassThru("rm -rf $this->project_dir"); @@ -207,11 +208,43 @@ class Project { } run_tool("add app_version -db_name $this->db_name -app_name '$app->name' -platform_name $app_version->platform_name -version $app_version->version -download_dir $this->project_dir/download -download_url $this->download_url -code_sign_keyfile $this->key_dir/code_sign_private -exec_dir $dir -exec_files $exec_name"); } + + // copy the user and administrative PHP files to the project dir, + // + PassThru("cp -f $source_dir/html_user/* $this->project_dir/html_user"); + PassThru("cp -f $source_dir/tools/country_select $this->project_dir/html_user"); + PassThru("cp -f $source_dir/html_ops/* $this->project_dir/html_ops"); // copy the server programs to the project /cgi dir, // and make a config file there // + + //Copy the sched server in the cgi directory with the cgi names given $source_dir/html_usr/schedulers.txt + if($scheduler_file == null) + { + $scheduler_file = "schedulers.txt"; + $f = fopen("$this->project_dir/html_user/schedulers.txt", "w"); + fputs($f,"".$this->scheduler_url."\n"); + fclose($f); + } + else + { + $f = fopen("$this->project_dir/html_user/$scheduler_file", "r"); + while(true) + { + $scheduler_url = fgets($f,1000); + if($scheduler_url == false) + break; + $temp = substr($scheduler_url,0,strrpos($scheduler_url,'<')); + $cgi_name = substr($temp,strrpos($temp,'/')+1,strlen($temp) - strrpos($temp,'/')); + PassThru("cp $source_dir/sched/cgi $this->project_dir/cgi/$cgi_name"); + } + + fclose($f); + } + PassThru("cp $source_dir/sched/cgi $this->project_dir/cgi/"); + //would have to be able to add more of these, copy several to cgi dir PassThru("cp $source_dir/sched/file_upload_handler $this->project_dir/cgi/"); PassThru("cp $source_dir/sched/make_work $this->project_dir/cgi/"); PassThru("cp $source_dir/sched/feeder $this->project_dir/cgi/"); @@ -231,11 +264,6 @@ class Project { fputs($f, "\n"); fclose($f); - // copy the user and administrative PHP files to the project dir, - // - PassThru("cp -f $source_dir/html_user/* $this->project_dir/html_user"); - PassThru("cp -f $source_dir/tools/country_select $this->project_dir/html_user"); - PassThru("cp -f $source_dir/html_ops/* $this->project_dir/html_ops"); // put a file with the database name and other info in each directory // @@ -248,12 +276,10 @@ class Project { PassThru("cp $this->project_dir/html_user/config.xml $this->project_dir/html_ops"); // edit "index.php" in the user directory to have - // the right scheduler URL - // - $u = str_replace("/", "\\\/", $this->scheduler_url); - $x = "sed -e s/SCHEDULER_URL/$u/ $this->project_dir/html_user/index.php > temp; mv temp $this->project_dir/html_user/index.php"; - echo "$x\n"; - PassThru($x); + // the right file as the source for scheduler_urls, default is schedulers.txt + $x = "sed -e s/FILE_NAME/$scheduler_file/ $this->project_dir/html_user/index.php > temp; mv temp $this->project_dir/html_user/index.php"; + echo "x is $x\n"; + PassThru($x); // create symbolic links to the CGI and HTML directories // @@ -274,7 +300,7 @@ class Project { } //moves the masterindex file to temp after $time seconds (if not null).This is used to test exponential backoff on the client side. - function delete_masterindex($time) + function delete_masterindex($time=null) { if($time != null) { @@ -286,7 +312,7 @@ class Project { //moves temp back to the masterindex after $time seconds(if not null). This is used to test exponential backoff on the client side. - function reestablish_masterindex($time) + function reestablish_masterindex($time=null) { if($time != null) { @@ -298,18 +324,18 @@ class Project { } //delete the cgi file for this project after $time if not null. This is used to test exponential backoff on the client side. - function delete_scheduler($time) + function delete_scheduler($time=null,$cgi_num = null) { if($time != null) { echo "\nsleeping for $time seconds"; PassThru("sleep $time"); } - PassThru("rm $this->project_dir/cgi/cgi"); + PassThru("rm $this->project_dir/cgi/cgi$cgi_num"); } //copies the cgi file back into the cgi directory.This is used to test exponential backoff on the client side. - function reinstall_scheduler($time) + function reinstall_scheduler($time=null,$cgi_num=null) { $source_dir = get_env_var("BOINC_SRC_DIR"); @@ -318,31 +344,67 @@ class Project { echo "\nsleeping for $time seconds"; PassThru("sleep $time"); } - PassThru("cp $source_dir/sched/cgi $this->project_dir/cgi/"); + PassThru("cp $source_dir/sched/cgi $this->project_dir/cgi/cgi$cgi_num"); } //moves the download directory to temp. This is used to test exponential backoff on the client side. - function delete_downloaddir($time) + function delete_downloaddir($time = null,$download_dir_number = null) { if($time != null) { echo "\nsleeping for $time seconds"; PassThru("sleep $time"); } - PassThru("mv $this->project_dir/download/ $this->project_dir/temp/"); + + PassThru("mv $this->project_dir/download$download_dir_num $this->project_dir/download_moved_$download_dir_num"); + } //reinstalls the download directory. This is used to test exponential backoff on the client side. - function reinstall_downloaddir($time) + function reinstall_downloaddir($time = null ,$download_dir_num = null) { if($time != null) { echo "\nsleeping for $time seconds"; PassThru("sleep $time"); } - PassThru("mv $this->project_dir/temp/ $this->project_dir/download/"); + PassThru("mv $this->project_dir/moved_download_dir$download_dir_num $this->project_dir/download$download_dir_num"); + } + + function remove_file_upload_handler($time = null,$handler_num = null) + { + if($time != null) + { + echo "\nsleeping for $time seconds"; + PassThru("sleep $time"); + } + PassThru("rm $this->project_dir/cgi/file_upload_handler$handler_num"); } + function reinstall_file_upload_handler($time = null,$handler_num = null) + { + $source_dir = get_env_var("BOINC_SRC_DIR"); + if($time != null) + { + echo "\nsleeping for $time seconds"; + PassThru("sleep $time"); + } + PassThru("cp $source_dir/sched/cgi $ +this->project_dir/cgi/file_upload_handler$handler_num"); + } + + //blocks until a file_upload_handler is running in the system, kills it and returns + function kill_file_upload_hanlder() + { + while(true) + { + $pid = exec("pgrep -n file_up"); + if($pid != null) + break; + } + PassThru("kill -9 $pid"); + } + function start_feeder(){ PassThru("cd $this->project_dir/cgi; ./feeder -asynch > feeder_out"); } @@ -510,15 +572,16 @@ class Host { $exec_name = sprintf("boinc_%s.%s_%s", get_env_var("BOINC_MAJOR_VERSION"), get_env_var("BOINC_MINOR_VERSION"), $platform); PassThru("cd $this->host_dir; $source_dir/client/$exec_name $args > client.out"); exit(0); - } + } } - //returns a pid for a boinc process running in the system that is different from $boinc_pid. This call blocks until such process is started. - function get_new_boincpid($boinc_pid) + + //returns a pid for a boinc process running in the system that is different from $client_pid. This call blocks until such process is started. + function get_new_client_pid($client_pid) { while(true) { $pid = exec("pgrep -n boinc"); - if(($pid != null) && ($pid != $boinc_pid)) + if(($pid != null) && ($pid != $client_pid)) return $pid; } @@ -562,7 +625,7 @@ class Work { var $rsc_fpops; var $rsc_disk; var $delay_bound; - + function Work($app) { $this->app = $app; $this->input_files = array(); @@ -578,7 +641,51 @@ class Work { $x = $this->input_files[$i]; PassThru("cp $x $project->project_dir/download"); } - $cmd = "create_work -db_name $project->db_name -download_dir $project->project_dir/download -upload_url $project->upload_url -download_url $project->download_url/ -keyfile $project->key_dir/upload_private -appname $app->name -rsc_iops $this->rcs_iops -rsc_fpops $this->rsc_fpops -rsc_disk $this->rsc_disk -wu_template $this->wu_template -result_template $this->result_template -nresults $this->nresults -wu_name $this->wu_template -delay_bound $this->delay_bound"; + + $f = fopen($this->wu_template,"r"); + while(true) + { + $temp = fgets($f,1000); + if($temp == false) + break; + $temp = stristr($temp,""); + if($temp) + { + $pos = strpos($temp,">"); + if($temp[$pos + 2] != "<") + { + $append = substr($temp, $pos+1,strpos($temp,"/<") - $pos -1); + } + PassThru("ln -s $project->project_dir/download $project->project_dir/download$append"); + } + } + + fclose($f); + $source_dir = get_env_var("BOINC_SRC_DIR"); + $append = null; + $f = fopen($this->result_template,"r"); + while(true) + { + $temp = fgets($f,1000); + if($temp == false) + break; + $temp = stristr($temp,""); + if($temp) + { + $upload_url = strip_tags($temp,""); + + if(strip_tags($upload_url)) + { + $append = strip_tags($upload_url); + + PassThru("cp $source_dir/sched/file_upload_handler $project->project_dir/cgi/file_upload_handler$append"); + + } + } + } + fclose($f); + + $cmd = "create_work -db_name $project->db_name -download_dir $project->project_dir/download -upload_url $project->upload_url -download_url $project->download_url -keyfile $project->key_dir/upload_private -appname $app->name -rsc_iops $this->rcs_iops -rsc_fpops $this->rsc_fpops -rsc_disk $this->rsc_disk -wu_template $this->wu_template -result_template $this->result_template -nresults $this->nresults -wu_name $this->wu_template -delay_bound $this->delay_bound"; for ($i=0; $iinput_files); $i++) { $x = $this->input_files[$i]; $cmd = $cmd." ".$x; diff --git a/test/test_pers.php b/test/test_pers.php index 8b4105fe40..492a1c5aaf 100644 --- a/test/test_pers.php +++ b/test/test_pers.php @@ -39,13 +39,12 @@ $path= "$host->host_dir/projects/$enc_url/upper_case"; print "\n the path for checking download is :".$path; $pid = $host->run_asynch("-exit_when_idle -limit_transfer_rate 2048"); -$boinc_pid = $host->get_new_boincpid(null); +$client_pid = $host->get_new_client_pid(null); assert($pid != -1); -echo "\n boinc_pid is $boinc_pid"; $first = 0; $file_size = 0; - //Check download + while(1) { @@ -65,11 +64,11 @@ while(1) if(($temp > 40000) && ($first ==0)) { print "\n stopping and rerunning the client"; - echo "\n now killing boinc_pid : $boinc_pid"; - $host->kill($boinc_pid, null); + echo "\n now killing client_pid : $client_pid"; + $host->kill($client_pid, null); $host->run_asynch("-exit_when_idle -limit_transfer_rate 2048"); - $boinc_pid = $host->get_new_boincpid($boinc_pid); - echo "\nNow executing : $boinc_pid"; + $client_pid = $host->get_new_client_pid($client_pid); + echo "\nNow executing : $client_pid"; $first++; } @@ -116,11 +115,11 @@ while(1) if(($temp > 20000) && ($first ==0)) { print "\n stopping and rerunning the client"; - print "\nkilling $boinc_pid"; - $host->kill($boinc_pid,null); + print "\nkilling $client_pid"; + $host->kill($client_pid,null); $host->run_asynch("-exit_when_idle -limit_transfer_rate 2048"); - $boinc_pid = $host->get_new_boincpid($boinc_pid); - echo "\nnew boinc_pid is $boinc_pid"; + $client_pid = $host->get_new_client_pid($client_pid); + echo "\nnew client_pid is $client_pid"; $first++; } @@ -130,7 +129,7 @@ while(1) { print "\n all of the files has been uploaded"; print "\n stopping and rerunning the client"; - $host->kill($boinc_pid, null); + $host->kill($client_pid, null); $host->run("-exit_when_idle"); break; } diff --git a/test/test_sched_failure.php b/test/test_sched_failure.php index a7104b196b..60a8c4ff9b 100644 --- a/test/test_sched_failure.php +++ b/test/test_sched_failure.php @@ -39,10 +39,10 @@ $project->start_feeder(); //delete the scheduler immediately - $project->delete_scheduler(null); + $project->delete_scheduler(); $pid = $host->run_asynch("-exit_when_idle"); //reinstall scheduler after 500 seconds - $project->reinstall_scheduler(500); + $project->reinstall_scheduler(); $status = 0; //wait until the host has stopped running pcntl_waitpid($pid,$status,0); diff --git a/test/test_uc.php b/test/test_uc.php index d0361f6f74..1245ac50ed 100644 --- a/test/test_uc.php +++ b/test/test_uc.php @@ -4,7 +4,8 @@ // Also whether stderr output is reported correctly include_once("test.inc"); - +$temp = "hello"; +echo "$temp[1]"; $project = new Project; $user = new User(); $host = new Host($user);