Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
f0ca635a
Commit
f0ca635a
authored
Mar 28, 2014
by
Daniel Salzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: improve exception messages
parent
80f11ca6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
20 deletions
+27
-20
tests-extra/tools/dnstest/server.py
tests-extra/tools/dnstest/server.py
+20
-13
tests-extra/tools/dnstest/test.py
tests-extra/tools/dnstest/test.py
+2
-2
tests-extra/tools/dnstest/utils.py
tests-extra/tools/dnstest/utils.py
+1
-1
tests-extra/tools/dnstest/zonefile.py
tests-extra/tools/dnstest/zonefile.py
+4
-4
No files found.
tests-extra/tools/dnstest/server.py
View file @
f0ca635a
...
...
@@ -21,7 +21,7 @@ def zone_arg_check(zone):
# Convert one item list to single object.
if
isinstance
(
zone
,
list
):
if
len
(
zone
)
!=
1
:
raise
Exception
(
"One zone required
.
"
)
raise
Exception
(
"One zone required"
)
return
zone
[
0
]
return
zone
...
...
@@ -199,7 +199,7 @@ class Server(object):
'''Set the server as a slave for the zone'''
if
zone
.
name
in
self
.
zones
:
raise
Exception
(
"Can't set zone
%s
as a slave"
%
name
)
raise
Exception
(
"Can't set zone
='%s'
as a slave"
%
name
)
slave_file
=
zone
.
clone
(
self
.
dir
+
"/slave"
,
exists
=
False
)
z
=
Zone
(
slave_file
,
ddns
,
ixfr
)
...
...
@@ -212,7 +212,7 @@ class Server(object):
stdout
=
self
.
fout
,
stderr
=
self
.
ferr
)
p
.
communicate
(
timeout
=
Server
.
COMPILE_TIMEOUT
)
except
:
raise
Exception
(
"Can't compile
%s
"
%
self
.
name
)
raise
Exception
(
"Can't compile
server='%s'
"
%
self
.
name
)
def
start
(
self
,
clean
=
False
):
mode
=
"w"
if
clean
else
"a"
...
...
@@ -232,7 +232,7 @@ class Server(object):
else
:
time
.
sleep
(
Server
.
START_WAIT
)
except
OSError
:
raise
Exception
(
"Can't start
%s
"
%
self
.
name
)
raise
Exception
(
"Can't start
server='%s'
"
%
self
.
name
)
def
reload
(
self
):
try
:
...
...
@@ -242,7 +242,8 @@ class Server(object):
time
.
sleep
(
Server
.
START_WAIT
)
except
CalledProcessError
as
e
:
self
.
backtrace
()
raise
Exception
(
"Can't reload %s (%i)"
%
(
self
.
name
,
e
.
returncode
))
raise
Exception
(
"Can't reload server='%s', ret='%i'"
%
(
self
.
name
,
e
.
returncode
))
def
flush
(
self
):
try
:
...
...
@@ -252,7 +253,8 @@ class Server(object):
time
.
sleep
(
Server
.
START_WAIT
)
except
CalledProcessError
as
e
:
self
.
backtrace
()
raise
Exception
(
"Can't flush %s (%i)"
%
(
self
.
name
,
e
.
returncode
))
raise
Exception
(
"Can't flush server='%s', ret='%i'"
%
(
self
.
name
,
e
.
returncode
))
def
running
(
self
):
proc
=
psutil
.
Process
(
self
.
proc
.
pid
)
...
...
@@ -363,7 +365,7 @@ class Server(object):
# Convert one item zone list to zone name.
if
isinstance
(
rname
,
list
):
if
len
(
rname
)
!=
1
:
raise
Exception
(
"One zone required
.
"
)
raise
Exception
(
"One zone required"
)
rname
=
rname
[
0
].
name
rtype_str
=
rtype
.
upper
()
...
...
@@ -485,7 +487,7 @@ class Server(object):
except
:
time
.
sleep
(
timeout
)
raise
Exception
(
"Can't query
%s for %s %s %s.
"
%
\
raise
Exception
(
"Can't query
server='%s' for '%s %s %s'
"
%
\
(
self
.
name
,
rname
,
rclass
,
rtype
))
def
create_sock
(
self
,
socket_type
):
...
...
@@ -499,7 +501,7 @@ class Server(object):
sock
=
self
.
create_sock
(
socket
.
SOCK_DGRAM
)
sent
=
sock
.
sendto
(
bytes
(
data
,
'utf-8'
),
(
self
.
addr
,
self
.
port
))
if
sent
!=
len
(
data
):
raise
Exception
(
"Can't send RAW data (%d bytes) to
%s."
%
\
raise
Exception
(
"Can't send RAW data (%d bytes) to
server='%s'"
%
(
len
(
data
),
self
.
name
))
def
zone_wait
(
self
,
zone
,
serial
=
None
):
...
...
@@ -513,7 +515,11 @@ class Server(object):
for
t
in
range
(
20
):
resp
=
self
.
dig
(
zone
.
name
,
"SOA"
,
udp
=
True
,
tries
=
1
,
log_no_sep
=
True
)
if
resp
.
resp
.
rcode
()
==
0
and
resp
.
resp
.
answer
:
if
resp
.
resp
.
rcode
()
==
0
:
if
not
resp
.
resp
.
answer
:
raise
Exception
(
"No SOA in ANSWER, zone='%s', server='%s'"
%
(
zone
.
name
,
self
.
name
))
soa
=
str
((
resp
.
resp
.
answer
[
0
]).
to_rdataset
())
_serial
=
int
(
soa
.
split
()[
5
])
if
serial
:
...
...
@@ -524,8 +530,9 @@ class Server(object):
time
.
sleep
(
2
)
else
:
self
.
backtrace
()
raise
Exception
(
"Can't get %s SOA%s from %s."
%
(
zone
.
name
,
">%i"
%
serial
if
serial
else
""
,
self
.
name
))
raise
Exception
(
"Can't get SOA%s, zone='%s', server='%s'"
%
(
" serial > %i"
%
serial
if
serial
else
""
,
zone
.
name
,
self
.
name
))
detail_log
(
SEP
)
...
...
@@ -600,7 +607,7 @@ class Server(object):
# Convert one item list to single object.
if
isinstance
(
zone
,
list
):
if
len
(
zone
)
!=
1
:
raise
Exception
(
"One zone required
.
"
)
raise
Exception
(
"One zone required"
)
zone
=
zone
[
0
]
self
.
zones
[
zone
.
name
].
add_query_module
(
module
,
param
)
...
...
tests-extra/tools/dnstest/test.py
View file @
f0ca635a
...
...
@@ -99,7 +99,7 @@ class Test(object):
elif
server
==
"dummy"
:
srv
=
dnstest
.
server
.
Dummy
()
else
:
raise
Exception
(
"Usupported server
%s
"
%
server
)
raise
Exception
(
"Usupported server
'%s'
"
%
server
)
type
(
srv
).
count
+=
1
...
...
@@ -176,7 +176,7 @@ class Test(object):
server
.
start
(
clean
=
True
)
if
not
server
.
running
():
raise
Exception
(
"Server
%s
not running"
%
server
.
name
)
raise
Exception
(
"Server
'%s'
not running"
%
server
.
name
)
if
not
server
.
listening
():
self
.
stop
(
check
=
False
)
...
...
tests-extra/tools/dnstest/utils.py
View file @
f0ca635a
...
...
@@ -17,7 +17,7 @@ def prepare_dir(path):
os
.
makedirs
(
path
)
except
OSError
:
if
not
os
.
path
.
isdir
(
path
):
raise
Exception
(
"Can't create directory
%s
"
%
path
)
raise
Exception
(
"Can't create directory
'%s'
"
%
path
)
def
test_info
():
'''Get current test case name'''
...
...
tests-extra/tools/dnstest/zonefile.py
View file @
f0ca635a
...
...
@@ -67,7 +67,7 @@ class ZoneFile(object):
shutil
.
copyfile
(
src_file
,
self
.
path
)
except
:
raise
Exception
(
"Can't use zone file
%s
"
%
src_file
)
raise
Exception
(
"Can't use zone file
'%s'
"
%
src_file
)
def
upd_file
(
self
,
file_name
=
None
,
storage
=
None
,
version
=
None
):
'''Replace zone file with a different one.'''
...
...
@@ -96,7 +96,7 @@ class ZoneFile(object):
+
params
zone_generate
.
main
(
params
)
except
OSError
:
raise
Exception
(
"Can't create zone file
%s
"
%
self
.
path
)
raise
Exception
(
"Can't create zone file
'%s'
"
%
self
.
path
)
def
dnssec_verify
(
self
):
'''Call dnssec-verify on the zone file.'''
...
...
@@ -152,7 +152,7 @@ class ZoneFile(object):
shutil
.
copyfile
(
self
.
path
,
self
.
path
+
".back"
+
str
(
self
.
backup_num
))
self
.
backup_num
+=
1
except
:
raise
Exception
(
"Can't make a copy of zone file
%s
"
%
self
.
path
)
raise
Exception
(
"Can't make a copy of zone file
'%s'
"
%
self
.
path
)
def
update_serial
(
self
,
new_serial
=
None
):
'''Change SOA serial.'''
...
...
@@ -203,6 +203,6 @@ class ZoneFile(object):
+
params
zone_generate
.
main
(
params
)
except
OSError
:
raise
Exception
(
"Can't modify zone file
%s
"
%
self
.
path
)
raise
Exception
(
"Can't modify zone file
'%s'
"
%
self
.
path
)
os
.
remove
(
old_name
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment