]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist test: generate CDB files 10673/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 26 Aug 2021 10:27:07 +0000 (12:27 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 26 Aug 2021 11:04:31 +0000 (13:04 +0200)
regression-tests.dnsdist/kvs.cdb.1 [deleted file]
regression-tests.dnsdist/kvs.cdb.2 [deleted file]
regression-tests.dnsdist/requirements.txt
regression-tests.dnsdist/test_CDB.py

diff --git a/regression-tests.dnsdist/kvs.cdb.1 b/regression-tests.dnsdist/kvs.cdb.1
deleted file mode 100644 (file)
index 4d3ba74..0000000
Binary files a/regression-tests.dnsdist/kvs.cdb.1 and /dev/null differ
diff --git a/regression-tests.dnsdist/kvs.cdb.2 b/regression-tests.dnsdist/kvs.cdb.2
deleted file mode 100644 (file)
index abd9648..0000000
Binary files a/regression-tests.dnsdist/kvs.cdb.2 and /dev/null differ
index 99b8454c552708ce002018aaa0e8b92a95bc4d7c..afa9fa76ecd5ff7cd0ed164d6d83926cd9eb8008 100644 (file)
@@ -7,3 +7,4 @@ pysnmp>=4.3.4
 future>=0.17.1
 pycurl>=7.43.0
 lmdb>=0.95
+cdbx==0.1.2
index 89026290f25689df47cce9e6e1e34bca0019442f..2ed764ce86b08b7dfb58feee9d75486f278a7ebc 100644 (file)
@@ -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)