RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* rtb_router_leak_test.cc 00002 00003 Check that the router et al don't leak. 00004 */ 00005 00006 #define BOOST_TEST_MAIN 00007 #define BOOST_TEST_DYN_LINK 00008 00009 #include <boost/test/unit_test.hpp> 00010 #include "jml/arch/format.h" 00011 #include "rtb/simulation/simulation.h" 00012 #include "rtbkit/core/router/router.h" 00013 #include <boost/thread/thread.hpp> 00014 #include <ace/Signal.h> 00015 00016 00017 using namespace std; 00018 using namespace ML; 00019 using namespace Datacratic; 00020 using namespace RTBKIT; 00021 00022 BOOST_AUTO_TEST_CASE( test_router_simulation_dont_leak ) 00023 { 00024 int numAuctions = 200; 00025 int queriesPerSecond = 100; 00026 int maxTimeMs = 100; 00027 00028 Router router; 00029 router.initEndpoints(); 00030 string host = "localhost"; 00031 int bidPort = router.bidPort(); 00032 int backchannelPort = router.backchannelPort(); 00033 00034 Simulation sim(queriesPerSecond, maxTimeMs); 00035 00036 EventLog log(some_sqlite_file); 00037 EventFilter query = log.query().type(some_request_type).limit(numAuctions); 00038 00039 00040 sim.init(host, bidPort, backchannelPort); 00041 00042 sim.run(query); 00043 00044 //client->sleepUntilIdle(); 00045 00046 sim.shutdown(); 00047 router.shutdown(); 00048 00049 sim.stats(); 00050 00051 BOOST_CHECK_EQUAL(sim.counters["auctions_started"], numAuctions); 00052 BOOST_CHECK_EQUAL(sim.counters["auctions_finished"], numAuctions); 00053 BOOST_CHECK_GT(sim.counters["errors"], 0); 00054 }