summaryrefslogtreecommitdiff
path: root/indra/newview/tests/llhttpretrypolicy_test.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2013-04-12 17:04:48 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2013-04-12 17:04:48 -0400
commitbb237ce15f0a7bc4a3fbffc45b1e4548fd1d2f81 (patch)
treebba6ac1e44172c6f95f46802ec189a3fe47dcd44 /indra/newview/tests/llhttpretrypolicy_test.cpp
parenta8cdcfc9a893b7debf7c006022b57c389b50bf0d (diff)
SH_4061 WIP - retry policy org and tests
Diffstat (limited to 'indra/newview/tests/llhttpretrypolicy_test.cpp')
-rwxr-xr-xindra/newview/tests/llhttpretrypolicy_test.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/indra/newview/tests/llhttpretrypolicy_test.cpp b/indra/newview/tests/llhttpretrypolicy_test.cpp
index 39bd15d62f..43fc1178cc 100755
--- a/indra/newview/tests/llhttpretrypolicy_test.cpp
+++ b/indra/newview/tests/llhttpretrypolicy_test.cpp
@@ -45,8 +45,12 @@ void RetryPolicyTestObject::test<1>()
LLSD headers;
F32 wait_seconds;
+ // No retry until we've finished a try.
+ ensure("never retry 0", !never_retry.shouldRetry(wait_seconds));
+
+ // 0 retries max.
never_retry.onFailure(500,headers);
- ensure("never retry", !never_retry.shouldRetry(wait_seconds));
+ ensure("never retry 1", !never_retry.shouldRetry(wait_seconds));
}
template<> template<>
@@ -70,6 +74,9 @@ void RetryPolicyTestObject::test<3>()
bool should_retry;
U32 frac_bits = 6;
+ // No retry until we've finished a try.
+ ensure("basic_retry 0", !basic_retry.shouldRetry(wait_seconds));
+
// Starting wait 1.0
basic_retry.onFailure(500,headers);
should_retry = basic_retry.shouldRetry(wait_seconds);
@@ -224,10 +231,13 @@ void RetryPolicyTestObject::test<7>()
time_t nowseconds;
time(&nowseconds);
sd_headers[HTTP_IN_HEADER_RETRY_AFTER] = LLDate((F64)nowseconds).asRFC1123();
- LLAdaptiveRetryPolicy policy(17.0,644.0,3.0,10);
+ LLAdaptiveRetryPolicy policy(17.0,644.0,3.0,5);
F32 seconds_to_wait;
bool should_retry;
+ // No retry until we've finished a try.
+ ensure("header 0", !policy.shouldRetry(seconds_to_wait));
+
// no retry header, use default.
policy.onFailure(500,LLSD());
should_retry = policy.shouldRetry(seconds_to_wait);
@@ -246,7 +256,7 @@ void RetryPolicyTestObject::test<7>()
LLCore::HttpHeaders *headers = new LLCore::HttpHeaders();
response->setStatus(503);
response->setHeaders(headers);
- headers->mHeaders.push_back("retry-after: 600");
+ headers->mHeaders.push_back(HTTP_IN_HEADER_RETRY_AFTER + ": 600");
policy.onFailure(response);
should_retry = policy.shouldRetry(seconds_to_wait);
ensure("header 3",should_retry);
@@ -262,13 +272,24 @@ void RetryPolicyTestObject::test<7>()
response->setHeaders(headers);
LLSD sd_headers;
time(&nowseconds);
- headers->mHeaders.push_back("retry-after: " + LLDate((F64)nowseconds).asRFC1123());
+ headers->mHeaders.push_back(HTTP_IN_HEADER_RETRY_AFTER + ": " + LLDate((F64)nowseconds).asRFC1123());
policy.onFailure(response);
should_retry = policy.shouldRetry(seconds_to_wait);
- ensure("header 3",should_retry);
- ensure_approximately_equals("header 3", seconds_to_wait, 0.0F, 6);
+ ensure("header 4",should_retry);
+ ensure_approximately_equals("header 4", seconds_to_wait, 0.0F, 6);
response->release();
}
+
+ // Timeout should be clamped at max.
+ policy.onFailure(500,LLSD());
+ should_retry = policy.shouldRetry(seconds_to_wait);
+ ensure("header 5", should_retry);
+ ensure_approximately_equals("header 5", seconds_to_wait, 644.0F, 6);
+
+ // No more retries.
+ policy.onFailure(500,LLSD());
+ should_retry = policy.shouldRetry(seconds_to_wait);
+ ensure("header 6", !should_retry);
}
}