summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-01-06 13:13:42 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-01-06 13:13:42 +0000
commit0a4f43d0edeefb5bc49329b791984c7b2072d1df (patch)
tree55d0b23ea83e0a9dbd1d78458b2affb493965700 /test
parent5325ec4155ad85339a6a5717b6f4854c0bf67eb0 (diff)
2009-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Applied AdaptiveURISelector patch from Aurelien Lefebvre. This patch adds AdaptiveURISelector, which selects one of the bests mirrors for first and reserved connections. For supplementary ones, it returns mirrors which has not been tested yet, and if each of them already tested, returns mirrors which has to be tested again. Otherwise, it doesn't return anymore mirrors. * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/FtpNegotiationCommand.cc * src/HttpResponseCommand.cc * src/Makefile.am * src/Makefile.in * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/ServerStat.cc * src/ServerStat.h * src/ServerStatMan.cc * src/SpeedCalc.cc * src/URISelector.h * src/prefs.cc * src/prefs.h * test/RequestGroupManTest.cc * test/ServerStatManTest.cc * test/ServerStatTest.cc
Diffstat (limited to 'test')
-rw-r--r--test/RequestGroupManTest.cc8
-rw-r--r--test/ServerStatManTest.cc46
-rw-r--r--test/ServerStatTest.cc18
3 files changed, 59 insertions, 13 deletions
diff --git a/test/RequestGroupManTest.cc b/test/RequestGroupManTest.cc
index d654011b..6f3182b5 100644
--- a/test/RequestGroupManTest.cc
+++ b/test/RequestGroupManTest.cc
@@ -1,4 +1,9 @@
#include "RequestGroupMan.h"
+
+#include <fstream>
+
+#include <cppunit/extensions/HelperMacros.h>
+
#include "prefs.h"
#include "SingleFileDownloadContext.h"
#include "RequestGroup.h"
@@ -8,8 +13,6 @@
#include "ServerStatMan.h"
#include "ServerStat.h"
#include "File.h"
-#include <fstream>
-#include <cppunit/extensions/HelperMacros.h>
namespace aria2 {
@@ -97,6 +100,7 @@ void RequestGroupManTest::testLoadServerStat()
Option option;
RequestGroupMan rm(std::deque<SharedHandle<RequestGroup> >(), 0, &option);
+ std::cerr << "testLoadServerStat" << std::endl;
CPPUNIT_ASSERT(rm.loadServerStat(f.getPath()));
SharedHandle<ServerStat> ss_localhost = rm.findServerStat("localhost",
"http");
diff --git a/test/ServerStatManTest.cc b/test/ServerStatManTest.cc
index c000ff52..265c04e1 100644
--- a/test/ServerStatManTest.cc
+++ b/test/ServerStatManTest.cc
@@ -1,11 +1,14 @@
#include "ServerStatMan.h"
-#include "ServerStat.h"
-#include "Exception.h"
-#include "Util.h"
+
#include <iostream>
#include <sstream>
+
#include <cppunit/extensions/HelperMacros.h>
+#include "ServerStat.h"
+#include "Exception.h"
+#include "Util.h"
+
namespace aria2 {
class ServerStatManTest:public CppUnit::TestFixture {
@@ -58,6 +61,9 @@ void ServerStatManTest::testSave()
{
SharedHandle<ServerStat> localhost_http(new ServerStat("localhost", "http"));
localhost_http->setDownloadSpeed(25000);
+ localhost_http->setSingleConnectionAvgSpeed(100);
+ localhost_http->setMultiConnectionAvgSpeed(101);
+ localhost_http->setCounter(5);
localhost_http->setLastUpdated(Time(1210000000));
SharedHandle<ServerStat> localhost_ftp(new ServerStat("localhost", "ftp"));
localhost_ftp->setDownloadSpeed(30000);
@@ -77,9 +83,29 @@ void ServerStatManTest::testSave()
std::string out = ss.str();
CPPUNIT_ASSERT_EQUAL
(std::string
- ("host=localhost, protocol=ftp, dl_speed=30000, last_updated=1210000001, status=OK\n"
- "host=localhost, protocol=http, dl_speed=25000, last_updated=1210000000, status=OK\n"
- "host=mirror, protocol=http, dl_speed=0, last_updated=1210000002, status=ERROR\n"),
+ ("host=localhost, protocol=ftp,"
+ " dl_speed=30000,"
+ " sc_avg_speed=0,"
+ " mc_avg_speed=0,"
+ " last_updated=1210000001,"
+ " counter=0,"
+ " status=OK\n"
+
+ "host=localhost, protocol=http,"
+ " dl_speed=25000,"
+ " sc_avg_speed=100,"
+ " mc_avg_speed=101,"
+ " last_updated=1210000000,"
+ " counter=5,"
+ " status=OK\n"
+
+ "host=mirror, protocol=http,"
+ " dl_speed=0,"
+ " sc_avg_speed=0,"
+ " mc_avg_speed=0,"
+ " last_updated=1210000002,"
+ " counter=0,"
+ " status=ERROR\n"),
out);
}
@@ -87,7 +113,7 @@ void ServerStatManTest::testLoad()
{
std::string in =
"host=localhost, protocol=ftp, dl_speed=30000, last_updated=1210000001, status=OK\n"
- "host=localhost, protocol=http, dl_speed=25000, last_updated=1210000000, status=OK\n"
+ "host=localhost, protocol=http, dl_speed=25000, sc_avg_speed=101, mc_avg_speed=102, last_updated=1210000000, counter=6, status=OK\n"
"host=mirror, protocol=http, dl_speed=0, last_updated=1210000002, status=ERROR\n";
std::stringstream ss(in);
@@ -101,6 +127,12 @@ void ServerStatManTest::testLoad()
CPPUNIT_ASSERT_EQUAL(std::string("http"), localhost_http->getProtocol());
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(25000),
localhost_http->getDownloadSpeed());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(101),
+ localhost_http->getSingleConnectionAvgSpeed());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(102),
+ localhost_http->getMultiConnectionAvgSpeed());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6),
+ localhost_http->getCounter());
CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(1210000000),
localhost_http->getLastUpdated().getTime());
CPPUNIT_ASSERT_EQUAL(ServerStat::OK, localhost_http->getStatus());
diff --git a/test/ServerStatTest.cc b/test/ServerStatTest.cc
index bbd493b9..92903c7b 100644
--- a/test/ServerStatTest.cc
+++ b/test/ServerStatTest.cc
@@ -1,10 +1,13 @@
#include "ServerStat.h"
-#include "Exception.h"
-#include "Util.h"
+
#include <iostream>
#include <sstream>
+
#include <cppunit/extensions/HelperMacros.h>
+#include "Exception.h"
+#include "Util.h"
+
namespace aria2 {
class ServerStatTest:public CppUnit::TestFixture {
@@ -46,6 +49,9 @@ void ServerStatTest::testOperatorOstream()
ServerStat localhost_http("localhost", "http");
localhost_http.setDownloadSpeed(90000);
localhost_http.setLastUpdated(Time(1000));
+ localhost_http.setSingleConnectionAvgSpeed(101);
+ localhost_http.setMultiConnectionAvgSpeed(102);
+ localhost_http.setCounter(5);
std::stringstream ss;
@@ -53,7 +59,9 @@ void ServerStatTest::testOperatorOstream()
CPPUNIT_ASSERT_EQUAL
(std::string
- ("host=localhost, protocol=http, dl_speed=90000, last_updated=1000, status=OK"),
+ ("host=localhost, protocol=http, dl_speed=90000,"
+ " sc_avg_speed=101, mc_avg_speed=102,"
+ " last_updated=1000, counter=5, status=OK"),
ss.str());
ss.str("");
@@ -67,7 +75,9 @@ void ServerStatTest::testOperatorOstream()
CPPUNIT_ASSERT_EQUAL
(std::string
- ("host=localhost, protocol=ftp, dl_speed=10000, last_updated=1210000000, status=ERROR"),
+ ("host=localhost, protocol=ftp, dl_speed=10000,"
+ " sc_avg_speed=0, mc_avg_speed=0,"
+ " last_updated=1210000000, counter=0, status=ERROR"),
ss.str());
}