File: test-rec-taskqueue.cc

package info (click to toggle)
pdns-recursor 4.8.8-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,620 kB
  • sloc: cpp: 95,714; javascript: 20,651; sh: 4,679; makefile: 652; xml: 37
file content (47 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

#include <stdio.h>

#include "dnsname.hh"
#include "qtype.hh"
#include "taskqueue.hh"
#include "rec-taskqueue.hh"
#include "test-syncres_cc.hh"

BOOST_AUTO_TEST_SUITE(rec_taskqueue)

BOOST_AUTO_TEST_CASE(test_almostexpired_queue_no_dups)
{
  taskQueueClear();
  pushAlmostExpiredTask(DNSName("foo"), QType::AAAA, 0, Netmask());
  pushAlmostExpiredTask(DNSName("foo"), QType::AAAA, 0, Netmask());
  pushAlmostExpiredTask(DNSName("foo"), QType::A, 0, Netmask());

  BOOST_CHECK_EQUAL(getTaskSize(), 2U);
  taskQueuePop();
  taskQueuePop();
  BOOST_CHECK_EQUAL(getTaskSize(), 0U);
  // AE queue is not rate limited
  pushAlmostExpiredTask(DNSName("foo"), QType::A, 0, Netmask());
  BOOST_CHECK_EQUAL(getTaskSize(), 1U);
}

BOOST_AUTO_TEST_CASE(test_resolve_queue_rate_limit)
{
  taskQueueClear();
  pushResolveTask(DNSName("foo"), QType::AAAA, 0, 1);
  BOOST_CHECK_EQUAL(getTaskSize(), 1U);
  taskQueuePop();
  BOOST_CHECK_EQUAL(getTaskSize(), 0U);

  // Should hit rate limiting
  pushResolveTask(DNSName("foo"), QType::AAAA, 0, 1);
  BOOST_CHECK_EQUAL(getTaskSize(), 0U);

  // Should not hit rate limiting as time has passed
  pushResolveTask(DNSName("foo"), QType::AAAA, 61, 62);
  BOOST_CHECK_EQUAL(getTaskSize(), 1U);
}

BOOST_AUTO_TEST_SUITE_END()