diff options
Diffstat (limited to 'indra/llcorehttp/tests')
| -rwxr-xr-x | indra/llcorehttp/tests/test_httprequest.hpp | 425 | ||||
| -rwxr-xr-x | indra/llcorehttp/tests/test_httpstatus.hpp | 24 | ||||
| -rwxr-xr-x | indra/llcorehttp/tests/test_llcorehttp_peer.py | 95 | 
3 files changed, 405 insertions, 139 deletions
| diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index f1b9c02393..2311753c65 100755 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -45,6 +45,15 @@  using namespace LLCoreInt; +// spin/sleep waiting times for client/server exchange tests +// +// These are now fairly generous to try to get around timeout +// ('reasonable time') failures during execution on a heavily- +// loaded system where the unit test is in competition with +// other programs. +static const int LOOP_SLEEP_INTERVAL(10000); +static const int LOOP_COUNT_SHORT(500);			// 5-second dwell time +static const int LOOP_COUNT_LONG(3000);			// 30-second dwell time  namespace  { @@ -305,11 +314,11 @@ void HttpRequestTestObjectType::test<3>()  		// Run the notification pump.  		int count(0); -		int limit(20); +		int limit(LOOP_COUNT_SHORT);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -320,21 +329,21 @@ void HttpRequestTestObjectType::test<3>()  		// Run the notification pump again  		count = 0; -		limit = 100; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -403,12 +412,12 @@ void HttpRequestTestObjectType::test<4>()  		// Run the notification pump.  		int count(0); -		int limit(20); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 2)  		{  			req1->update(1000000);  			req2->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 2); @@ -420,22 +429,22 @@ void HttpRequestTestObjectType::test<4>()  		// Run the notification pump again  		count = 0; -		limit = 100; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 3)  		{  			req1->update(1000000);  			req2->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 3);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -504,11 +513,11 @@ void HttpRequestTestObjectType::test<5>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_SHORT);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("NoOp notification received", mHandlerCalls == 1); @@ -580,11 +589,11 @@ void HttpRequestTestObjectType::test<6>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_SHORT);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("No notifications received", mHandlerCalls == 0); @@ -661,11 +670,11 @@ void HttpRequestTestObjectType::test<7>()  		// Run the notification pump.  		int count(0); -		int limit(50);				// With one retry, should fail quickish +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -677,21 +686,21 @@ void HttpRequestTestObjectType::test<7>()  		// Run the notification pump again  		count = 0; -		limit = 100; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -777,11 +786,11 @@ void HttpRequestTestObjectType::test<8>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -793,21 +802,21 @@ void HttpRequestTestObjectType::test<8>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -887,11 +896,11 @@ void HttpRequestTestObjectType::test<9>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -903,21 +912,21 @@ void HttpRequestTestObjectType::test<9>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -999,11 +1008,11 @@ void HttpRequestTestObjectType::test<10>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1015,21 +1024,21 @@ void HttpRequestTestObjectType::test<10>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1117,11 +1126,11 @@ void HttpRequestTestObjectType::test<11>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1133,21 +1142,21 @@ void HttpRequestTestObjectType::test<11>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1237,11 +1246,11 @@ void HttpRequestTestObjectType::test<12>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1253,21 +1262,21 @@ void HttpRequestTestObjectType::test<12>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1352,8 +1361,8 @@ void HttpRequestTestObjectType::test<13>()  		HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,  													 0U,  													 url_base, -													 0, -													 0, +													 0,	 +												 0,  													 opts,  													 NULL,  													 &handler); @@ -1365,11 +1374,11 @@ void HttpRequestTestObjectType::test<13>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1382,21 +1391,21 @@ void HttpRequestTestObjectType::test<13>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1484,11 +1493,11 @@ void HttpRequestTestObjectType::test<14>()  		// Run the notification pump.  		int count(0); -		int limit(50);				// With one retry, should fail quickish +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1500,21 +1509,21 @@ void HttpRequestTestObjectType::test<14>()  		// Run the notification pump again  		count = 0; -		limit = 100; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1607,11 +1616,11 @@ void HttpRequestTestObjectType::test<15>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1624,21 +1633,21 @@ void HttpRequestTestObjectType::test<15>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -1773,11 +1782,11 @@ void HttpRequestTestObjectType::test<16>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -1850,11 +1859,11 @@ void HttpRequestTestObjectType::test<16>()  		// Run the notification pump.  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 2); @@ -1869,21 +1878,21 @@ void HttpRequestTestObjectType::test<16>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 3)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 3);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2048,11 +2057,11 @@ void HttpRequestTestObjectType::test<17>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2067,21 +2076,21 @@ void HttpRequestTestObjectType::test<17>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2252,11 +2261,11 @@ void HttpRequestTestObjectType::test<18>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2271,21 +2280,21 @@ void HttpRequestTestObjectType::test<18>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2456,11 +2465,11 @@ void HttpRequestTestObjectType::test<19>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2474,21 +2483,21 @@ void HttpRequestTestObjectType::test<19>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2673,11 +2682,11 @@ void HttpRequestTestObjectType::test<20>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2692,21 +2701,21 @@ void HttpRequestTestObjectType::test<20>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2890,11 +2899,11 @@ void HttpRequestTestObjectType::test<21>()  		// Run the notification pump.  		int count(0); -		int limit(10); +		int limit(LOOP_COUNT_LONG);  		while (count++ < limit && mHandlerCalls < 1)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Request executed in reasonable time", count < limit);  		ensure("One handler invocation for request", mHandlerCalls == 1); @@ -2909,21 +2918,21 @@ void HttpRequestTestObjectType::test<21>()  		// Run the notification pump again  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_LONG;  		while (count++ < limit && mHandlerCalls < 2)  		{  			req->update(1000000); -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Second request executed in reasonable time", count < limit);  		ensure("Second handler invocation", mHandlerCalls == 2);  		// See that we actually shutdown the thread  		count = 0; -		limit = 10; +		limit = LOOP_COUNT_SHORT;  		while (count++ < limit && ! HttpService::isStopped())  		{ -			usleep(100000); +			usleep(LOOP_SLEEP_INTERVAL);  		}  		ensure("Thread actually stopped running", HttpService::isStopped()); @@ -2971,12 +2980,206 @@ void HttpRequestTestObjectType::test<21>()  	}  } - +// BUG-2295 Tests - Content-Range header received but no body  template <> template <>  void HttpRequestTestObjectType::test<22>()  {  	ScopedCurlInit ready; +	std::string url_base(get_base_url()); +	// std::cerr << "Base:  "  << url_base << std::endl; +	 +	set_test_name("BUG-2295"); + +	// Handler can be stack-allocated *if* there are no dangling +	// references to it after completion of this method. +	// Create before memory record as the string copy will bump numbers. +	TestHandler2 handler(this, "handler"); +		 +	// record the total amount of dynamically allocated memory +	mMemTotal = GetMemTotal(); +	mHandlerCalls = 0; + +	HttpOptions * options = NULL; +	HttpRequest * req = NULL; + +	try +	{ +		// options set +		options = new HttpOptions(); +		options->setRetries(1);			// Partial_File is retryable and can timeout in here + +		// Get singletons created +		HttpRequest::createService(); +		 +		// Start threading early so that thread memory is invariant +		// over the test. +		HttpRequest::startThread(); + +		// create a new ref counted object with an implicit reference +		req = new HttpRequest(); +		ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); + +		// ====================================== +		// Issue bug2295 GETs that will get a 206 +		// ====================================== +		mStatus = HttpStatus(206); +		static const int test_count(3); +		for (int i(0); i < test_count; ++i) +		{ +			char buffer[128]; +			sprintf(buffer, "/bug2295/%d/", i); +			HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, +														 0U, +														 url_base + buffer, +														 0, +														 25, +														 options, +														 NULL, +														 &handler); +			ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); +		} +		 +		// Run the notification pump. +		int count(0); +		int limit(LOOP_COUNT_LONG); +		while (count++ < limit && mHandlerCalls < test_count) +		{ +			req->update(1000000); +			usleep(LOOP_SLEEP_INTERVAL); +		} +		ensure("Request executed in reasonable time - ms1", count < limit); +		ensure("One handler invocation for each request - ms1", mHandlerCalls == test_count); + +		// ====================================== +		// Issue bug2295 GETs that will get a libcurl 18 (PARTIAL_FILE) +		// ====================================== +		mHandlerCalls = 0; +		mStatus = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_PARTIAL_FILE); +		static const int test2_count(1); +		for (int i(0); i < test2_count; ++i) +		{ +			char buffer[128]; +			sprintf(buffer, "/bug2295/00000012/%d/", i); +			HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, +														 0U, +														 url_base + buffer, +														 0, +														 25, +														 options, +														 NULL, +														 &handler); +			ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); +		} +		 +		// Run the notification pump. +		count = 0; +		limit = LOOP_COUNT_LONG; +		while (count++ < limit && mHandlerCalls < test2_count) +		{ +			req->update(1000000); +			usleep(LOOP_SLEEP_INTERVAL); +		} +		ensure("Request executed in reasonable time - ms2", count < limit); +		ensure("One handler invocation for each request - ms2", mHandlerCalls == test2_count); + +		// ====================================== +		// Issue bug2295 GETs that will get an llcorehttp HE_INV_CONTENT_RANGE_HDR status +		// ====================================== +		mHandlerCalls = 0; +		mStatus = HttpStatus(HttpStatus::LLCORE, HE_INV_CONTENT_RANGE_HDR); +		static const int test3_count(1); +		for (int i(0); i < test3_count; ++i) +		{ +			char buffer[128]; +			sprintf(buffer, "/bug2295/inv_cont_range/%d/", i); +			HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, +														 0U, +														 url_base + buffer, +														 0, +														 25, +														 options, +														 NULL, +														 &handler); +			ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); +		} +		 +		// Run the notification pump. +		count = 0; +		limit = LOOP_COUNT_LONG; +		while (count++ < limit && mHandlerCalls < test3_count) +		{ +			req->update(1000000); +			usleep(LOOP_SLEEP_INTERVAL); +		} +		ensure("Request executed in reasonable time - ms3", count < limit); +		ensure("One handler invocation for each request - ms3", mHandlerCalls == test3_count); + +		// ====================================== +		// Okay, request a shutdown of the servicing thread +		// ====================================== +		mStatus = HttpStatus(); +		mHandlerCalls = 0; +		HttpHandle handle = req->requestStopThread(&handler); +		ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); +	 +		// Run the notification pump again +		count = 0; +		limit = LOOP_COUNT_LONG; +		while (count++ < limit && mHandlerCalls < 1) +		{ +			req->update(1000000); +			usleep(LOOP_SLEEP_INTERVAL); +		} +		ensure("Shutdown request executed in reasonable time", count < limit); +		ensure("Shutdown handler invocation", mHandlerCalls == 1); + +		// See that we actually shutdown the thread +		count = 0; +		limit = LOOP_COUNT_SHORT; +		while (count++ < limit && ! HttpService::isStopped()) +		{ +			usleep(LOOP_SLEEP_INTERVAL); +		} +		ensure("Thread actually stopped running", HttpService::isStopped()); + +		// release options +		if (options) +		{ +			options->release(); +			options = NULL; +		} +		 +		// release the request object +		delete req; +		req = NULL; + +		// Shut down service +		HttpRequest::destroyService(); +	 +#if defined(WIN32) +		// Can only do this memory test on Windows.  On other platforms, +		// the LL logging system holds on to memory and produces what looks +		// like memory leaks... +	 +		// printf("Old mem:  %d, New mem:  %d\n", mMemTotal, GetMemTotal()); +		ensure("Memory usage back to that at entry", mMemTotal == GetMemTotal()); +#endif +	} +	catch (...) +	{ +		stop_thread(req); +		delete req; +		HttpRequest::destroyService(); +		throw; +	} +} + +template <> template <> +void HttpRequestTestObjectType::test<23>() +{ +	ScopedCurlInit ready; +  	set_test_name("HttpRequest GET 503s with 'Retry-After'");  	// This tests mainly that the code doesn't fall over if diff --git a/indra/llcorehttp/tests/test_httpstatus.hpp b/indra/llcorehttp/tests/test_httpstatus.hpp index ae8f665f8e..0b379836c9 100755 --- a/indra/llcorehttp/tests/test_httpstatus.hpp +++ b/indra/llcorehttp/tests/test_httpstatus.hpp @@ -91,9 +91,6 @@ template <> template <>  void HttpStatusTestObjectType::test<2>()  {  	set_test_name("HttpStatus memory structure"); -#if LL_WINDOWS -	skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif  	// Require that an HttpStatus object can be trivially  	// returned as a function return value in registers. @@ -106,10 +103,7 @@ void HttpStatusTestObjectType::test<2>()  template <> template <>  void HttpStatusTestObjectType::test<3>()  { -	set_test_name("HttpStatus valid error string conversion"); -#if LL_WINDOWS -	skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif +	set_test_name("HttpStatus valid status string conversion");  	HttpStatus status;  	status.mType = HttpStatus::EXT_CURL_EASY; @@ -141,10 +135,7 @@ void HttpStatusTestObjectType::test<3>()  template <> template <>  void HttpStatusTestObjectType::test<4>()  { -	set_test_name("HttpStatus invalid error string conversion"); -#if LL_WINDOWS -	skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif +	set_test_name("HttpStatus invalid status string conversion");  	HttpStatus status;  	status.mType = HttpStatus::EXT_CURL_EASY; @@ -170,9 +161,6 @@ template <> template <>  void HttpStatusTestObjectType::test<5>()  {  	set_test_name("HttpStatus equality/inequality testing"); -#if LL_WINDOWS -	skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif  	// Make certain equality/inequality tests do not pass  	// through the bool conversion.  Distinct successful @@ -193,9 +181,6 @@ template <> template <>  void HttpStatusTestObjectType::test<6>()  {  	set_test_name("HttpStatus basic HTTP status encoding"); -#if LL_WINDOWS -	skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif  	HttpStatus status;  	status.mType = 200; @@ -242,10 +227,7 @@ void HttpStatusTestObjectType::test<6>()  template <> template <>  void HttpStatusTestObjectType::test<7>()  { -	set_test_name("HttpStatus HTTP error text strings"); -#if LL_WINDOWS -	skip("MAINT-2302: This frequently (though not always) fails on Windows."); -#endif +	set_test_name("HttpStatus HTTP status text strings");  	HttpStatus status(100, HE_REPLY_ERROR);  	std::string msg(status.toString()); diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py index f6c4d1a820..04cde651c4 100755 --- a/indra/llcorehttp/tests/test_llcorehttp_peer.py +++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py @@ -35,6 +35,10 @@ import time  import select  import getopt  from threading import Thread +try: +    from cStringIO import StringIO +except ImportError: +    from StringIO import StringIO  from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler  from SocketServer import ThreadingMixIn @@ -48,7 +52,23 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler):      """This subclass of BaseHTTPRequestHandler is to receive and echo      LLSD-flavored messages sent by the C++ LLHTTPClient. -    [Merge with viewer-cat later] +    Target URLs are fairly free-form and are assembled by  +    concatinating fragments.  Currently defined fragments +    are: +    - '/reflect/'       Request headers are bounced back to caller +                        after prefixing with 'X-Reflect-' +    - '/fail/'          Body of request can contain LLSD with  +                        'reason' string and 'status' integer +                        which will become response header. +    - '/bug2295/'       206 response, no data in body: +    -- '/bug2295/0/'       "Content-Range: bytes 0-75/2983" +    -- '/bug2295/1/'       "Content-Range: bytes 0-75/*" +    -- '/bug2295/2/'       "Content-Range: bytes 0-75/2983", +                           "Content-Length: 0" +    -- '/bug2295/00000018/0/'  Generates PARTIAL_FILE (18) error in libcurl. +                           "Content-Range: bytes 0-75/2983", +                           "Content-Length: 76" +    -- '/bug2295/inv_cont_range/0/'  Generates HE_INVALID_CONTENT_RANGE error in llcorehttp.      - '/503/'           Generate 503 responses with various kinds                          of 'retry-after' headers      -- '/503/0/'            "Retry-After: 2"    @@ -58,7 +78,12 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler):      -- '/503/4/'            "Retry-After: (*#*(@*(@(")"      -- '/503/5/'            "Retry-After: aklsjflajfaklsfaklfasfklasdfklasdgahsdhgasdiogaioshdgo"      -- '/503/6/'            "Retry-After: 1 2 3 4 5 6 7 8 9 10" + +    Some combinations make no sense, there's no effort to protect +    you from that.      """ +    ignore_exceptions = (Exception,) +      def read(self):          # The following logic is adapted from the library module          # SimpleXMLRPCServer.py. @@ -98,20 +123,29 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler):      def do_GET(self, withdata=True):          # Of course, don't attempt to read data. -        self.answer(dict(reply="success", status=200, -                         reason="Your GET operation worked")) +        try: +            self.answer(dict(reply="success", status=200, +                             reason="Your GET operation worked")) +        except self.ignore_exceptions, e: +            print >> sys.stderr, "Exception during GET (ignoring): %s" % str(e)      def do_POST(self):          # Read the provided POST data.          # self.answer(self.read()) -        self.answer(dict(reply="success", status=200, -                         reason=self.read())) +        try: +            self.answer(dict(reply="success", status=200, +                             reason=self.read())) +        except self.ignore_exceptions, e: +            print >> sys.stderr, "Exception during POST (ignoring): %s" % str(e)      def do_PUT(self):          # Read the provided PUT data.          # self.answer(self.read()) -        self.answer(dict(reply="success", status=200, -                         reason=self.read())) +        try: +            self.answer(dict(reply="success", status=200, +                             reason=self.read())) +        except self.ignore_exceptions, e: +            print >> sys.stderr, "Exception during PUT (ignoring): %s" % str(e)      def answer(self, data, withdata=True):          debug("%s.answer(%s): self.path = %r", self.__class__.__name__, data, self.path) @@ -152,6 +186,41 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler):              self.end_headers()              if body:                  self.wfile.write(body) +        elif "/bug2295/" in self.path: +            # Test for https://jira.secondlife.com/browse/BUG-2295 +            # +            # Client can receive a header indicating data should +            # appear in the body without actually getting the body. +            # Library needs to defend against this case. +            # +            body = None +            if "/bug2295/0/" in self.path: +                self.send_response(206) +                self.send_header("Content-Range", "bytes 0-75/2983") +            elif "/bug2295/1/" in self.path: +                self.send_response(206) +                self.send_header("Content-Range", "bytes 0-75/*") +            elif "/bug2295/2/" in self.path: +                self.send_response(206) +                self.send_header("Content-Range", "bytes 0-75/2983") +                self.send_header("Content-Length", "0") +            elif "/bug2295/00000012/0/" in self.path: +                self.send_response(206) +                self.send_header("Content-Range", "bytes 0-75/2983") +                self.send_header("Content-Length", "76") +            elif "/bug2295/inv_cont_range/0/" in self.path: +                self.send_response(206) +                self.send_header("Content-Range", "bytes 0-75/2983") +                body = "Some text, but not enough." +            else: +                # Unknown request +                self.send_response(400) +            if "/reflect/" in self.path: +                self.reflect_headers() +            self.send_header("Content-type", "text/plain") +            self.end_headers() +            if body: +                self.wfile.write(body)          elif "fail" not in self.path:              data = data.copy()          # we're going to modify              # Ensure there's a "reply" key in data, even if there wasn't before @@ -207,6 +276,17 @@ class Server(ThreadingMixIn, HTTPServer):      # operation of freeport() absolutely depends on it being off.      allow_reuse_address = False +    # Override of BaseServer.handle_error().  Not too interested +    # in errors and the default handler emits a scary traceback +    # to stderr which annoys some.  Disable this override to get +    # default behavior which *shouldn't* cause the program to return +    # a failure status. +    def handle_error(self, request, client_address): +        print '-'*40 +        print 'Ignoring exception during processing of request from', +        print client_address +        print '-'*40 +  if __name__ == "__main__":      do_valgrind = False      path_search = False @@ -233,3 +313,4 @@ if __name__ == "__main__":          args = ["valgrind", "--log-file=./valgrind.log"] + args          path_search = True      sys.exit(run(server=Thread(name="httpd", target=httpd.serve_forever), use_path=path_search, *args)) + | 
