File: test-rec-taskqueue.cc

package info (click to toggle)
pdns-recursor 5.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,108 kB
  • sloc: cpp: 109,513; javascript: 20,651; python: 5,657; sh: 5,069; makefile: 780; ansic: 582; xml: 37
file content (50 lines) | stat: -rw-r--r-- 1,374 bytes parent folder | download | duplicates (2)
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
48
49
50
#ifndef BOOST_TEST_DYN_LINK
#define BOOST_TEST_DYN_LINK
#endif

#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, false);
  BOOST_CHECK_EQUAL(getTaskSize(), 1U);
  taskQueuePop();
  BOOST_CHECK_EQUAL(getTaskSize(), 0U);

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

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

BOOST_AUTO_TEST_SUITE_END()