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
a015f636
Commit
a015f636
authored
8 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Handle socket error in Nginx test.
parent
47cc5e1b
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_vhosts.py
+34
-29
34 additions, 29 deletions
tests/test_nginx_vhosts.py
with
34 additions
and
29 deletions
tests/test_nginx_vhosts.py
+
34
−
29
View file @
a015f636
...
...
@@ -53,39 +53,44 @@ for name in os.listdir(nginx_dir):
found
=
True
url
=
'
%s://%s
'
%
(
'
https
'
if
https
else
'
http
'
,
domain
)
sys
.
stdout
.
write
(
'
Testing url
"
%s
"
:
'
%
url
)
ip
=
socket
.
gethostbyname
(
domain
)
if
ip
!=
'
127.0.0.1
'
:
sys
.
stdout
.
write
(
'
\033
[91mKO (domain is not resolved with 127.0.0.1)
\033
[0m
'
)
try
:
ip
=
socket
.
gethostbyname
(
domain
)
except
Exception
as
e
:
sys
.
stdout
.
write
(
'
\033
[91mKO (domain is not resolved: %s)
\033
[0m
'
%
e
)
errors
+=
1
else
:
try
:
req
=
requests
.
get
(
url
,
verify
=
False
,
proxies
=
{
'
http
'
:
''
,
'
https
'
:
''
},
timeout
=
10
)
except
Exception
as
e
:
code
=
str
(
e
)
else
:
code
=
req
.
status_code
if
code
not
in
(
200
,
403
):
sys
.
stdout
.
write
(
'
\033
[91mKO (%s)
\033
[0m
'
%
code
)
if
ip
!=
'
127.0.0.1
'
:
sys
.
stdout
.
write
(
'
\033
[91mKO (domain is not resolved with 127.0.0.1)
\033
[0m
'
)
errors
+=
1
else
:
sys
.
stdout
.
write
(
'
\033
[92mOK (%s)
\033
[0m
'
%
code
)
if
'
mediaserver
'
in
name
and
wowza_dir
:
# test /streaming url
sys
.
stdout
.
write
(
'
, streaming:
'
)
try
:
req
=
requests
.
get
(
url
+
'
/streaming/
'
,
verify
=
False
,
proxies
=
{
'
http
'
:
''
,
'
https
'
:
''
},
timeout
=
10
)
except
Exception
as
e
:
code
=
str
(
e
)
else
:
code
=
req
.
status_code
if
code
!=
200
:
sys
.
stdout
.
write
(
'
\033
[91mKO (%s)
\033
[0m
'
%
code
)
errors
+=
1
elif
'
Wowza Streaming Engine
'
not
in
req
.
text
:
sys
.
stdout
.
write
(
'
\033
[91mKO (%s, %s)
\033
[0m
'
%
(
code
,
req
.
text
.
replace
(
'
\n
'
,
'
'
)[:
200
]))
errors
+=
1
else
:
sys
.
stdout
.
write
(
'
\033
[92mOK (%s)
\033
[0m
'
%
code
)
try
:
req
=
requests
.
get
(
url
,
verify
=
False
,
proxies
=
{
'
http
'
:
''
,
'
https
'
:
''
},
timeout
=
10
)
except
Exception
as
e
:
code
=
str
(
e
)
else
:
code
=
req
.
status_code
if
code
not
in
(
200
,
403
):
sys
.
stdout
.
write
(
'
\033
[91mKO (%s)
\033
[0m
'
%
code
)
errors
+=
1
else
:
sys
.
stdout
.
write
(
'
\033
[92mOK (%s)
\033
[0m
'
%
code
)
if
'
mediaserver
'
in
name
and
wowza_dir
:
# test /streaming url
sys
.
stdout
.
write
(
'
, streaming:
'
)
try
:
req
=
requests
.
get
(
url
+
'
/streaming/
'
,
verify
=
False
,
proxies
=
{
'
http
'
:
''
,
'
https
'
:
''
},
timeout
=
10
)
except
Exception
as
e
:
code
=
str
(
e
)
else
:
code
=
req
.
status_code
if
code
!=
200
:
sys
.
stdout
.
write
(
'
\033
[91mKO (%s)
\033
[0m
'
%
code
)
errors
+=
1
elif
'
Wowza Streaming Engine
'
not
in
req
.
text
:
sys
.
stdout
.
write
(
'
\033
[91mKO (%s, %s)
\033
[0m
'
%
(
code
,
req
.
text
.
replace
(
'
\n
'
,
'
'
)[:
200
]))
errors
+=
1
else
:
sys
.
stdout
.
write
(
'
\033
[92mOK (%s)
\033
[0m
'
%
code
)
sys
.
stdout
.
write
(
'
.
\n
'
)
if
errors
:
...
...
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