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
65ca2aec
Commit
65ca2aec
authored
8 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Moved tests execution in a dedicated file (refs
#20133
).
parent
2b041440
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
102.Run_tests/0_setup.sh
+0
-4
0 additions, 4 deletions
102.Run_tests/0_setup.sh
envsetup.py
+9
-32
9 additions, 32 deletions
envsetup.py
tester.py
+125
-0
125 additions, 0 deletions
tester.py
with
134 additions
and
36 deletions
102.Run_tests/0_setup.sh
+
0
−
4
View file @
65ca2aec
...
...
@@ -26,10 +26,6 @@ echo "NGINX" >> /root/deployment.results
grep
server_name /etc/nginx/sites-enabled/
*
|
uniq
>>
/root/deployment.results
echo
""
>>
/root/deployment.results
echo
"RTMP"
>>
/root/deployment.results
cat
/etc/hca/rtmp.ini |
grep
-v
'#'
>>
/root/deployment.results
echo
""
>>
/root/deployment.results
echo
"SERVICES"
>>
/root/deployment.results
echo
"mediaserver
$(
service mediaserver status |
grep
Active
)
"
>>
/root/deployment.results
echo
"WowzaStreamingEngine
$(
service WowzaStreamingEngine status |
grep
Active
)
"
>>
/root/deployment.results
...
...
This diff is collapsed.
Click to expand it.
envsetup.py
+
9
−
32
View file @
65ca2aec
...
...
@@ -13,12 +13,20 @@ from utils import log
class
EnvSetup
():
USAGE
=
'''
%s [-d] [-h] [<action id>]
-d: debug mode (can be started with non root users).
-h: show this message.
action id: specify which action should be started (non interactive).
'''
%
__file__
PY_SETUP_NAME
=
'
0_setup.py
'
BASH_SETUP_NAME
=
'
0_setup.sh
'
def
__init__
(
self
,
*
args
):
self
.
display_header
()
args
=
list
(
args
)
# Check if help is required
if
'
-h
'
in
args
:
log
(
'
USAGE:
'
+
self
.
USAGE
)
sys
.
exit
(
0
)
# Check current dir
root_dir
=
utils
.
get_dir
(
__file__
)
if
root_dir
!=
''
:
...
...
@@ -87,7 +95,6 @@ class EnvSetup():
else
:
log
(
'
\033
[1;94m%s
\033
[0m
'
%
(
action
[
'
label
'
]))
log
(
''
)
log
(
'
t: Run tests
'
)
log
(
'
c: Configuration status
'
)
log
(
'
e: Exit
\n
'
)
log
(
'
Info:
'
)
...
...
@@ -106,37 +113,7 @@ class EnvSetup():
log
(
'
Exit
'
)
sys
.
exit
(
0
)
exit_code
=
0
if
target
==
'
t
'
:
# Run tests
path
=
os
.
path
.
join
(
self
.
root_dir
,
'
tests
'
)
if
not
os
.
path
.
isdir
(
path
):
exit_code
=
1
log
(
'
The tests dir is missing (%s).
'
%
path
)
else
:
os
.
chdir
(
path
)
names
=
os
.
listdir
(
path
)
names
.
sort
()
results
=
list
()
for
name
in
names
:
log
(
'
\033
[1;95m-- Test
"
%s
"
--
\033
[0;0m
'
%
name
)
test_path
=
os
.
path
.
join
(
path
,
name
)
try
:
code
=
utils
.
exec_cmd
(
test_path
)
if
code
!=
0
:
raise
Exception
(
'
Command exited with code %s.
'
%
code
)
except
Exception
as
e
:
exit_code
=
1
log
(
e
)
results
.
append
((
False
,
test_path
))
else
:
results
.
append
((
True
,
test_path
))
log
(
'
\n
Tests results:
'
)
for
success
,
test_path
in
results
:
if
success
:
log
(
'
%s:
\033
[92msuccess
\033
[0m
'
%
test_path
)
else
:
log
(
'
%s:
\033
[91mfailure
\033
[0m
'
%
test_path
)
elif
target
==
'
c
'
:
if
target
==
'
c
'
:
# Display current configuration
log
(
'
Configuration status:
'
)
override
=
utils
.
get_conf
(
'
_override
'
)
...
...
This diff is collapsed.
Click to expand it.
tester.py
0 → 100755
+
125
−
0
View file @
65ca2aec
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Script to start tests and to manage their results
'''
import
os
import
sys
import
utils
from
utils
import
log
class
Tester
():
USAGE
=
'''
%s [-e] [-d] [-h]
-e: send email with report.
-d: debug mode (can be started with non root users).
-h: show this message.
'''
%
__file__
def
__init__
(
self
,
*
args
):
log
(
'
\033
[96m-------------------------------
\033
[0m
'
)
log
(
'
\033
[96m- UbiCast applications tester -
\033
[0m
'
)
log
(
'
\033
[96m-------------------------------
\033
[0m
'
)
args
=
list
(
args
)
# Check if help is required
if
'
-h
'
in
args
:
log
(
'
USAGE:
'
+
self
.
USAGE
)
sys
.
exit
(
0
)
# Check current dir
root_dir
=
utils
.
get_dir
(
__file__
)
if
root_dir
!=
''
:
os
.
chdir
(
root_dir
)
self
.
root_dir
=
root_dir
# Add to python path
if
root_dir
not
in
sys
.
path
:
sys
.
path
.
append
(
root_dir
)
# Check that this script is run by root
debug
=
'
-d
'
in
args
if
debug
:
args
.
remove
(
'
-d
'
)
code
,
out
=
utils
.
exec_cmd
([
'
whoami
'
],
get_out
=
True
)
if
out
!=
'
root
'
and
not
debug
:
log
(
'
This script should be run as root user.
'
)
sys
.
exit
(
1
)
# Load conf
conf
=
utils
.
load_conf
()
if
not
conf
:
log
(
'
No configuration loaded.
'
)
sys
.
exit
(
1
)
# Check for email value
email
=
'
-e
'
in
args
if
email
:
args
.
remove
(
'
-i
'
)
exit_code
=
self
.
run_tests
(
email
)
sys
.
exit
(
exit_code
)
def
get_file_description
(
self
,
path
):
with
open
(
path
,
'
r
'
)
as
fo
:
content
=
fo
.
read
()
description
=
''
if
path
.
endswith
(
'
.py
'
):
start
=
content
.
find
(
'
\'\'\'
'
)
if
start
>
0
:
start
+=
3
end
=
content
.
find
(
'
\'\'\'
'
,
start
)
if
end
>
0
:
description
=
content
[
start
:
end
].
strip
()
else
:
for
line
in
content
.
split
(
'
\n
'
):
if
line
.
startswith
(
'
#!
'
):
continue
elif
line
.
startswith
(
'
#
'
):
description
+=
line
+
'
\n
'
else
:
break
return
description
.
strip
()
def
run_tests
(
self
,
email
=
False
):
path
=
os
.
path
.
join
(
self
.
root_dir
,
'
tests
'
)
if
not
os
.
path
.
isdir
(
path
):
log
(
'
The tests dir is missing (
"
%s
"
).
'
%
path
)
return
1
os
.
chdir
(
path
)
names
=
os
.
listdir
(
path
)
names
.
sort
()
if
not
names
:
log
(
'
The tests dir is empty (
"
%s
"
).
'
%
path
)
return
1
results
=
list
()
exit_code
=
0
# Run all tests
for
name
in
names
:
log
(
'
\033
[1;95m-- Test
"
%s
"
--
\033
[0;0m
'
%
name
)
test_path
=
os
.
path
.
join
(
path
,
name
)
# Get test description
description
=
self
.
get_file_description
(
test_path
)
# Run test
try
:
code
=
utils
.
exec_cmd
(
test_path
)
if
code
!=
0
:
raise
Exception
(
'
Command exited with code %s.
'
%
code
)
except
Exception
as
e
:
exit_code
=
1
log
(
e
)
results
.
append
((
False
,
test_path
,
description
))
else
:
results
.
append
((
True
,
test_path
,
description
))
log
(
'
\n
Tests results:
'
)
html_report
=
'
<table>
'
html_report
+=
'
\n
<tr><th>Test</th><th>Result</th><th>Description</th></tr>
'
for
success
,
test_path
,
description
in
results
:
file_name
=
os
.
path
.
basename
(
test_path
)
if
success
:
html_result
=
'
<span style=
"
color: green;
"
>success</span>
'
term_result
=
'
\033
[92msuccess
\033
[0m
'
else
:
html_result
=
'
<span style=
"
color: red;
"
>failure</span>
'
term_result
=
'
\033
[91mfailure
\033
[0m
'
log
(
'
%s: %s
'
%
(
file_name
,
term_result
))
html_report
+=
'
\n
<tr><td>%s</td><td>%s</td><td>%s</td></tr>
'
%
(
file_name
,
html_result
,
description
)
html_report
+=
'
\n
</table>
'
return
exit_code
if
__name__
==
'
__main__
'
:
Tester
(
*
sys
.
argv
[
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