From 583c5c5d7b97dc609aa09efefaeb56c5c53a6472 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Thu, 26 Aug 2021 12:27:07 +0200 Subject: [PATCH] dnsdist test: generate CDB files --- regression-tests.dnsdist/kvs.cdb.1 | Bin 2390 -> 0 bytes regression-tests.dnsdist/kvs.cdb.2 | Bin 2390 -> 0 bytes regression-tests.dnsdist/requirements.txt | 1 + regression-tests.dnsdist/test_CDB.py | 19 ++++++++++++++----- 4 files changed, 15 insertions(+), 5 deletions(-) delete mode 100644 regression-tests.dnsdist/kvs.cdb.1 delete mode 100644 regression-tests.dnsdist/kvs.cdb.2 diff --git a/regression-tests.dnsdist/kvs.cdb.1 b/regression-tests.dnsdist/kvs.cdb.1 deleted file mode 100644 index 4d3ba74a9e5e14ce8520a0aaf15c65a5fe99c46a..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc-jL100001 literal 2390 zc-j-=WB>!PVN5dtX*DQ+lpdu=>5)N$^1T_9k4%Ha-JtxDOoPH949Xv+M<&ez#M(ey z&%nS~l95@g07NAjsS0I@Ii;xz`DtKIaeir0a;idNN=i{`F;G4+T@I*435Zz>^AdAY znUhnJSW8liONu!P^2<|;Qu2zKlk;;Ka2g2K1u{n-XofNnvlW-7rDax-Y!E~n$Rs7G zNrdghZCGk@eqIVl2?G?!TsNCz&cOf&v*oL57=ZkFht_VYM-qpD{q5%)PXfgOe^Q^? diff --git a/regression-tests.dnsdist/kvs.cdb.2 b/regression-tests.dnsdist/kvs.cdb.2 deleted file mode 100644 index abd9648bb7d99ee888610e85a723387a2f40d1d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc-jL100001 literal 2390 zc-j-=WB>!PVN5dtX*DQ+lpdu=>ET6#^0yh3PYexG?*`?MWEvC>VNm`kJu+z)Al3%r zdSG%W$;d2L0HTtNRE4s{oYGW<{4_A9IKQ+gIaMJsC8a2}7$~2ZE(g@21jMX`d5O8H z%*iQ9tR<<%CB+;C`Q@oaDS5@r$@#eqI1L2r0+}NZG(#DP*@{ck(lRSZHVC2(WReop zB*J#$HY_zcKQ9HOgaHa=4.3.4 future>=0.17.1 pycurl>=7.43.0 lmdb>=0.95 +cdbx==0.1.2 diff --git a/regression-tests.dnsdist/test_CDB.py b/regression-tests.dnsdist/test_CDB.py index 89026290f2..2ed764ce86 100644 --- a/regression-tests.dnsdist/test_CDB.py +++ b/regression-tests.dnsdist/test_CDB.py @@ -1,12 +1,21 @@ #!/usr/bin/env python +import cdbx import unittest import dns import os -import shutil import socket import time from dnsdisttests import DNSDistTest +def writeCDB(fname, variant=1): + cdb = cdbx.CDB.make(fname+'.tmp') + cdb.add(socket.inet_aton(f'127.0.0.{variant}'), b'this is the value of the source address tag') + cdb.add(b'\x05qname\x03cdb\x05tests\x08powerdns\x03com\x00', b'this is the value of the qname tag') + cdb.add(b'\x06suffix\x03cdb\x05tests\x08powerdns\x03com\x00', b'this is the value of the suffix tag') + cdb.add(b'this is the value of the qname tag', b'this is the value of the second tag') + cdb.commit().close() + os.rename(fname+'.tmp', fname) + @unittest.skipIf('SKIP_CDB_TESTS' in os.environ, 'CDB tests are disabled') class CDBTest(DNSDistTest): @@ -53,7 +62,7 @@ class TestCDBSimple(CDBTest): @classmethod def setUpCDB(cls): - shutil.copyfile('kvs.cdb.1', cls._cdbFileName) + writeCDB(cls._cdbFileName, 1) @classmethod def setUpClass(cls): @@ -138,7 +147,7 @@ class TestCDBReload(CDBTest): @classmethod def setUpCDB(cls): - shutil.copyfile('kvs.cdb.1', cls._cdbFileName) + writeCDB(cls._cdbFileName, 1) @classmethod def setUpClass(cls): @@ -174,8 +183,8 @@ class TestCDBReload(CDBTest): self.assertTrue(receivedResponse) self.assertEqual(expectedResponse, receivedResponse) - # switch to the second DB which has no entry for 127.0.0.1 - shutil.copyfile('kvs.cdb.2', self._cdbFileName) + # write a new CDB which has no entry for 127.0.0.1 + writeCDB(self._cdbFileName, 2) # wait long enough for the CDB database to be reloaded time.sleep(self._cdbRefreshDelay + 1) -- 2.47.2