#include "dnsdist-rules.hh"
+static DNSQuestion getDQ(const DNSName* providedName = nullptr)
+{
+ static const DNSName qname("powerdns.com.");
+ static const ComboAddress lc("127.0.0.1:53");
+ static const ComboAddress rem("192.0.2.1:42");
+ static struct timespec queryRealTime;
+ static PacketBuffer packet(sizeof(dnsheader));
+
+ uint16_t qtype = QType::A;
+ uint16_t qclass = QClass::IN;
+ auto proto = dnsdist::Protocol::DoUDP;
+ gettime(&queryRealTime, true);
+
+ DNSQuestion dq(providedName ? providedName : &qname, qtype, qclass, &lc, &rem, packet, proto, &queryRealTime);
+ return dq;
+}
+
BOOST_AUTO_TEST_SUITE(dnsdistluarules_cc)
BOOST_AUTO_TEST_CASE(test_MaxQPSIPRule) {
BOOST_CHECK_EQUAL(scanned, 0U);
}
+BOOST_AUTO_TEST_CASE(test_poolOutstandingRule) {
+ auto dq = getDQ();
+
+ ServerPool sp{};
+ auto ds1 = std::make_shared<DownstreamState>(ComboAddress("192.0.2.1:53"));
+ auto ds2 = std::make_shared<DownstreamState>(ComboAddress("192.0.2.2:53"));
+
+ /* increase the outstanding count of both */
+ ds1->outstanding = 400;
+ ds2->outstanding = 30;
+
+ sp.addServer(ds1);
+ sp.addServer(ds2);
+
+ BOOST_CHECK_EQUAL(sp.poolLoad(), 400+30);
+
+ auto localPool = g_pools.getCopy();
+ addServerToPool(localPool, "test", ds1);
+ addServerToPool(localPool, "test", ds2);
+ g_pools.setState(localPool);
+
+ PoolOutstandingRule pOR1("test", 10);
+ BOOST_CHECK_EQUAL(pOR1.matches(&dq), true);
+
+ PoolOutstandingRule pOR2("test", 1000);
+ BOOST_CHECK_EQUAL(pOR2.matches(&dq), false);
+}
BOOST_AUTO_TEST_SUITE_END()