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
0dc14b63
Commit
0dc14b63
authored
4 years ago
by
Nicolas KAROLAK
Browse files
Options
Downloads
Patches
Plain Diff
use f-strings
parent
6b71b6a9
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
tests/test_nginx_vhosts.py
+15
-15
15 additions, 15 deletions
tests/test_nginx_vhosts.py
with
15 additions
and
15 deletions
tests/test_nginx_vhosts.py
+
15
−
15
View file @
0dc14b63
...
...
@@ -91,11 +91,11 @@ def test_vhost(
name
=
nginx_file
.
name
for
port
,
proto
in
ports_info
or
[(
80
,
False
)]:
for
domain
in
domains
or
[
"
localhost
"
]:
url
=
"
%s://%s:%s
"
%
(
proto
,
domain
,
port
)
u
.
info
(
"
- testing url
'
%s
'
from
%s
"
%
(
url
,
name
)
)
url
=
f
"
{
proto
}
://
{
domain
}
:
{
port
}
"
u
.
info
(
f
"
- testing url
'
{
url
}
'
from
{
name
}
"
)
if
name
.
startswith
(
"
mediaserver
"
)
and
not
tested
:
if
not
re
.
search
(
r
"
https?://%s
"
%
domain
,
celerity_conf
):
u
.
warning
(
"
url
'
%s
'
not found in celerity conf
"
%
url
)
u
.
warning
(
f
"
url
'
{
url
}
'
not found in celerity conf
"
)
warnings
+=
1
# test domain IP
ip_error
=
None
...
...
@@ -103,19 +103,19 @@ def test_vhost(
try
:
ip
=
socket
.
gethostbyname
(
domain
)
except
Exception
as
e
:
ip_error
=
"
domain: not resolved
%s
"
%
e
ip_error
=
f
"
domain: not resolved
{
e
}
"
else
:
if
ip
!=
"
127.0.0.1
"
:
ip_warning
=
"
domain: resolve to
%s
instead of 127.0.0.1
"
%
ip
ip_warning
=
f
"
domain: resolve to
{
ip
}
instead of 127.0.0.1
"
if
ip_error
:
if
resolution_ignored
and
domain
in
resolution_ignored
:
u
.
info
(
"
%s (ignored)
"
%
ip_error
)
u
.
info
(
f
"
{
ip_error
}
(ignored)
"
)
ip_error
=
None
else
:
u
.
error
(
ip_error
)
elif
ip_warning
:
if
resolution_ignored
and
domain
in
resolution_ignored
:
u
.
info
(
"
%s (ignored)
"
%
ip_warning
)
u
.
info
(
f
"
{
ip_warning
}
(ignored)
"
)
ip_warning
=
None
else
:
u
.
warning
(
ip_warning
)
...
...
@@ -139,14 +139,14 @@ def test_vhost(
or
domain
==
"
localhost
"
and
code
not
in
(
200
,
401
,
403
,
404
)
):
u
.
error
(
"
status:
%s, %sms
"
%
(
code
,
req_time
)
)
u
.
error
(
f
"
status:
{
code
}
,
{
req_time
}
ms
"
)
req_error
=
True
else
:
if
req_time
>
10000
:
u
.
warning
(
"
status:
%s, %sms
"
%
(
code
,
req_time
)
)
u
.
warning
(
f
"
status:
{
code
}
,
{
req_time
}
ms
"
)
warnings
+=
1
else
:
u
.
success
(
"
status:
%s, %sms
"
%
(
code
,
req_time
)
)
u
.
success
(
f
"
status:
{
code
}
,
{
req_time
}
ms
"
)
if
"
mediaserver
"
in
name
and
wowza_dir
:
# test /streaming url
try
:
...
...
@@ -163,13 +163,13 @@ def test_vhost(
else
:
code
=
req
.
status_code
if
code
!=
200
:
u
.
error
(
"
streaming:
%s, %sms
"
%
(
code
,
req_time
)
)
u
.
error
(
f
"
streaming:
{
code
}
,
{
req_time
}
ms
"
)
req_error
=
True
elif
req_time
>
10000
:
u
.
warning
(
"
streaming:
%s, %sms
"
%
(
code
,
req_time
)
)
u
.
warning
(
f
"
streaming:
{
code
}
,
{
req_time
}
ms
"
)
warnings
+=
1
else
:
u
.
success
(
"
streaming:
%s, %sms
"
%
(
code
,
req_time
)
)
u
.
success
(
f
"
streaming:
{
code
}
,
{
req_time
}
ms
"
)
tested
+=
1
if
ip_warning
:
...
...
@@ -185,13 +185,13 @@ def main():
# check that Nginx dir exists
nginx_dir
=
"
/etc/nginx/sites-enabled
"
if
not
Path
(
nginx_dir
).
exists
():
u
.
info
(
"
nginx dir does not exists (
'
%s
'
), test skipped.
"
%
nginx_dir
)
u
.
info
(
f
"
nginx dir does not exists (
'
{
nginx_dir
}
'
), test skipped.
"
)
exit
(
2
)
# check that Wowza is installed
wowza_dir
=
"
/usr/local/WowzaStreamingEngine
"
if
not
Path
(
wowza_dir
).
exists
():
u
.
info
(
"
wowza is not installed (
'
%s
'
does not exist).
"
%
wowza_dir
)
u
.
info
(
f
"
wowza is not installed (
'
wowza_dir
'
does not exist).
"
)
wowza_dir
=
None
else
:
u
.
info
(
"
wowza is installed, /streaming/ will be tested on mediaserver vhosts.
"
)
...
...
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