Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
db897a3c
Commit
db897a3c
authored
5 years ago
by
Nicolas KAROLAK
Browse files
Options
Downloads
Patches
Plain Diff
use dns-resolver
parent
0792e392
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_dns_records.py
+12
-15
12 additions, 15 deletions
tests/test_dns_records.py
with
12 additions
and
15 deletions
tests/test_dns_records.py
+
12
−
15
View file @
db897a3c
...
@@ -9,6 +9,7 @@ from pathlib import Path
...
@@ -9,6 +9,7 @@ from pathlib import Path
import
re
import
re
import
subprocess
import
subprocess
import
sys
import
sys
import
dns.resolver
try
:
try
:
import
pydbus
import
pydbus
...
@@ -81,24 +82,20 @@ def check_dns(hostname: str, expected_ip: str, resolvers: set) -> tuple:
...
@@ -81,24 +82,20 @@ def check_dns(hostname: str, expected_ip: str, resolvers: set) -> tuple:
warnings
=
0
warnings
=
0
errors
=
0
errors
=
0
for
resolver
in
resolvers
:
resolver
=
dns
.
resolver
.
Resolver
(
configure
=
False
)
status
,
output
=
subprocess
.
getstatusoutput
(
resolver
.
nameservers
=
list
(
resolvers
)
"
host {} {}
"
.
format
(
hostname
,
resolver
)
try
:
)
answers
=
[
rdata
.
address
for
rdata
in
resolver
.
query
(
hostname
)]
if
status
==
0
:
except
Exception
as
dns_err
:
address
=
get_result
(
output
)
u
.
error
(
"
cannot resolve {}: {}
"
.
format
(
hostname
,
dns_err
))
errors
+=
1
else
:
for
address
in
answers
:
if
address
==
expected_ip
:
if
address
==
expected_ip
:
u
.
success
(
"
dns({}):
{} -> {}
"
.
format
(
resolver
,
hostname
,
address
))
u
.
success
(
"
{} -> {}
"
.
format
(
hostname
,
address
))
else
:
else
:
u
.
error
(
u
.
error
(
"
{} -> {} != {}
"
.
format
(
hostname
,
address
,
expected_ip
))
"
dns({}): {} -> {} (should be {})
"
.
format
(
resolver
,
hostname
,
address
,
expected_ip
)
)
errors
+=
1
errors
+=
1
else
:
u
.
error
(
"
dns({}): cannot resolve {}
"
.
format
(
resolver
,
hostname
))
errors
+=
1
return
warnings
,
errors
return
warnings
,
errors
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment