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
ce79b934
Verified
Commit
ce79b934
authored
5 years ago
by
Nicolas KAROLAK
Browse files
Options
Downloads
Patches
Plain Diff
test output homogenization
parent
23e45a9b
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_nginx_status.py
+34
-15
34 additions, 15 deletions
tests/test_nginx_status.py
with
34 additions
and
15 deletions
tests/test_nginx_status.py
+
34
−
15
View file @
ce79b934
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
"""
Criticality: Normal
Checks that the webserver is running.
'''
import
os
"""
from
pathlib
import
Path
import
requests
import
sys
sys
.
path
.
append
(
str
(
Path
(
__file__
).
parents
[
1
].
resolve
()))
# pylint: disable=wrong-import-position
from
envsetup
import
utils
as
u
# noqa: E402
def
main
():
print
(
"
Checking nginx status:
"
)
if
not
Path
(
"
/etc/nginx
"
).
exists
():
u
.
info
(
"
nginx dir does not exists, skip test
"
)
exit
(
2
)
if
not
os
.
path
.
exists
(
'
/etc/nginx
'
):
print
(
'
Nginx dir does not exists, test skipped.
'
)
sys
.
exit
(
2
)
else
:
print
(
'
Checking http://127.0.0.1:1080/nginx_status response.
'
)
try
:
req
=
requests
.
get
(
'
http://127.0.0.1:1080/nginx_status
'
,
proxies
=
{
'
http
'
:
''
,
'
https
'
:
''
},
timeout
=
5
)
req
=
requests
.
get
(
"
http://127.0.0.1:1080/nginx_status
"
,
proxies
=
{
"
http
"
:
""
,
"
https
"
:
""
},
timeout
=
5
,
)
if
req
.
status_code
!=
200
:
raise
Exception
(
'
Request failed with status code %s.
'
%
req
.
status_code
)
if
'
Active connections
'
not
in
req
.
text
:
raise
Exception
(
'
I
nvalid response from nginx status url
.
'
)
raise
Exception
(
"
status code: {}
"
.
format
(
req
.
status_code
)
)
if
"
Active connections
"
not
in
req
.
text
:
raise
Exception
(
"
i
nvalid response from nginx status url
"
)
except
Exception
as
e
:
print
(
str
(
e
))
sys
.
exit
(
1
)
u
.
error
(
str
(
e
))
exit
(
1
)
u
.
success
(
"
status code: {}
"
.
format
(
req
.
status_code
))
exit
(
0
)
if
__name__
==
"
__main__
"
:
main
()
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