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
89543d76
Commit
89543d76
authored
7 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Indicate number of failures in email subject (refs
#21150
).
parent
61318828
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
+8
-5
8 additions, 5 deletions
tester.py
with
8 additions
and
5 deletions
tester.py
+
8
−
5
View file @
89543d76
...
...
@@ -250,7 +250,6 @@ class Tester():
# Prepare report
report_rows
.
append
((
name
,
criticality
,
status
,
str
(
duration
),
description
))
report_rows_length
=
[
max
(
len
(
strip_colors
(
t
)),
report_rows_length
[
i
])
for
i
,
t
in
enumerate
(
report_rows
[
-
1
])]
exit_code
=
1
if
failures
>
0
else
0
# Display results
# results as text
log
(
'
\n
Tests results:
'
)
...
...
@@ -296,7 +295,7 @@ class Tester():
with
open
(
history_file
,
'
a
'
)
as
fo
:
if
add_header
:
fo
.
write
(
'
Date | Result | Succeeded | Failed | Not testable
\n
'
)
fo
.
write
(
'
%s | %s | %s | %s | %s
\n
'
%
(
now
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
),
'
O
K
'
if
exit_code
==
0
else
'
K
O
'
,
successes
,
failures
,
len
(
tests
)
-
successes
-
failures
))
fo
.
write
(
'
%s | %s | %s | %s | %s
\n
'
%
(
now
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
),
'
K
O
'
if
failures
>
0
else
'
O
K
'
,
successes
,
failures
,
len
(
tests
)
-
successes
-
failures
))
# Search for old logs to remove
names
=
os
.
listdir
(
log_dir
)
names
.
sort
()
...
...
@@ -325,7 +324,7 @@ class Tester():
if
hostname
:
if
email
:
send_email
=
True
elif
email_if_fail
and
exit_code
!=
0
:
elif
email_if_fail
and
failures
>
0
:
# if they were too many consecutive failures, do not send the email
with
open
(
history_file
,
'
r
'
)
as
fo
:
history_content
=
fo
.
read
()
...
...
@@ -338,7 +337,10 @@ class Tester():
consecutive_failures
+=
1
else
:
break
if
consecutive_failures
<
self
.
NO_MAIL_FAILURES_COUNT
:
if
consecutive_failures
==
self
.
NO_MAIL_FAILURES_COUNT
:
log
(
'
Maximum consecutive tester failures reached (%s).
\n
No more emails will be sent.
'
%
consecutive_failures
)
send_email
=
True
elif
consecutive_failures
<
self
.
NO_MAIL_FAILURES_COUNT
:
log
(
'
Consecutive tester failures: %s.
'
%
consecutive_failures
)
send_email
=
True
else
:
...
...
@@ -382,7 +384,7 @@ Content-transfer-encoding: utf-8
boundary
=
boundary
,
hostname
=
hostname
,
recipients
=
recipients
,
status
=
'
OK
'
if
exit_code
==
0
else
'
K
O
'
,
status
=
(
'
KO (%s tests failed)
'
%
failures
)
if
failures
>
0
else
'
O
K
'
,
date
=
now
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
),
report
=
html_report
,
log_name
=
log_name
,
...
...
@@ -397,6 +399,7 @@ Content-transfer-encoding: utf-8
return
1
else
:
log
(
'
Email sent to: %s
'
%
recipients
)
exit_code
=
1
if
failures
>
0
else
0
return
exit_code
...
...
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