1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
#! /usr/local/bin/php
<?php
//This tests the persistent file transfers for download and upload. It interrupts them in the middle and makes sure that the filesize never decreases along interrupted transfers.
include_once("test.inc");
set_time_limit(10000000000);
$project = new Project;
$user = new User();
$host = new Host($user);
$app = new App("upper_case");
$app_version = new App_Version($app);
$project->add_user($user);
$project->add_app($app);
$project->add_app_version($app_version);
$project->install(); // must install projects before adding to hosts
$host->log_flags = "log_flags.xml";
$host->add_project($project);
$host->install();
echo "adding work\n";
$work = new Work($app);
$work->wu_template = "uc_wu";
$work->result_template = "uc_result";
$work->redundancy = 2;
array_push($work->input_files, "input");
$work->install($project);
$project->start_feeder();
//get the path for checking download
$source_dir = SRC_DIR;
$enc_url = strtr($project->master_url, "/", "_");
$enc_url = substr($enc_url,7,strlen($enc_url));
$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");
$client_pid = $host->get_new_client_pid(null);
assert($pid != -1);
$first = 0;
$file_size = 0;
//Check download
while(1)
{
if(file_exists($path))
{
$temp = filesize($path);
if($temp < $file_size)
{
echo "\nfilesize dropped, problem downloading\n";
echo "temp is $temp, file_size is $file_size\n";
break;
}
else if($temp > $file_size)
{
print "\n filesize increased, it is : ".$temp;
if(($temp > 40000) && ($first ==0))
{
print "\n stopping and rerunning the client";
echo "\n now killing client_pid : $client_pid";
$host->kill($client_pid, null);
$host->run_asynch("-exit_when_idle -limit_transfer_rate 2048");
$client_pid = $host->get_new_client_pid($client_pid);
echo "\nNow executing : $client_pid";
$first++;
}
}
$file_size = $temp;
if($file_size == filesize("$source_dir/apps/upper_case"))
{
echo "\n download test succeeded";
break;
}
}
}
$file_size = 0;
$path= "$project->project_dir/upload/uc_wu_0_0";
$first =0;
print "\nupload path is: ".$path;
echo "\n Now checking upload";
while(1)
{
// echo "\n checking upload";
if(file_exists($path))
{
// echo "\nfile exists is download";
$temp = filesize($path);
if($temp < $file_size)
{
echo "\nfilesize dropped, problem uploading\n";
echo "temp is $temp, file_size if $file_size\n";
break;
}
if($temp > $file_size)
{
print "\n filesize increased, it is : ".$temp;
if(($temp > 20000) && ($first ==0))
{
print "\n stopping and rerunning the client";
print "\nkilling $client_pid";
$host->kill($client_pid,null);
$host->run_asynch("-exit_when_idle -limit_transfer_rate 2048");
$client_pid = $host->get_new_client_pid($client_pid);
echo "\nnew client_pid is $client_pid";
$first++;
}
}
$file_size = $temp;
if($file_size == filesize("$source_dir/test/uc_correct_output"))
{
print "\n all of the files has been uploaded";
print "\n stopping and rerunning the client";
$host->kill($client_pid, null);
$host->run("-exit_when_idle");
break;
}
}
}
$project->stop();
$result->server_state = RESULT_SERVER_STATE_OVER;
$result->stderr_out = "APP: upper_case: starting, argc 1";
$result->exit_status = 0;
$project->check_results(2, $result);
$project->compare_file("uc_wu_0_0", "uc_correct_output");
$project->compare_file("uc_wu_1_0", "uc_correct_output");
?>
|