From: Remi Gacogne Date: Tue, 5 Nov 2019 10:52:57 +0000 (+0100) Subject: dnsdist: Add env toggles to disable some regression tests X-Git-Tag: auth-4.3.0-alpha1~32^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13291274b703002f661eb82b8643dc2871ead8b0;p=thirdparty%2Fpdns.git dnsdist: Add env toggles to disable some regression tests --- diff --git a/regression-tests.dnsdist/test_Basics.py b/regression-tests.dnsdist/test_Basics.py index 5dfda57d21..24cbc549f0 100644 --- a/regression-tests.dnsdist/test_Basics.py +++ b/regression-tests.dnsdist/test_Basics.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import unittest import dns import clientsubnetoption from dnsdisttests import DNSDistTest diff --git a/regression-tests.dnsdist/test_CDB.py b/regression-tests.dnsdist/test_CDB.py index dcc74e9cd3..c9b4dbe90e 100644 --- a/regression-tests.dnsdist/test_CDB.py +++ b/regression-tests.dnsdist/test_CDB.py @@ -1,11 +1,13 @@ #!/usr/bin/env python import unittest import dns +import os import shutil import socket import time from dnsdisttests import DNSDistTest +@unittest.skipIf('SKIP_CDB_TESTS' in os.environ, 'CDB tests are disabled') class CDBTest(DNSDistTest): _cdbFileName = '/tmp/test-cdb-db' diff --git a/regression-tests.dnsdist/test_DOH.py b/regression-tests.dnsdist/test_DOH.py index f23a25a37e..5f209f5d3d 100644 --- a/regression-tests.dnsdist/test_DOH.py +++ b/regression-tests.dnsdist/test_DOH.py @@ -1,6 +1,8 @@ #!/usr/bin/env python import base64 import dns +import os +import unittest import clientsubnetoption from dnsdisttests import DNSDistTest @@ -9,6 +11,7 @@ from io import BytesIO #from hyper import HTTP20Connection #from hyper.ssl_compat import SSLContext, PROTOCOL_TLSv1_2 +@unittest.skipIf('SKIP_DOH_TESTS' in os.environ, 'DNS over HTTPS tests are disabled') class DNSDistDOHTest(DNSDistTest): @classmethod @@ -107,6 +110,19 @@ class DNSDistDOHTest(DNSDistTest): cls._response_headers = response_headers.getvalue() return (receivedQuery, message) + @classmethod + def setUpClass(cls): + + # for some reason, @unittest.skipIf() is not applied to derived classes with some versions of Python + if 'SKIP_DOH_TESTS' in os.environ: + raise unittest.SkipTest('DNS over HTTPS tests are disabled') + + cls.startResponders() + cls.startDNSDist() + cls.setUpSockets() + + print("Launching tests..") + # @classmethod # def openDOHConnection(cls, port, caFile, timeout=2.0): # sslctx = SSLContext(PROTOCOL_TLSv1_2) diff --git a/regression-tests.dnsdist/test_LMDB.py b/regression-tests.dnsdist/test_LMDB.py index 7529ddd456..3056d167b4 100644 --- a/regression-tests.dnsdist/test_LMDB.py +++ b/regression-tests.dnsdist/test_LMDB.py @@ -2,9 +2,11 @@ import unittest import dns import lmdb +import os import socket from dnsdisttests import DNSDistTest +@unittest.skipIf('SKIP_LMDB_TESTS' in os.environ, 'LMDB tests are disabled') class TestLMDB(DNSDistTest): _lmdbFileName = '/tmp/test-lmdb-db' diff --git a/regression-tests.dnsdist/test_OCSP.py b/regression-tests.dnsdist/test_OCSP.py index d3a4ed3a84..5e2d5485bb 100644 --- a/regression-tests.dnsdist/test_OCSP.py +++ b/regression-tests.dnsdist/test_OCSP.py @@ -1,6 +1,8 @@ #!/usr/bin/env python import dns +import os import subprocess +import unittest from dnsdisttests import DNSDistTest class DNSDistOCSPStaplingTest(DNSDistTest): @@ -17,6 +19,7 @@ class DNSDistOCSPStaplingTest(DNSDistTest): return output[0].decode() +@unittest.skipIf('SKIP_DOH_TESTS' in os.environ, 'DNS over HTTPS tests are disabled') class TestOCSPStaplingDOH(DNSDistOCSPStaplingTest): _serverKey = 'server.key' @@ -35,6 +38,19 @@ class TestOCSPStaplingDOH(DNSDistOCSPStaplingTest): """ _config_params = ['_testServerPort', '_serverCert', '_caCert', '_caKey', '_ocspFile', '_dohServerPort', '_serverCert', '_serverKey', '_ocspFile'] + @classmethod + def setUpClass(cls): + + # for some reason, @unittest.skipIf() is not applied to derived classes with some versions of Python + if 'SKIP_DOH_TESTS' in os.environ: + raise unittest.SkipTest('DNS over HTTPS tests are disabled') + + cls.startResponders() + cls.startDNSDist() + cls.setUpSockets() + + print("Launching tests..") + def testOCSPStapling(self): """ OCSP Stapling: DOH diff --git a/regression-tests.dnsdist/test_Prometheus.py b/regression-tests.dnsdist/test_Prometheus.py index 02b015996c..621c62020a 100644 --- a/regression-tests.dnsdist/test_Prometheus.py +++ b/regression-tests.dnsdist/test_Prometheus.py @@ -1,8 +1,11 @@ #!/usr/bin/env python +import os import requests import subprocess +import unittest from dnsdisttests import DNSDistTest +@unittest.skipIf('SKIP_PROMETHEUS_TESTS' in os.environ, 'Prometheus tests are disabled') class TestPrometheus(DNSDistTest): _webTimeout = 2.0 diff --git a/regression-tests.dnsdist/test_TLSSessionResumption.py b/regression-tests.dnsdist/test_TLSSessionResumption.py index b6c40790b3..190a32af6d 100644 --- a/regression-tests.dnsdist/test_TLSSessionResumption.py +++ b/regression-tests.dnsdist/test_TLSSessionResumption.py @@ -6,6 +6,7 @@ import shutil import subprocess import tempfile import time +import unittest from dnsdisttests import DNSDistTest try: range = xrange @@ -57,6 +58,7 @@ class DNSDistTLSSessionResumptionTest(DNSDistTest): with open(outputFile, 'wb') as fp: fp.write(os.urandom(numberOfTickets * 80)) +@unittest.skipIf('SKIP_DOH_TESTS' in os.environ, 'DNS over HTTPS tests are disabled') class TestNoTLSSessionResumptionDOH(DNSDistTLSSessionResumptionTest): _serverKey = 'server.key' @@ -79,6 +81,7 @@ class TestNoTLSSessionResumptionDOH(DNSDistTLSSessionResumptionTest): self.assertFalse(self.checkSessionResumed('127.0.0.1', self._dohServerPort, self._serverName, self._caCert, '/tmp/no-session.out.doh', None, allowNoTicket=True)) self.assertFalse(self.checkSessionResumed('127.0.0.1', self._dohServerPort, self._serverName, self._caCert, '/tmp/no-session.out.doh', '/tmp/no-session.out.doh', allowNoTicket=True)) +@unittest.skipIf('SKIP_DOH_TESTS' in os.environ, 'DNS over HTTPS tests are disabled') class TestTLSSessionResumptionDOH(DNSDistTLSSessionResumptionTest): _serverKey = 'server.key' diff --git a/regression-tests.dnsdist/test_Tags.py b/regression-tests.dnsdist/test_Tags.py index 736c87bf95..9a50c2b299 100644 --- a/regression-tests.dnsdist/test_Tags.py +++ b/regression-tests.dnsdist/test_Tags.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import unittest import dns import clientsubnetoption from dnsdisttests import DNSDistTest