26#include <freeradius-devel/util/retry.h>
53 TEST_CASE(
"Next retransmission is after start");
81 TEST_CASE(
"Initial bounds for RT = IRT * (1 + RAND[-0.1,+0.1])");
83 TEST_MSG(
"rt should be < IRT * 1.2 (i.e. %" PRIi64
") < (%" PRIi64
", for IRT %" PRIi64
")",
87 TEST_MSG(
"rt should be > IRT * 0.8 (i.e. %" PRIi64
") > (%" PRIi64
", for RTprev %" PRIi64
")",
115 for (i = 0; i < 4; i++) {
119 TEST_MSG(
"retry %d should be CONTINUE, got %d", i + 2, state);
132 TEST_CASE(
"Retry interval bounds RT = RTprev * (2 + RAND[-0.1,+0.1])");
134 TEST_MSG(
"rt should be < RT_prev * 2.2 (i.e. %" PRIi64
") < (%" PRIi64
", for RTprev %" PRIi64
")",
138 TEST_MSG(
"rt should be > RT * 1.8 (i.e. %" PRIi64
") > (%" PRIi64
", for RTprev %" PRIi64
")",
168 for (i = 0; i < 2; i++) {
172 TEST_MSG(
"retry %d should be CONTINUE, got %d", i + 2, state);
179 TEST_MSG(
"retry 3 should be MRC, got %d", state);
218 if (attempts >= 10)
break;
222 TEST_MSG(
"expected MRD, got %d after %d attempts", state, attempts);
246 TEST_CASE(
"First retry exceeds count, returns MRD");
276 for (i = 0; i < 8; i++) {
284 TEST_CASE(
"Retry interval grows over time (exponential backoff)");
286 TEST_MSG(
"expected interval to grow at least 2 times, grew %d times", grew);
311 for (i = 0; i < 10; i++) {
316 TEST_CASE(
"Retry interval bounds RT <= MRT * (1 + RAND[-0.1,+0.1])");
325 TEST_MSG(
"rt should be < MRT * 1.2 (i.e. %" PRIi64
") < (%" PRIi64
", for MRT %" PRIi64
")",
329 TEST_MSG(
"rt should be > MRT * 0.8 (i.e. %" PRIi64
") > (%" PRIi64
", for MRT %" PRIi64
")",
351 TEST_CASE(
"With no MRD/MRC, end defaults to start + 1 day");
354 TEST_CASE(
"Retransmissions continue normally");
static const conf_parser_t config[]
static void test_retry_mrc(void)
static void test_retry_init(void)
static void test_retry_single(void)
static void test_retry_mrd(void)
static void test_retry_mrt_cap(void)
static void test_retry_irt(void)
static void test_retry_no_limits(void)
static void test_retry_backoff(void)
static void test_retry_rt(void)
static fr_time_delta_t fr_time_delta_from_msec(int64_t msec)
static int64_t fr_time_delta_unwrap(fr_time_delta_t time)
#define fr_time_delta_lt(_a, _b)
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
#define fr_time_delta_wrap(_time)
#define fr_time_wrap(_time)
#define fr_time_eq(_a, _b)
#define fr_time_add(_a, _b)
Add a time/time delta together.
#define fr_time_gt(_a, _b)
#define fr_time_delta_gt(_a, _b)
A time delta, a difference in time measured in nanoseconds.
fr_retry_state_t fr_retry_next(fr_retry_t *r, fr_time_t now)
Initialize a retransmission counter.
void fr_retry_init(fr_retry_t *r, fr_time_t now, fr_retry_config_t const *config)
Initialize a retransmission counter.
fr_time_t start
when we started the retransmission
fr_time_delta_t rt
retransmit interval
fr_retry_state_t state
so callers can see what state it's in.
@ FR_RETRY_MRC
reached maximum retransmission count
@ FR_RETRY_MRD
reached maximum retransmission duration
uint32_t count
number of sent packets
fr_time_t end
when we will end the retransmissions
fr_time_t next
when the next timer should be set