fix test_transfer to set mixed mode to 'prefer_tcp' to avoid having it interfere with the send rate. optimize the test to run a lot faster. fix proxy to allow any protocol (fixes issue where test failed with http and https proxy). Bump the minimum rate limit to 20kB/s (from 5kB/s) in proportional mixed mode algorithm

This commit is contained in:
Arvid Norberg 2010-12-27 22:54:14 +00:00
parent 40e1bea451
commit d1124574ef
3 changed files with 171 additions and 157 deletions

View File

@ -2335,8 +2335,8 @@ namespace aux {
else
{
if (num_tcp_peers == 0) num_tcp_peers = 1;
int upload_rate = (std::max)(m_stat.upload_rate(), 5000);
int download_rate = (std::max)(m_stat.download_rate(), 5000);
int upload_rate = (std::max)(m_stat.upload_rate(), 20000);
int download_rate = (std::max)(m_stat.download_rate(), 20000);
if (m_upload_channel.throttle()) upload_rate = m_upload_channel.throttle();
if (m_download_channel.throttle()) download_rate = m_download_channel.throttle();

View File

@ -180,7 +180,7 @@ void start_proxy(int port, int proxy_type)
char buf[512];
// we need to echo n since dg will ask us to configure it
snprintf(buf, sizeof(buf), "echo n | delegated -P%d ADMIN=test@test.com "
"PERMIT=\"*:*:localhost\" REMITTABLE=+,https RELAY=proxy,delegate "
"PERMIT=\"*:*:localhost\" REMITTABLE=\"*\" RELAY=proxy,delegate "
"SERVER=%s %s"
, port, type, auth);
@ -188,7 +188,7 @@ void start_proxy(int port, int proxy_type)
system(buf);
fprintf(stderr, "launched\n");
// apparently delegate takes a while to open its listen port
test_sleep(1000);
test_sleep(500);
}
using namespace libtorrent;
@ -263,6 +263,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
session_settings sess_set = ses1->settings();
if (ses3) sess_set.allow_multiple_connections_per_ip = true;
sess_set.ignore_limits_on_local_network = false;
sess_set.mixed_mode_algorithm = session_settings::prefer_tcp;
sess_set.max_failcount = 1;
ses1->set_settings(sess_set);
ses2->set_settings(sess_set);

View File

@ -230,7 +230,7 @@ bool on_alert(alert* a)
return false;
}
void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowed_fast = false)
void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowed_fast = false, bool test_priorities = false)
{
char const* test_name[] = {"no", "SOCKS4", "SOCKS5", "SOCKS5 password", "HTTP", "HTTP password"};
@ -303,6 +303,8 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file, 16 * 1024, 13, false);
file.close();
if (test_priorities)
{
int udp_tracker_port = start_tracker();
int tracker_port = start_web_server();
@ -312,6 +314,7 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
snprintf(tracker_url, sizeof(tracker_url), "udp://127.0.0.1:%d/announce", udp_tracker_port);
t->add_tracker(tracker_url);
}
add_torrent_params addp(&test_storage_constructor);
addp.paused = false;
@ -324,14 +327,17 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0
, true, false, true, "_transfer", 8 * 1024, &t, false, test_disk_full?&addp:0);
// set half of the pieces to priority 0
int num_pieces = tor2.get_torrent_info().num_pieces();
std::vector<int> priorities(num_pieces, 1);
if (test_priorities)
{
// set half of the pieces to priority 0
std::fill(priorities.begin(), priorities.begin() + (num_pieces / 2), 0);
tor2.prioritize_pieces(priorities);
std::cerr << "setting priorities: ";
std::copy(priorities.begin(), priorities.end(), std::ostream_iterator<int>(std::cerr, ", "));
std::cerr << std::endl;
}
// ses1.set_alert_dispatch(&print_alert);
@ -403,11 +409,14 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
test_sleep(100);
}
if (test_priorities)
{
// 1 announce per tracker to start
TEST_CHECK(tracker_responses >= 2);
TEST_CHECK(!tor2.status().is_seeding);
TEST_CHECK(tor2.status().is_finished);
if (tor2.status().is_finished)
std::cerr << "torrent is finished (50% complete)" << std::endl;
else return;
@ -432,7 +441,7 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
{
print_alerts(ses2, "ses2");
torrent_status st2 = tor2.status();
// std::cerr << "\033[0m" << int(st2.progress * 100) << "% " << std::endl;
// std::cerr << "\033[0m" << int(st2.progress * 100) << "% " << std::endl;
TEST_CHECK(st2.state == torrent_status::finished);
test_sleep(100);
}
@ -556,11 +565,15 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
test_sleep(100);
}
}
TEST_CHECK(tor2.status().is_seeding);
if (test_priorities)
{
stop_tracker();
stop_web_server();
}
if (proxy_type) stop_proxy(proxy_port);
}
@ -578,10 +591,10 @@ int test_main()
test_transfer(i);
// test with a (simulated) full disk
test_transfer(0, true);
test_transfer(0, true, true);
// test allowed fast
test_transfer(0, false, true);
test_transfer(0, false, true, true);
error_code ec;
remove_all("./tmp1_transfer", ec);