From 72b6e7a74f353897b18ec6f3ea921f330f2e4c05 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Sat, 29 Mar 2003 07:25:12 +0000 Subject: [PATCH] updated tests svn path=/trunk/boinc/; revision=1115 --- test/sah_result | 13 ---- test/sah_test.php | 28 --------- test/sah_wu | 10 --- test/test.inc | 142 ++++++++++++++++++++++-------------------- test/test_1sec.php | 59 ++++++++++-------- test/test_backend.php | 70 +++++++++++++++++++++ test/test_concat.php | 3 +- test/test_uc.php | 16 ++++- 8 files changed, 193 insertions(+), 148 deletions(-) delete mode 100644 test/sah_result delete mode 100755 test/sah_test.php delete mode 100644 test/sah_wu create mode 100644 test/test_backend.php diff --git a/test/sah_result b/test/sah_result deleted file mode 100644 index 166a7ecd11..0000000000 --- a/test/sah_result +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - 100000 - - - - - outfile.sah - - diff --git a/test/sah_test.php b/test/sah_test.php deleted file mode 100755 index 1e2026eecf..0000000000 --- a/test/sah_test.php +++ /dev/null @@ -1,28 +0,0 @@ -#! /usr/local/bin/php - diff --git a/test/sah_wu b/test/sah_wu deleted file mode 100644 index adedbd1b18..0000000000 --- a/test/sah_wu +++ /dev/null @@ -1,10 +0,0 @@ - - 0 - - - - 0 - work_unit.sah - - work_unit.sah - diff --git a/test/test.inc b/test/test.inc index 71933761f5..d63221caf5 100644 --- a/test/test.inc +++ b/test/test.inc @@ -148,16 +148,8 @@ class Project { var $master_url; var $resource_share; var $source_dir; - var $start_assimilator; - var $start_feeder; - var $start_file_deleter; - var $start_make_work; - var $start_timeout_check; - var $start_validate; var $project_php_file; var $project_prefs_php_file; - var $make_work_wu_template; - var $make_work_result_template; function Project() { $this->short_name = "test"; @@ -171,12 +163,6 @@ class Project { $this->shmem_key = get_env_var("BOINC_SHMEM_KEY"); $this->resource_share = 1; $this->source_dir = get_env_var("BOINC_SRC_DIR"); - $this->start_assimilator = false; - $this->start_feeder = false; - $this->start_file_deleter = false; - $this->start_make_work = false; - $this->start_timeout_check = false; - $this->start_validate = false; } function add_user($user) { @@ -347,39 +333,17 @@ class Project { // write the server config file // - $f = fopen("$this->project_dir/cgi/.htconfig.xml", "w"); - fputs($f, "\n"); - fputs($f, "$this->db_name\n"); - fputs($f, "$this->db_passwd\n"); - fputs($f, "$this->shmem_key\n"); - fputs($f, "$this->key_dir\n"); - fputs($f, "$this->download_url\n"); - fputs($f, "$this->project_dir/download\n"); - fputs($f, "$this->upload_url\n"); - fputs($f, "$this->project_dir/upload\n"); - fputs($f, "$this->user_name\n"); - if ($this->start_assimilator) { - fputs($f, "assimilator >> assimilator.out 2>&1\n"); - } - if ($this->start_feeder) { - fputs($f, "feeder -asynch >> feeder.out 2>&1\n"); - } - if ($this->start_file_deleter) { - fputs($f, "file_deleter -asynch >> file_deleter.out 2>&1\n"); - } - if ($this->start_make_work) { - $result_template_path = realpath($this->make_work_result_template); - fputs($f, "make_work -asynch -result_template $result_template_path -wu_name $this->make_work_wu_template >> make_work.out 2>&1\n"); - } - if ($this->start_timeout_check) { - fputs($f, "timeout_check -asynch >> timeout_check.out 2>&1\n"); - } - if ($this->start_validate) { - fputs($f, "validate -asynch >> validate.out 2>&1\n"); - } - fputs($f, "\n"); - fclose($f); - + $this->append_config("\n" . + "$this->db_name\n" . + "$this->db_passwd\n" . + "$this->shmem_key\n" . + "$this->key_dir\n" . + "$this->download_url\n" . + "$this->project_dir/download\n" . + "$this->upload_url\n" . + "$this->project_dir/upload\n" . + "$this->user_name\n" . + "\n"); // put a file with the database name and other info // in each HTML directory @@ -431,6 +395,7 @@ class Project { PassThru("htpasswd -bc $this->project_dir/html_ops/.htpasswd $user $password"); } + // moves the master web page to temp // This is used to test exponential backoff on the client side. // @@ -483,53 +448,57 @@ class Project { PassThru("cp $this->source_dir/sched/file_upload_handler $this->project_dir/cgi/file_upload_handler$handler_num"); } - function start_servers(){ - PassThru("cd $this->project_dir/cgi; ./start_servers >> start_servers_out 2>&1"); + function start_servers() { + PassThru("cd $this->project_dir/cgi; ./start_servers >> start_servers.out 2>&1"); } - function start_feeder(){ - PassThru("cd $this->project_dir/cgi; ./feeder -asynch >> feeder_out 2>&1"); + function install_feeder() { + $this->append_config("./feeder -asynch >> feeder.out 2>&1\n"); } - function start_timeout_check($app, $nerror = 5,$ndet = 5, $nredundancy = 5){ - PassThru("cd $this->project_dir/cgi; ./timeout_check -app $app->name -nerror $nerror -ndet $ndet -nredundancy $nredundancy -asynch >> timeout_check_out 2>&1"); + function install_timeout_check($app, $nerror = 5,$ndet = 5, $nredundancy = 5){ + $this->append_config("./timeout_check -app $app->name -nerror $nerror -ndet $ndet -nredundancy $nredundancy -asynch >> timeout_check.out 2>&1\n"); } - function start_make_work($work){ + function install_make_work($work,$cushion,$redundancy){ $result_template_path = realpath($work->result_template); - PassThru("cd $this->project_dir/cgi; ./make_work -asynch -result_template $result_template_path -wu_name $work->wu_template >> make_work_out 2>&1"); + $this->append_config("./make_work -asynch -cushion $cushion -redundancy $redundancy -result_template $result_template_path -wu_name $work->wu_template >> make_work.out 2>&1\n"); + } + + function deinstall_make_work() { + $this->remove_config("make_work"); } // run the validator asynchronously // - function start_validate($app, $quorum) { - PassThru("cd $this->project_dir/cgi; ./validate_test -asynch -app $app->name -quorum $quorum >> validate_out 2>&1"); + function install_validate($app, $quorum) { + $this->append_config("./validate_test -asynch -app $app->name -quorum $quorum >> validate.out 2>&1\n"); } // do one pass of validation // function validate($app, $quorum) { - PassThru("cd $this->project_dir/cgi; ./validate_test -one_pass -app $app->name -quorum $quorum >> validate_out 2>&1"); + PassThru("cd $this->project_dir/cgi; ./validate_test -one_pass -app $app->name -quorum $quorum >> validate.out 2>&1"); } - function start_file_delete(){ - PassThru("cd $this->project_dir/cgi; ./file_deleter -asynch >> file_deleter_out 2>&1"); + function install_file_delete(){ + $this->append_config("./file_deleter -asynch >> file_deleter.out 2>&1\n"); } // do one pass of file_deleter // function file_delete() { - PassThru("cd $this->project_dir/cgi; ./file_deleter -one_pass >> file_deleter_out 2>&1"); + PassThru("cd $this->project_dir/cgi; ./file_deleter -one_pass >> file_deleter.out 2>&1"); } - function start_assimilator($app) { - PassThru("cd $this->project_dir/cgi; ./assimilator -asynch -app $app->name >> assimilator_out 2>&1"); + function install_assimilator($app) { + $this->append_config("./assimilator -asynch -app $app->name >> assimilator.out 2>&1\n"); } // do one pass of assimilator // function assimilate($app) { - PassThru("cd $this->project_dir/cgi; ./assimilator -one_pass -app $app->name >> assimilator_out 2>&1"); + PassThru("cd $this->project_dir/cgi; ./assimilator -one_pass -app $app->name >> assimilator.out 2>&1"); } // start collecting data for stripcharts @@ -561,6 +530,47 @@ class Project { fclose($f); } + // append the line to the config file + function append_config($line) { + touch($this->project_dir."/cgi/.htconfig.xml"); + $f_old = fopen($this->project_dir."/cgi/.htconfig.xml", "r"); + $f_new = fopen($this->project_dir."/cgi/.htconfig.tmp", "w"); + $appended = false; + while(!feof($f_old)) { + $in_line = fgets($f_old); + if (strstr($in_line, "")) { + fputs($f_new, $line); + $appended = true; + } + fputs($f_new, $in_line); + } + if (!$appended) fputs($f_new, $line); + fclose($f_old); + fclose($f_new); + rename($this->project_dir."/cgi/.htconfig.tmp", $this->project_dir."/cgi/.htconfig.xml"); + } + + // remove any line containing the pattern from the config file + function remove_config($pattern) { + touch($this->project_dir."/cgi/.htconfig.xml"); + $f_old = fopen($this->project_dir."/cgi/.htconfig.xml", "r"); + $f_new = fopen($this->project_dir."/cgi/.htconfig.tmp", "w"); + while(!feof($f_old)) { + $in_line = fgets($f_old); + if (!strstr($in_line, $pattern)) + fputs($f_new, $in_line); + } + fclose($f_old); + fclose($f_new); + rename($this->project_dir."/cgi/.htconfig.tmp", $this->project_dir."/cgi/.htconfig.xml"); + } + + // remove the stop_server trigger + // + function restart() { + unlink($this->project_dir."/cgi/stop_server"); + } + function check_results($ntarget, $result) { $n = 0; db_open($this->db_name); @@ -586,14 +596,14 @@ class Project { function num_wus_left() { db_open($this->db_name); - $result = mysql_query("select count(*) as cnt from result where state=2"); + $result = mysql_query("select count(*) as cnt from result where server_state=2"); $count = mysql_fetch_object($result); return $count->cnt; } function num_results_done() { db_open($this->db_name); - $result = mysql_query("select count(*) as cnt from result where state=4"); + $result = mysql_query("select count(*) as cnt from result where server_state=4"); $count = mysql_fetch_object($result); return $count->cnt; } diff --git a/test/test_1sec.php b/test/test_1sec.php index 57ac8a13e4..bb09e553f6 100644 --- a/test/test_1sec.php +++ b/test/test_1sec.php @@ -14,48 +14,53 @@ $app = new App("upper_case"); $app_version = new App_Version($app); - $project1->resource_share = 1; - $project2->shmem_key = "0x12344321"; - $project1->name = "Project1"; - $project1->add_user($user); - $project1->add_app($app); - $project1->add_app_version($app_version); - $project1->install(); // must install projects before adding to hosts - - $project2->resource_share = 5; - $project2->shmem_key = "0x12345678"; - $project2->name = "Project2"; - $project2->add_user($user); - $project2->add_app($app); - $project2->add_app_version($app_version); - $project2->install(); // must install projects before adding to hosts - - $host->add_project($project1); - $host->add_project($project2); - $host->install(); - - echo "adding work\n"; - $work = new Work($app); $work->wu_template = "uc_wu"; $work->result_template = "uc_result"; $work->redundancy = 5; $work->delay_bound = 60; array_push($work->input_files, "input"); + + $project1->resource_share = 1; + $project1->shmem_key = "0x12344321"; + $project1->short_name = "Project1"; + $project1->long_name = "Project1"; + $project1->add_user($user); + $project1->add_app($app); + $project1->add_app_version($app_version); + $project1->install(); // must install projects before adding to hosts + $project1->install_feeder(); + + $project2->resource_share = 5; + $project2->shmem_key = "0x12345678"; + $project2->short_name = "Project2"; + $project2->long_name = "Project2"; + $project2->add_user($user); + $project2->add_app($app); + $project2->add_app_version($app_version); + $project2->install(); // must install projects before adding to hosts + $project2->install_feeder(); + + $host->add_user($user,$project1); + $host->add_user($user,$project2); + $host->install(); + + echo "adding work\n"; + $work->install($project1); $work->install($project2); - $project1->start_feeder(); - $project2->start_feeder(); - $host->run("-exit_when_idle"); + $project1->start_servers(); + $project2->start_servers(); + $host->run("-exit_when_idle -no_time_test"); $project1->stop(); $project2->stop(); $result->state = RESULT_STATE_DONE; - $project1->check_results(2, $result); + $project1->check_results(5, $result); $project1->compare_file("uc_wu_0_0", "uc_correct_output"); $project1->compare_file("uc_wu_1_0", "uc_correct_output"); - $project2->check_results(2, $result); + $project2->check_results(5, $result); $project2->compare_file("uc_wu_0_0", "uc_correct_output"); $project2->compare_file("uc_wu_1_0", "uc_correct_output"); ?> diff --git a/test/test_backend.php b/test/test_backend.php new file mode 100644 index 0000000000..e407e8509e --- /dev/null +++ b/test/test_backend.php @@ -0,0 +1,70 @@ +#! /usr/local/bin/php +wu_template = "uc_wu"; + $work->result_template = "uc_result"; + $work->redundancy = 4; + $work->delay_bound = 86400; + array_push($work->input_files, "input"); + + $project->add_user($user); + $project->add_app($app); + $project->add_app_version($app_version); + $project->install(); // must install projects before adding to hosts + $project->install_make_work($work, 100, 5); + + $host->log_flags = "log_flags.xml"; + $host->add_user($user,$project); + $host->install(); + + echo "adding work\n"; + + $work->install($project); + + $project->start_servers(); + + // Start by generating a batch of 100 results + echo "Generating 100 results... "; + while( $project->num_wus_left() < 100 ) sleep(1); + echo "done.\n"; + + // Stop the project, deinstall make_work, and install the normal backend components + $project->stop(); + $project->deinstall_make_work(); + $project->install_assimilator($app); + $project->install_file_delete(); + $project->install_validate($app, 5); + $project->install_feeder(); + + while (($pid=exec("pgrep -n make_work")) != null) sleep(1); + + // Restart the server + $project->restart(); + $project->start_servers(); + + // Run the client until there's no more work + $host->run("-exit_when_idle -no_time_test"); + + sleep(5); + + // *** DO TESTS HERE + $result->state = RESULT_STATE_DONE; + $result->exit_status = 0; + $project->check_results(101, $result); + + // Stop the server + $project->stop(); +?> diff --git a/test/test_concat.php b/test/test_concat.php index ab94b7b980..ddd57302b5 100644 --- a/test/test_concat.php +++ b/test/test_concat.php @@ -14,6 +14,7 @@ $project->add_app($app); $project->add_app_version($app_version); $project->install(); // must install projects before adding to hosts + $project->install_feeder(); $host->add_user($user,$project); $host->install(); @@ -28,7 +29,7 @@ array_push($work->input_files, "input"); $work->install($project); - $project->start_feeder(); + $project->start_servers(); $host->run("-exit_when_idle"); $project->stop(); diff --git a/test/test_uc.php b/test/test_uc.php index ed9134082b..88a6631833 100644 --- a/test/test_uc.php +++ b/test/test_uc.php @@ -2,6 +2,7 @@ project_prefs = "\nfoobar\n\n"; - $user->global_prefs = "\n400000\n"; + $user->global_prefs = "\n". + "0\n". + "2\n". + "\n". + "400000\n". + "\n"; $project->add_user($user); $project->install(); // must install projects before adding to hosts + $project->install_feeder(); $host = new Host(); $host->log_flags = "log_flags.xml"; @@ -36,12 +43,15 @@ $work = new Work($app); $work->wu_template = "uc_wu"; $work->result_template = "uc_result"; - $work->redundancy = 2; + $work->redundancy = 10; $work->delay_bound = 2; + // Say that 1 WU takes 1 day on a ref comp + $work->rsc_fpops = 86400*1e9/2; + $work->rsc_iops = 86400*1e9/2; array_push($work->input_files, "input"); $work->install($project); - $project->start_feeder(); + $project->start_servers(); $host->run("-exit_when_idle -no_time_test"); $project->stop();