diff --git a/tests/test_dns_records.py b/tests/test_dns_records.py index b55cc1192b85d847c01ffb982a3daf7c7be73f4b..c24ec9da87f3db48585ebbeff6064de230ddcf65 100755 --- a/tests/test_dns_records.py +++ b/tests/test_dns_records.py @@ -85,24 +85,24 @@ if not ip or ip == '0': print('No IP set in configuration file, unable to test DNS.') sys.exit(2) -conf_servers = ( - 'MS_SERVER_NAME', - 'MONITOR_SERVER_NAME', - 'CM_SERVER_NAME', +services_info = ( + ('MS_SERVER_NAME', 'mediaserver', 'python3-mediaserver'), + ('MONITOR_SERVER_NAME', 'monitor', 'python3-mediaserver-monitor'), + ('CM_SERVER_NAME', 'campusmanager', 'campus-manager'), ) -conf_server_defaults = ( - 'mediaserver', - 'monitor', - 'campusmanager', -) - -for s in conf_servers: - hostname = conf.get(s) - if hostname not in conf_server_defaults: - ok = check_dns(hostname, ip) - if not ok: - all_ok = False +for conf_name, default_domain, package in services_info: + domain = conf.get(conf_name) + if domain and domain != default_domain: + # check that the service is installed on this system + status, output = subprocess.getstatusoutput('dpkg -s %s' % package) + if status == 0: + print('Checking IP of "%s".' % domain) + ok = check_dns(domain, ip) + if not ok: + all_ok = False + else: + print('Package %s is not installed, IP of "%s" will not be checked.' % (package, domain)) if not all_ok: sys.exit(1)