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
4712e4a2
Commit
4712e4a2
authored
5 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Improved log of email test | refs
#30015
parent
114fc1e3
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_email.py
+32
-18
32 additions, 18 deletions
tests/test_email.py
with
32 additions
and
18 deletions
tests/test_email.py
+
32
−
18
View file @
4712e4a2
...
...
@@ -119,12 +119,6 @@ def check_send(sender: str) -> tuple:
)
subprocess
.
getoutput
(
cmd
)
# init vars
timeout
=
120
waited
=
1
delay
=
2
out
=
""
# find logs
if
Path
(
"
/var/log/maillog
"
).
is_file
():
cmd
=
"
grep
'
{}
'
/var/log/maillog
"
.
format
(
email
)
...
...
@@ -133,29 +127,49 @@ def check_send(sender: str) -> tuple:
else
:
u
.
info
(
"
/var/log/mail.log not found, trying journalctl
"
)
cmd
=
"
journalctl -t postfix/smtp | grep {}
"
.
format
(
email
)
u
.
log
(
"
Using following command to search for sending log:
\n
{}
"
.
format
(
cmd
))
# init vars
timeout
=
120
waited
=
0
delay
=
1
timed_out
=
False
out
=
""
u
.
log
(
"
Email sending timeout is {} seconds.
"
.
format
(
timeout
))
# logs polling
time
.
sleep
(
1
)
while
True
:
sys
.
stdout
.
write
(
"
Waiting for sending log
"
)
sys
.
stdout
.
flush
()
while
not
timed_out
:
# wait
time
.
sleep
(
delay
)
waited
+=
delay
delay
*=
2
# run command
status
,
out
=
subprocess
.
getstatusoutput
(
cmd
)
# log loop
sys
.
stdout
.
write
(
"
.
"
)
sys
.
stdout
.
flush
()
# found
if
status
==
0
:
out
=
out
.
strip
().
split
(
"
\n
"
)[
-
1
]
if
"
status=deferred
"
not
in
out
:
break
# timeout
if
waited
>=
timeout
:
u
.
error
(
"
Failed to send email.
"
)
u
.
info
(
"
> no log entry found using command: {}
"
.
format
(
cmd
))
errors
+=
1
break
# wait before next iteration
time
.
sleep
(
delay
)
waited
+=
delay
delay
*=
2
timed_out
=
waited
>=
timeout
sys
.
stdout
.
write
(
"
\n
"
)
# check if the sending has timed out
if
timed_out
:
u
.
error
(
"
Failed to send email (timed out).
"
)
if
out
:
u
.
info
(
"
> sending log line:
\n
{}
"
.
format
(
out
))
else
:
u
.
info
(
"
> no log entry found.
"
)
errors
+=
1
# check output for errors
if
"
bounced
"
in
out
or
"
you tried to reach does not exist
"
in
out
:
el
if
"
bounced
"
in
out
or
"
you tried to reach does not exist
"
in
out
:
u
.
error
(
"
Failed to send email
"
)
u
.
info
(
"
> sending log line:
\n
{}
"
.
format
(
out
))
errors
+=
1
...
...
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