From: Daniel Salzman Date: Wed, 7 Nov 2018 09:54:03 +0000 (+0100) Subject: tests-extra: move maxminddb check into module check X-Git-Tag: v2.8.0~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=391d5c6e52ffe5e2da172fc6563f5cdcf9c9fc1b;p=thirdparty%2Fknot-dns.git tests-extra: move maxminddb check into module check --- diff --git a/tests-extra/tests/modules/geoip/test.py b/tests-extra/tests/modules/geoip/test.py index 47b80f3502..a9642decfa 100644 --- a/tests-extra/tests/modules/geoip/test.py +++ b/tests-extra/tests/modules/geoip/test.py @@ -5,22 +5,7 @@ from dnstest.test import Test from dnstest.module import ModGeoip from dnstest.utils import * -from subprocess import Popen, PIPE import random -import re - -def check_mmdb(): - '''Checks the server binary for the MMDB_open function''' - - try: - proc = Popen(ModGeoip._check_cmd(), stdout=PIPE, stderr=PIPE, - universal_newlines=True) - (out, err) = proc.communicate() - if re.search("MMDB_open", out): - return - raise Skip() - except: - raise Skip("libmaxminddb not detected") t = Test(address=4, stress=False) knot = t.server("knot") @@ -29,9 +14,9 @@ zone = t.zone("example.com.", storage=".") t.link(zone, knot) ModGeoip.check() -check_mmdb() -mod_geoip = ModGeoip(t.data_dir + "geo.conf", "geodb", t.data_dir + "db.mmdb", ["country/iso_code", "(id)city/geoname_id"]) +mod_geoip = ModGeoip(t.data_dir + "geo.conf", "geodb", t.data_dir + "db.mmdb", + ["country/iso_code", "(id)city/geoname_id"]) knot.add_module(zone, mod_geoip); t.start() diff --git a/tests-extra/tools/dnstest/module.py b/tests-extra/tools/dnstest/module.py index 2923c4a0c5..5a4c45b65a 100644 --- a/tests-extra/tools/dnstest/module.py +++ b/tests-extra/tools/dnstest/module.py @@ -292,7 +292,7 @@ class ModCookies(KnotModule): class ModQueryacl(KnotModule): '''Query ACL module''' - + mod_name = "queryacl" def __init__(self, address=None, interface=None): @@ -303,7 +303,7 @@ class ModQueryacl(KnotModule): def get_conf(self, conf=None): if not conf: conf = dnstest.config.KnotConf() - + conf.begin(self.conf_name) conf.id_item("id", self.conf_id) if self.address: @@ -332,6 +332,21 @@ class ModGeoip(KnotModule): self.geodb_file = geodb_file self.geodb_key = geodb_key + @classmethod + def check(self): + '''Extended module check by libmaxminddb dependency check''' + super().check() + + try: + proc = Popen(self._check_cmd(), stdout=PIPE, stderr=PIPE, + universal_newlines=True) + (out, err) = proc.communicate() + if re.search("MMDB_open", out): + return + raise Skip() + except: + raise Skip("Library 'maxminddb' not detected") + def get_conf(self, conf=None): if not conf: conf = dnstest.config.KnotConf()