]>
Commit | Line | Data |
---|---|---|
9bf515e1 RG |
1 | #!/usr/bin/env python |
2 | import dns | |
3 | import os | |
4 | import unittest | |
5 | from dnsdisttests import DNSDistTest | |
6 | from dnsdistDynBlockTests import DynBlocksTest | |
7 | ||
8 | class EBPFTest(object): | |
9 | pass | |
10 | ||
11 | @unittest.skipUnless('ENABLE_SUDO_TESTS' in os.environ, "sudo is not available") | |
12 | class TestDynBlockEBPFQPS(DynBlocksTest): | |
13 | ||
14 | _config_template = """ | |
15 | bpf = newBPFFilter({ipv4MaxItems=10, ipv6MaxItems=10, qnamesMaxItems=10}) | |
16 | setDefaultBPFFilter(bpf) | |
17 | local dbr = dynBlockRulesGroup() | |
18 | dbr:setQueryRate(%d, %d, "Exceeded query rate", %d) | |
19 | function maintenance() | |
20 | dbr:apply() | |
21 | end | |
22 | ||
23 | -- not going to wait 60s! | |
24 | setDynBlocksPurgeInterval(1) | |
25 | ||
26 | -- exercise the manual blocking methods | |
27 | bpf:block(newCA("2001:DB8::42")) | |
28 | bpf:blockQName(newDNSName("powerdns.com."), 255) | |
29 | bpf:getStats() | |
30 | bpf:unblock(newCA("2001:DB8::42")) | |
31 | bpf:unblockQName(newDNSName("powerdns.com."), 255) | |
32 | ||
33 | newServer{address="127.0.0.1:%s"} | |
34 | webserver("127.0.0.1:%s") | |
35 | setWebserverConfig({password="%s", apiKey="%s"}) | |
36 | """ | |
37 | _config_params = ['_dynBlockQPS', '_dynBlockPeriod', '_dynBlockDuration', '_testServerPort', '_webServerPort', '_webServerBasicAuthPasswordHashed', '_webServerAPIKeyHashed'] | |
38 | _sudoMode = True | |
39 | ||
40 | def testDynBlocksQRate(self): | |
41 | """ | |
42 | Dyn Blocks: QRate | |
43 | """ | |
44 | name = 'qrate.dynblocks.tests.powerdns.com.' | |
45 | self.doTestQRate(name, ebpf=True) |