updated tests

svn path=/trunk/boinc/; revision=1115
This commit is contained in:
Eric Heien 2003-03-29 07:25:12 +00:00
parent 6601bcbb69
commit 72b6e7a74f
8 changed files with 193 additions and 148 deletions

View File

@ -1,13 +0,0 @@
<file_info>
<name><OUTFILE_0/></name>
<generated_locally/>
<upload_when_present/>
<url><UPLOAD_URL/></url>
<max_nbytes>100000</max_nbytes>
</file_info>
<result>
<file_ref>
<file_name><OUTFILE_0/></file_name>
<open_name>outfile.sah</open_name>
</file_ref>
</result>

View File

@ -1,28 +0,0 @@
#! /usr/local/bin/php
<?php
// test the seti@home client
//
// You must have done "make" in all source directories
include_once("init.inc");
check_env_vars(); // THIS IS ABSOLUTELY CRITICAL!!!
clear_db();
clear_data_dirs();
create_keys(); //added
init_client_dirs("prefs3.xml"); //"account_sah.xml");
copy_to_download_dir("work_unit.sah");
add_platform();
add_core_client(null);
add_user(null);
add_app("setiathome-3.06",null,null);
create_work("-appname setiathome-3.06 -wu_name sah_wu -wu_template sah_wu -result_template sah_result -redundancy 1 work_unit.sah");
echo "starting feeder\n";
start_feeder();
echo "started feeder\n";
run_client();
echo "ran client\n";
stop_feeder();
check_results_done();
?>

View File

@ -1,10 +0,0 @@
<file_info>
<number>0</number>
</file_info>
<workunit>
<input_file>
<file_number>0</file_number>
<open_name>work_unit.sah</open_name>
</input_file>
<command_line>work_unit.sah</command_line>
</workunit>

View File

@ -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, "<config>\n");
fputs($f, "<db_name>$this->db_name</db_name>\n");
fputs($f, "<db_passwd>$this->db_passwd</db_passwd>\n");
fputs($f, "<shmem_key>$this->shmem_key</shmem_key>\n");
fputs($f, "<key_dir>$this->key_dir</key_dir>\n");
fputs($f, "<download_url>$this->download_url</download_url>\n");
fputs($f, "<download_dir>$this->project_dir/download</download_dir>\n");
fputs($f, "<upload_url>$this->upload_url</upload_url>\n");
fputs($f, "<upload_dir>$this->project_dir/upload</upload_dir>\n");
fputs($f, "<user_name>$this->user_name</user_name>\n");
if ($this->start_assimilator) {
fputs($f, "<start>assimilator >> assimilator.out 2>&1</start>\n");
}
if ($this->start_feeder) {
fputs($f, "<start>feeder -asynch >> feeder.out 2>&1</start>\n");
}
if ($this->start_file_deleter) {
fputs($f, "<start>file_deleter -asynch >> file_deleter.out 2>&1</start>\n");
}
if ($this->start_make_work) {
$result_template_path = realpath($this->make_work_result_template);
fputs($f, "<start>make_work -asynch -result_template $result_template_path -wu_name $this->make_work_wu_template >> make_work.out 2>&1</start>\n");
}
if ($this->start_timeout_check) {
fputs($f, "<start>timeout_check -asynch >> timeout_check.out 2>&1</start>\n");
}
if ($this->start_validate) {
fputs($f, "<start>validate -asynch >> validate.out 2>&1</start>\n");
}
fputs($f, "</config>\n");
fclose($f);
$this->append_config("<config>\n" .
"<db_name>$this->db_name</db_name>\n" .
"<db_passwd>$this->db_passwd</db_passwd>\n" .
"<shmem_key>$this->shmem_key</shmem_key>\n" .
"<key_dir>$this->key_dir</key_dir>\n" .
"<download_url>$this->download_url</download_url>\n" .
"<download_dir>$this->project_dir/download</download_dir>\n" .
"<upload_url>$this->upload_url</upload_url>\n" .
"<upload_dir>$this->project_dir/upload</upload_dir>\n" .
"<user_name>$this->user_name</user_name>\n" .
"</config>\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("<start>./feeder -asynch >> feeder.out 2>&1</start>\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("<start>./timeout_check -app $app->name -nerror $nerror -ndet $ndet -nredundancy $nredundancy -asynch >> timeout_check.out 2>&1</start>\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("<start>./make_work -asynch -cushion $cushion -redundancy $redundancy -result_template $result_template_path -wu_name $work->wu_template >> make_work.out 2>&1</start>\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("<start>./validate_test -asynch -app $app->name -quorum $quorum >> validate.out 2>&1</start>\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("<start>./file_deleter -asynch >> file_deleter.out 2>&1</start>\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("<start>./assimilator -asynch -app $app->name >> assimilator.out 2>&1</start>\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, "</config>")) {
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;
}

View File

@ -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");
?>

70
test/test_backend.php Normal file
View File

@ -0,0 +1,70 @@
#! /usr/local/bin/php
<?php
// End to end test. Tests make_work, feeder, scheduling server, client,
// file_upload_handler, validator, assimilator, and file_deleter on a
// large batch of workunits. Confirms that credit is correctly granted
// and that unneeded files are deleted
include_once("test.inc");
$project = new Project;
$user = new User();
$host = new Host($user);
$app = new App("upper_case");
$app_version = new App_Version($app);
$work = new Work($app);
$work->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();
?>

View File

@ -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();

View File

@ -2,6 +2,7 @@
<?php
// This tests whether the most basic mechanisms are working
// Also whether stderr output is reported correctly
// Also tests if water levels are working correctly
include_once("test.inc");
@ -21,10 +22,16 @@
$user = new User();
$user->project_prefs = "<project_specific>\nfoobar\n</project_specific>\n";
$user->global_prefs = "<run_on_batteries/>\n<max_bytes_sec_down>400000</max_bytes_sec_down>\n";
$user->global_prefs = "<venue name=\"home\">\n".
"<work_buf_min_days>0</work_buf_min_days>\n".
"<work_buf_max_days>2</work_buf_max_days>\n".
"<run_on_batteries/>\n".
"<max_bytes_sec_down>400000</max_bytes_sec_down>\n".
"</venue>\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();