blob: 1ca452c4cf1096226bc53bc7d95d9b8da9408871 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/messagebus/errorcode.h>
#include <vespa/messagebus/routing/retrytransienterrorspolicy.h>
#include <vespa/vespalib/testkit/testapp.h>
using namespace mbus;
TEST_SETUP(Test);
int
Test::Main()
{
TEST_INIT("retrypolicy_test");
RetryTransientErrorsPolicy policy;
for (uint32_t i = 0; i < 5; ++i) {
double delay = i / 3.0;
policy.setBaseDelay(delay);
for (uint32_t j = 0; j < 5; ++j) {
EXPECT_EQUAL((int)(j * delay), (int)policy.getRetryDelay(j));
}
for (uint32_t j = ErrorCode::NONE; j < ErrorCode::ERROR_LIMIT; ++j) {
policy.setEnabled(true);
if (j < ErrorCode::FATAL_ERROR) {
EXPECT_TRUE(policy.canRetry(j));
} else {
EXPECT_TRUE(!policy.canRetry(j));
}
policy.setEnabled(false);
EXPECT_TRUE(!policy.canRetry(j));
}
}
TEST_DONE();
}
|