Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
Lu Xu
slapos.toolbox
Commits
6b64f179
Commit
6b64f179
authored
Dec 18, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
skip current test if its computer becomes unavailable
parent
d1f8405e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
11 deletions
+55
-11
slapos/agent/agent.py
slapos/agent/agent.py
+55
-11
No files found.
slapos/agent/agent.py
View file @
6b64f179
...
@@ -58,6 +58,15 @@ TESTER_STATE_INSTANCE_INSTALLED = 2
...
@@ -58,6 +58,15 @@ TESTER_STATE_INSTANCE_INSTALLED = 2
TESTER_STATE_INSTANCE_STARTED
=
4
TESTER_STATE_INSTANCE_STARTED
=
4
TESTER_STATE_INSTANCE_UNINSTALLED
=
5
TESTER_STATE_INSTANCE_UNINSTALLED
=
5
def
compute_response_age
(
created_at
):
# the following does NOT take TZ into account
created_at
=
datetime
.
datetime
.
strptime
(
created_at
,
'%a, %d %b %Y %H:%M:%S %Z'
)
gmt_now
=
datetime
.
datetime
(
*
time
.
gmtime
()[:
6
])
return
(
gmt_now
-
created_at
).
seconds
class
x509Transport
(
xmlrpclib
.
Transport
):
class
x509Transport
(
xmlrpclib
.
Transport
):
"""
"""
Similar to xmlrpclib.SecureTransport, but with actually usable x509
Similar to xmlrpclib.SecureTransport, but with actually usable x509
...
@@ -199,6 +208,7 @@ class SoftwareReleaseTester(RPCRetry):
...
@@ -199,6 +208,7 @@ class SoftwareReleaseTester(RPCRetry):
)
)
def
_getSoftwareState
(
self
):
def
_getSoftwareState
(
self
):
# the state of the software release is not reported anymore with the current API.
return
SOFTWARE_STATE_INSTALLED
return
SOFTWARE_STATE_INSTALLED
def
_getInstanceState
(
self
):
def
_getInstanceState
(
self
):
...
@@ -218,17 +228,13 @@ class SoftwareReleaseTester(RPCRetry):
...
@@ -218,17 +228,13 @@ class SoftwareReleaseTester(RPCRetry):
try
:
try
:
instance_state
=
requested
.
getStatus
()
instance_state
=
requested
.
getStatus
()
# the following does NOT take TZ into account
if
instance_state
[
'text'
].
startswith
(
'#error'
):
created_at
=
datetime
.
datetime
.
strptime
(
instance_state
[
'created_at'
],
'%a, %d %b %Y %H:%M:%S %Z'
)
return
INSTANCE_STATE_UNKNOWN
gmt_now
=
datetime
.
datetime
(
*
time
.
gmtime
()[:
6
])
se
lf
.
_logger
.
debug
(
'Instance state: '
,
instance_state
)
se
rver_response_age
=
compute_response_age
(
instance_state
[
'created_at'
]
)
self
.
_logger
.
debug
(
'Created at: %s (%d
)'
%
(
instance_state
[
'created_at'
],
(
gmt_now
-
created_at
).
seconds
))
self
.
_logger
.
debug
(
'Created at: %s (%d
secs ago)'
%
(
instance_state
[
'created_at'
],
server_response_age
))
if
instance_state
[
'text'
].
startswith
(
'#error no data found'
):
if
instance_state
[
'text'
].
startswith
(
'#access'
)
and
server_response_age
<
60
*
5
:
return
INSTANCE_STATE_UNKNOWN
elif
instance_state
[
'text'
].
startswith
(
'#access'
)
\
and
(
gmt_now
-
created_at
).
seconds
<
300
:
return
INSTANCE_STATE_STARTED
return
INSTANCE_STATE_STARTED
except
slapos
.
slap
.
ResourceNotReady
:
except
slapos
.
slap
.
ResourceNotReady
:
return
INSTANCE_STATE_UNKNOWN
return
INSTANCE_STATE_UNKNOWN
...
@@ -531,12 +537,50 @@ def main():
...
@@ -531,12 +537,50 @@ def main():
# Change test_result.watcher_period outside this loop if you wish
# Change test_result.watcher_period outside this loop if you wish
# to change sleep duration.
# to change sleep duration.
next_deadline
=
now
+
test_result
.
watcher_period
next_deadline
=
now
+
test_result
.
watcher_period
for
section
,
(
test_line
,
tester
,
target_computer
)
in
running_test_dict
.
items
(
):
for
section
,
(
test_line
,
tester
,
target_computer
)
in
list
(
running_test_dict
.
items
()
):
logger
.
info
(
'Checking %s: %r...'
,
section
,
tester
)
logger
.
info
(
'Checking %s: %r...'
,
section
,
tester
)
computer_state
=
slap
.
registerComputer
(
target_computer
).
getStatus
()
# check if the computer has successfullly connected to report its status.
if
not
computer_state
[
'text'
].
startswith
(
'#access'
):
error_msg
=
'Error while retrieving computer status for %s (%s). Test and teardown skipped.'
%
(
section
,
computer_state
[
'text'
])
logger
.
error
(
error_msg
)
test_line
.
stop
(
test_count
=
1
,
error_count
=
0
,
failure_count
=
1
,
skip_count
=
0
,
stderr
=
error_msg
,
)
del
running_test_dict
[
section
]
continue
# check if the computer has connected in the last 15 minutes
# if it has not: report the failure, skip the rest of the test and the teardown as well.
server_response_age
=
compute_response_age
(
computer_state
[
'created_at'
])
if
server_response_age
>
60
*
15
:
error_msg
=
'Computer is unavailable (since %s minutes) for %s. Test and teardown skipped.'
%
(
int
(
server_response_age
/
60
),
section
)
logger
.
error
(
error_msg
)
test_line
.
stop
(
test_count
=
1
,
error_count
=
0
,
failure_count
=
1
,
skip_count
=
0
,
stderr
=
error_msg
,
)
del
running_test_dict
[
section
]
continue
try
:
try
:
deadline
=
tester
.
tic
(
now
)
deadline
=
tester
.
tic
(
now
)
except
Exception
:
except
Exception
:
logger
.
exception
(
'Test execution fail
for %s'
%
(
section
)
)
logger
.
exception
(
'Test execution fail
ed for %s'
%
section
)
test_line
.
stop
(
test_line
.
stop
(
test_count
=
1
,
test_count
=
1
,
error_count
=
1
,
error_count
=
1
,
...
...
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