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
ede15d11
Commit
ede15d11
authored
7 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Added out of support handling (refs
#23881
).
parent
a6c707a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tester.py
+37
-14
37 additions, 14 deletions
tester.py
with
37 additions
and
14 deletions
tester.py
+
37
−
14
View file @
ede15d11
...
...
@@ -15,6 +15,10 @@ import glob
import
utils
from
utils
import
log
OUT_OF_SUPPORT_TEXT
=
'''
\033
[93mWarning:
The system is out of support, UbiCast will not be notified if errors are detected.
Please contact UbiCast sales team (sales@ubicast.eu) to renew the support contract.
\033
[0m
'''
class
Logger
(
object
):
def
__init__
(
self
,
stream
,
log_buffer
):
...
...
@@ -40,6 +44,20 @@ def strip_colors(text):
return
re
.
sub
(
r
'
\033\[[\d;]+m
'
,
''
,
text
)
def
escape
(
text
):
html
=
text
.
strip
()
html
=
html
.
replace
(
'
<
'
,
'
<
'
)
html
=
html
.
replace
(
'
>
'
,
'
>
'
)
html
=
html
.
replace
(
'
\033
[90m
'
,
'
<span style=
"
color: gray;
"
>
'
)
html
=
html
.
replace
(
'
\033
[91m
'
,
'
<span style=
"
color: red;
"
>
'
)
html
=
html
.
replace
(
'
\033
[92m
'
,
'
<span style=
"
color: green;
"
>
'
)
html
=
html
.
replace
(
'
\033
[93m
'
,
'
<span style=
"
color: orange;
"
>
'
)
html
=
html
.
replace
(
'
\033
[94m
'
,
'
<span style=
"
color: blue;
"
>
'
)
html
=
html
.
replace
(
'
\033
[95m
'
,
'
<span style=
"
color: purple;
"
>
'
)
html
=
strip_colors
(
html
)
return
html
def
raid_idle
():
idle
=
True
devs
=
glob
.
glob
(
'
/sys/block/md*/md/sync_action
'
)
...
...
@@ -246,6 +264,7 @@ class Tester():
total_duration
=
None
report_rows
=
[(
'
Test
'
,
'
Criticality
'
,
'
Result
'
,
'
Duration
'
,
'
Description
'
)]
report_rows_length
=
[
len
(
t
)
for
t
in
report_rows
[
0
]]
out_of_support
=
False
for
name
,
criticality
,
description
,
command
in
tests
:
log
(
'
\033
[1;95m-- Test
"
%s
"
--
\033
[0;0m
'
%
name
)
start_date
=
datetime
.
datetime
.
utcnow
()
...
...
@@ -254,9 +273,12 @@ class Tester():
p
=
subprocess
.
Popen
(
command
,
stdin
=
sys
.
stdin
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
if
out
:
log
(
out
.
decode
(
'
utf-8
'
).
strip
())
out
=
out
.
decode
(
'
utf-8
'
).
strip
()
out_of_support
=
out_of_support
or
'
out of support
'
in
out
log
(
out
)
if
err
:
log
(
err
.
decode
(
'
utf-8
'
).
strip
())
err
=
err
.
decode
(
'
utf-8
'
).
strip
()
log
(
err
)
if
p
.
returncode
==
0
:
status
=
'
\033
[92msuccess
\033
[0m
'
successes
+=
1
...
...
@@ -296,6 +318,8 @@ class Tester():
nb_sp
=
report_rows_length
[
i
]
-
len
(
strip_colors
(
val
))
log_report
+=
'
%s%s
'
%
(
val
,
'
'
*
nb_sp
)
log_report
+=
'
\n
'
+
'
-
'
*
50
if
out_of_support
:
log_report
=
OUT_OF_SUPPORT_TEXT
+
'
\n
'
+
log_report
log
(
log_report
.
strip
())
log
(
'
Total tests duration: %s.
\n
'
%
total_duration
)
# results as html
...
...
@@ -304,16 +328,11 @@ class Tester():
html_cell
=
'
th
'
if
not
html_report
else
'
td
'
html_report
+=
'
\n
<tr>
'
for
i
,
val
in
enumerate
(
row
):
html_report
+=
'
<%s>%s</%s>
'
%
(
html_cell
,
val
,
html_cell
)
html_report
+=
'
<%s>%s</%s>
'
%
(
html_cell
,
escape
(
val
)
,
html_cell
)
html_report
+=
'
</tr>
'
html_report
=
'
<table border=
"
1
"
>%s
\n
</table>
'
%
html_report
html_report
=
html_report
.
replace
(
'
\033
[90m
'
,
'
<span style=
"
color: gray;
"
>
'
)
html_report
=
html_report
.
replace
(
'
\033
[91m
'
,
'
<span style=
"
color: red;
"
>
'
)
html_report
=
html_report
.
replace
(
'
\033
[92m
'
,
'
<span style=
"
color: green;
"
>
'
)
html_report
=
html_report
.
replace
(
'
\033
[93m
'
,
'
<span style=
"
color: orange;
"
>
'
)
html_report
=
html_report
.
replace
(
'
\033
[94m
'
,
'
<span style=
"
color: blue;
"
>
'
)
html_report
=
html_report
.
replace
(
'
\033
[95m
'
,
'
<span style=
"
color: purple;
"
>
'
)
html_report
=
html_report
.
replace
(
'
\033
[0m
'
,
'
</span>
'
)
if
out_of_support
:
html_report
=
'
<p>
'
+
escape
(
OUT_OF_SUPPORT_TEXT
)
+
'
</p>
\n
'
+
html_report
# Store locally results
now
=
datetime
.
datetime
.
utcnow
()
log_dir
=
os
.
path
.
join
(
self
.
root_dir
,
'
log
'
)
...
...
@@ -377,7 +396,7 @@ class Tester():
log
(
consecutive_msg
)
html_report
+=
'
\n
<br/>
'
+
consecutive_msg
.
replace
(
'
\n
'
,
'
\n
<br/>
'
)
if
send_email
:
recipients
=
utils
.
get_conf
(
'
EMAIL_ADMINS
'
)
recipients
=
utils
.
get_conf
(
'
EMAIL_ADMINS
'
)
or
''
system_domain
=
utils
.
get_conf
(
'
MS_SERVER_NAME
'
)
system_type
=
'
MediaServer
'
if
system_domain
==
'
mediaserver
'
:
...
...
@@ -390,8 +409,12 @@ class Tester():
system_domain
=
'
Server
'
system_type
=
'
-
'
if
utils
.
get_conf
(
'
PREMIUM_SUPPORT
'
)
!=
'
0
'
:
system_domain
=
"
[PREMIUM] %s
"
%
system_domain
recipients
+=
'
,premium-support@ubicast.eu
'
system_domain
=
'
[PREMIUM] %s
'
%
system_domain
if
not
out_of_support
:
recipients
+=
'
,premium-support@ubicast.eu
'
if
out_of_support
:
recipients
=
recipients
.
replace
(
'
sysadmin@ubicast.eu
'
,
''
).
replace
(
'
,,
'
,
'
,
'
)
recipients
=
recipients
.
strip
(
'
,
'
)
if
not
recipients
:
log
(
'
No recipients defined for email sending. Set a value for EMAIL_ADMINS.
'
)
return
1
...
...
@@ -406,7 +429,7 @@ Content-type: multipart/related; boundary="%(boundary)s"
Content-Type: text/html; charset=UTF-8
Content-transfer-encoding: utf-8
<b>Date: %(date)s UTC</b><
br/><br
/>
<p>
<b>Date: %(date)s UTC</b></
p
>
%(report)s
--%(boundary)s
...
...
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