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
75fdb1af
Commit
75fdb1af
authored
4 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Added a setting to disable test of routing rules | refs
#33094
parent
2dbf88d2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
global-conf.sh
+6
-3
6 additions, 3 deletions
global-conf.sh
tests/tester.py
+130
-109
130 additions, 109 deletions
tests/tester.py
with
136 additions
and
112 deletions
global-conf.sh
+
6
−
3
View file @
75fdb1af
...
@@ -134,15 +134,18 @@ MEDIAIMPORT_PASSWD=''
...
@@ -134,15 +134,18 @@ MEDIAIMPORT_PASSWD=''
# -- Tester config --
# -- Tester config --
# separate values with commas
# separate values with commas
TESTER_IGNORED_TESTS
=
''
# separate values with commas
TESTER_MS_INSTANCES
=
''
TESTER_MS_INSTANCES
=
''
# maximum number of instances to test
# TESTER_MAX_INSTANCES is ignored if TESTER_MS_INSTANCES is set
# TESTER_MAX_INSTANCES is ignored if TESTER_MS_INSTANCES is set
TESTER_MAX_INSTANCES
=
''
TESTER_MAX_INSTANCES
=
''
#
separate values with commas
#
ignore routing rules in VOD/live/cache tests (enable this if the server cannot reach cache servers)
TESTER_IGNORE
D_TEST
S
=
''
TESTER_IGNORE
_ROUTING_RULE
S
=
'
0
'
# ignore these dns names
# ignore these dns names
TESTER_DNS_RESOLUTION_IGNORED
=
''
TESTER_DNS_RESOLUTION_IGNORED
=
''
# ignore these nginx vhosts
# ignore these nginx vhosts
TESTER_
DNS
_RESOLUTION_IGNORED
=
''
TESTER_
VHOST
_RESOLUTION_IGNORED
=
''
# encode report attachment to base64
# encode report attachment to base64
TESTER_BASE64_ATTACH
=
'0'
TESTER_BASE64_ATTACH
=
'0'
...
...
This diff is collapsed.
Click to expand it.
tests/tester.py
+
130
−
109
View file @
75fdb1af
...
@@ -122,16 +122,17 @@ class Tester():
...
@@ -122,16 +122,17 @@ class Tester():
if
not
conf
:
if
not
conf
:
print
(
"
No configuration loaded.
"
)
print
(
"
No configuration loaded.
"
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
# Check for email value
# Check RAID status
if
not
raid_idle
():
print
(
"
A RAID check or operation is in progress, aborting tests
"
)
sys
.
exit
(
1
)
# Get tests to run
tests
=
self
.
discover_tests
(
args
.
basic_tests
,
msuser
=
args
.
msuser
,
no_update
=
args
.
no_update
)
tests
=
self
.
discover_tests
(
args
.
basic_tests
,
msuser
=
args
.
msuser
,
no_update
=
args
.
no_update
)
if
not
tests
:
if
not
tests
:
print
(
"
No test to run.
"
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
# Run tests
if
raid_idle
():
exit_code
=
self
.
run_tests
(
tests
,
send_email
=
args
.
send_email
,
send_email_if_fail
=
args
.
send_email_if_fail
)
exit_code
=
self
.
run_tests
(
tests
,
send_email
=
args
.
send_email
,
send_email_if_fail
=
args
.
send_email_if_fail
)
else
:
print
(
"
A RAID check or operation is in progress, aborting tests
"
)
exit_code
=
1
sys
.
exit
(
exit_code
)
sys
.
exit
(
exit_code
)
def
parse_file_header
(
self
,
path
):
def
parse_file_header
(
self
,
path
):
...
@@ -173,30 +174,39 @@ class Tester():
...
@@ -173,30 +174,39 @@ class Tester():
def
discover_tests
(
self
,
basic_only
=
False
,
msuser
=
None
,
no_update
=
False
):
def
discover_tests
(
self
,
basic_only
=
False
,
msuser
=
None
,
no_update
=
False
):
ignored_tests
=
get_conf
(
"
TESTER_IGNORED_TESTS
"
,
""
).
split
(
"
,
"
)
ignored_tests
=
get_conf
(
"
TESTER_IGNORED_TESTS
"
,
""
).
split
(
"
,
"
)
ignored_tests
.
append
(
"
__init__.py
"
)
ignored_tests
.
append
(
"
__init__.py
"
)
if
basic_only
:
tests
=
self
.
discover_basic_tests
(
ignored_tests
)
elif
msuser
:
tests
=
self
.
discover_mediaserver_tests
(
msuser
,
no_update
,
ignored_tests
)
else
:
tests
=
self
.
discover_basic_tests
(
ignored_tests
)
tests
.
extend
(
self
.
discover_mediaserver_tests
(
msuser
,
no_update
,
ignored_tests
))
criticalities_map
=
{
"
Low
"
:
1
,
"
Normal
"
:
2
,
"
High
"
:
3
}
tests
.
sort
(
key
=
lambda
i
:
(
-
criticalities_map
.
get
(
i
[
1
],
0
),
i
[
0
]))
return
tests
def
discover_basic_tests
(
self
,
ignored_tests
=
None
):
# Get standard tests
# Get standard tests
path
=
os
.
path
.
join
(
self
.
root_dir
,
"
scripts
"
)
test_dir
=
os
.
path
.
join
(
self
.
root_dir
,
"
scripts
"
)
if
not
os
.
path
.
isdir
(
path
):
if
not
os
.
path
.
isdir
(
test_dir
):
print
(
'
The tests dir is missing (
"
%s
"
).
'
%
path
)
print
(
'
The tests dir is missing (
"
%s
"
).
'
%
test_dir
)
return
return
list
()
names
=
os
.
listdir
(
path
)
names
=
os
.
listdir
(
test_dir
)
names
.
sort
()
names
.
sort
()
if
not
names
:
if
not
names
:
print
(
'
The tests dir is empty (
"
%s
"
).
'
%
path
)
print
(
'
The tests dir is empty (
"
%s
"
).
'
%
test_dir
)
return
return
list
()
criticalities_map
=
{
"
Low
"
:
1
,
"
Normal
"
:
2
,
"
High
"
:
3
}
tests
=
list
()
tests
=
list
()
for
name
in
names
:
for
name
in
names
:
if
name
in
ignored_tests
:
if
ignored_tests
and
name
in
ignored_tests
:
continue
continue
test_path
=
os
.
path
.
join
(
path
,
name
)
test_path
=
os
.
path
.
join
(
test_dir
,
name
)
if
os
.
path
.
isfile
(
test_path
):
if
os
.
path
.
isfile
(
test_path
):
criticality
,
description
=
self
.
parse_file_header
(
test_path
)
criticality
,
description
=
self
.
parse_file_header
(
test_path
)
tests
.
append
((
name
,
criticality
,
description
,
[
test_path
]))
tests
.
append
((
name
,
criticality
,
description
,
[
test_path
],
None
))
if
basic_only
:
return
tests
tests
.
sort
(
key
=
lambda
i
:
(
-
criticalities_map
.
get
(
i
[
1
],
0
),
i
[
0
]))
return
tests
def
discover_mediaserver_tests
(
self
,
msuser
=
None
,
no_update
=
False
,
ignored_tests
=
None
):
elif
msuser
:
tests
=
list
()
# Get MS instances
# Get MS instances
ms_users
=
list
()
ms_users
=
list
()
for
user
in
os
.
listdir
(
"
/home
"
):
for
user
in
os
.
listdir
(
"
/home
"
):
...
@@ -204,91 +214,96 @@ class Tester():
...
@@ -204,91 +214,96 @@ class Tester():
not
msuser
or
user
==
msuser
not
msuser
or
user
==
msuser
):
):
ms_users
.
append
(
user
)
ms_users
.
append
(
user
)
# Get MediaServer tests
if
not
ms_users
:
if
ms_users
:
return
list
()
ms_users
.
sort
()
ms_users
.
sort
()
cleaned_list
=
list
()
cleaned_list
=
list
()
instances_to_test
=
get_conf
(
"
TESTER_MS_INSTANCES
"
,
""
).
split
(
"
,
"
)
instances_to_test
=
get_conf
(
"
TESTER_MS_INSTANCES
"
,
""
).
split
(
"
,
"
)
if
instances_to_test
:
if
instances_to_test
:
for
val
in
instances_to_test
:
for
val
in
instances_to_test
:
val
=
val
.
strip
()
val
=
val
.
strip
()
if
not
val
:
if
not
val
:
continue
continue
if
val
in
ms_users
:
if
val
in
ms_users
:
cleaned_list
.
append
(
val
)
cleaned_list
.
append
(
val
)
else
:
else
:
print
(
print
(
'
An inexisting instance has been requested for tests:
"
%s
"
.
'
'
An inexisting instance has been requested for tests:
"
%s
"
.
'
%
val
%
val
)
if
cleaned_list
:
ms_users
=
cleaned_list
else
:
try
:
max_instances
=
int
(
get_conf
(
"
TESTER_MAX_INSTANCES
"
)
or
2
)
except
Exception
as
e
:
print
(
"
TESTER_MAX_INSTANCES has an invalid value: %s
"
%
e
)
max_instances
=
2
if
len
(
ms_users
)
>
max_instances
:
ms_users
=
ms_users
[:
max_instances
]
print
(
"
Instances that will be tested: %s.
"
%
"
,
"
.
join
(
ms_users
))
# Clone testing suite
ms_path
=
os
.
path
.
join
(
path
,
"
ms-testing-suite
"
)
if
not
os
.
path
.
exists
(
ms_path
):
print
(
'
Cloning ms-testing-suite in
"
%s
"
.
'
%
ms_path
)
subprocess
.
run
(
[
"
git
"
,
"
clone
"
,
"
--recursive
"
,
"
https://mirismanager.ubicast.eu/git/mediaserver/ms-testing-suite.git
"
,
ms_path
,
]
)
if
os
.
path
.
exists
(
ms_path
)
and
not
no_update
:
print
(
'
Updating ms-testing-suite in
"
%s
"
.
'
%
ms_path
)
os
.
chdir
(
ms_path
)
branch
=
get_conf
(
"
ENVSETUP_BRANCH
"
)
or
"
stable
"
if
branch
:
subprocess
.
run
([
"
git
"
,
"
checkout
"
,
branch
])
subprocess
.
run
([
"
git
"
,
"
fetch
"
,
"
--recurse-submodules
"
,
"
--all
"
])
subprocess
.
run
([
"
git
"
,
"
reset
"
,
"
--hard
"
,
"
origin/{}
"
.
format
(
branch
)])
subprocess
.
run
([
"
git
"
,
"
pull
"
,
"
--recurse-submodules
"
])
subprocess
.
run
([
"
git
"
,
"
submodule
"
,
"
update
"
,
"
--init
"
,
"
--recursive
"
])
os
.
chdir
(
self
.
root_dir
)
# Add tests to list
print
(
"
Add MediaServer tests if available.
"
)
wowza_dir
=
"
/usr/local/WowzaStreamingEngine
"
etc_lives_conf
=
"
/etc/mediaserver/lives.json
"
local_lives_conf
=
"
/home/%s/msinstance/conf/lives.json
"
old_etc_lives_conf
=
"
/etc/mediaserver/lives_conf.py
"
old_local_lives_conf
=
"
/home/%s/msinstance/conf/lives_conf.py
"
for
user
in
ms_users
:
ms_tests
=
[
"
ms_vod_tester.py
"
,
"
test_caches.py
"
]
# Check if live tests should be started
if
(
os
.
path
.
exists
(
wowza_dir
)
or
os
.
path
.
exists
(
etc_lives_conf
)
or
os
.
path
.
exists
(
local_lives_conf
%
user
)
or
os
.
path
.
exists
(
old_etc_lives_conf
)
or
os
.
path
.
exists
(
old_local_lives_conf
%
user
)
):
ms_tests
.
append
(
"
test_wowza_secure.py
"
)
ms_tests
.
append
(
"
ms_live_tester.py
"
)
for
name
in
ms_tests
:
if
name
in
ignored_tests
:
continue
test_path
=
os
.
path
.
join
(
ms_path
,
name
)
criticality
,
description
=
self
.
parse_file_header
(
test_path
)
tests
.
append
(
(
"
%s (%s)
"
%
(
name
,
user
),
criticality
,
description
,
[
test_path
,
user
],
)
)
)
tests
.
sort
(
key
=
lambda
i
:
(
-
criticalities_map
.
get
(
i
[
1
],
0
),
i
[
0
]))
if
cleaned_list
:
ms_users
=
cleaned_list
else
:
try
:
max_instances
=
int
(
get_conf
(
"
TESTER_MAX_INSTANCES
"
)
or
2
)
except
Exception
as
e
:
print
(
"
TESTER_MAX_INSTANCES has an invalid value: %s
"
%
e
)
max_instances
=
2
if
len
(
ms_users
)
>
max_instances
:
ms_users
=
ms_users
[:
max_instances
]
print
(
"
Instances that will be tested: %s.
"
%
"
,
"
.
join
(
ms_users
))
# Clone testing suite
ms_path
=
os
.
path
.
join
(
self
.
root_dir
,
"
scripts
"
,
"
ms-testing-suite
"
)
if
not
os
.
path
.
exists
(
ms_path
):
print
(
'
Cloning ms-testing-suite in
"
%s
"
.
'
%
ms_path
)
subprocess
.
run
(
[
"
git
"
,
"
clone
"
,
"
--recursive
"
,
"
https://mirismanager.ubicast.eu/git/mediaserver/ms-testing-suite.git
"
,
ms_path
,
]
)
if
not
os
.
path
.
exists
(
ms_path
):
print
(
'
The ms-testing-suite dir
"
%s
"
does not exist, no MediaServer test will be run.
'
%
ms_path
)
return
list
()
# Update testing suite if allowed
if
not
no_update
:
print
(
'
Updating ms-testing-suite in
"
%s
"
.
'
%
ms_path
)
os
.
chdir
(
ms_path
)
branch
=
get_conf
(
"
ENVSETUP_BRANCH
"
)
or
"
stable
"
if
branch
:
subprocess
.
run
([
"
git
"
,
"
checkout
"
,
branch
])
subprocess
.
run
([
"
git
"
,
"
fetch
"
,
"
--recurse-submodules
"
,
"
--all
"
])
subprocess
.
run
([
"
git
"
,
"
reset
"
,
"
--hard
"
,
"
origin/{}
"
.
format
(
branch
)])
subprocess
.
run
([
"
git
"
,
"
pull
"
,
"
--recurse-submodules
"
])
subprocess
.
run
([
"
git
"
,
"
submodule
"
,
"
update
"
,
"
--init
"
,
"
--recursive
"
])
os
.
chdir
(
self
.
root_dir
)
# Build tests list
print
(
"
Add MediaServer tests if available.
"
)
wowza_dir
=
"
/usr/local/WowzaStreamingEngine
"
etc_lives_conf
=
"
/etc/mediaserver/lives.json
"
local_lives_conf
=
"
/home/%s/msinstance/conf/lives.json
"
old_etc_lives_conf
=
"
/etc/mediaserver/lives_conf.py
"
old_local_lives_conf
=
"
/home/%s/msinstance/conf/lives_conf.py
"
tests
=
list
()
for
user
in
ms_users
:
ms_tests
=
[
"
ms_vod_tester.py
"
,
"
test_caches.py
"
]
# Check if live tests should be started
if
(
os
.
path
.
exists
(
wowza_dir
)
or
os
.
path
.
exists
(
etc_lives_conf
)
or
os
.
path
.
exists
(
local_lives_conf
%
user
)
or
os
.
path
.
exists
(
old_etc_lives_conf
)
or
os
.
path
.
exists
(
old_local_lives_conf
%
user
)
):
ms_tests
.
append
(
"
test_wowza_secure.py
"
)
ms_tests
.
append
(
"
ms_live_tester.py
"
)
ignore_rules
=
get_conf
(
"
TESTER_IGNORE_ROUTING_RULES
"
,
"
0
"
)
for
name
in
ms_tests
:
if
ignored_tests
and
name
in
ignored_tests
:
continue
test_path
=
os
.
path
.
join
(
ms_path
,
name
)
if
os
.
path
.
exists
(
test_path
):
criticality
,
description
=
self
.
parse_file_header
(
test_path
)
tests
.
append
((
"
%s (%s)
"
%
(
name
,
user
),
criticality
,
description
,
[
test_path
,
user
],
{
"
IGNORE_ROUTING_RULES
"
:
ignore_rules
},
))
return
tests
return
tests
def
run_tests
(
self
,
tests
,
send_email
=
False
,
send_email_if_fail
=
False
):
# noqa: C901
def
run_tests
(
self
,
tests
,
send_email
=
False
,
send_email_if_fail
=
False
):
# noqa: C901
...
@@ -299,7 +314,7 @@ class Tester():
...
@@ -299,7 +314,7 @@ class Tester():
report_rows
=
[(
"
Test
"
,
"
Criticality
"
,
"
Result
"
,
"
Duration
"
,
"
Description
"
)]
report_rows
=
[(
"
Test
"
,
"
Criticality
"
,
"
Result
"
,
"
Duration
"
,
"
Description
"
)]
report_rows_length
=
[
len
(
t
)
for
t
in
report_rows
[
0
]]
report_rows_length
=
[
len
(
t
)
for
t
in
report_rows
[
0
]]
out_of_support
=
False
out_of_support
=
False
for
name
,
criticality
,
description
,
command
in
tests
:
for
name
,
criticality
,
description
,
command
,
env
in
tests
:
print
(
'
\033
[1;95m-- Test
"
%s
"
--
\033
[0;0m
'
%
name
)
print
(
'
\033
[1;95m-- Test
"
%s
"
--
\033
[0;0m
'
%
name
)
start_date
=
datetime
.
datetime
.
utcnow
()
start_date
=
datetime
.
datetime
.
utcnow
()
print
(
"
Test start: %s UTC.
"
%
start_date
.
strftime
(
"
%Y-%m-%d %H:%M:%S
"
))
print
(
"
Test start: %s UTC.
"
%
start_date
.
strftime
(
"
%Y-%m-%d %H:%M:%S
"
))
...
@@ -307,11 +322,17 @@ class Tester():
...
@@ -307,11 +322,17 @@ class Tester():
count
=
0
count
=
0
while
count
<
3
:
while
count
<
3
:
if
count
>
0
:
if
count
>
0
:
time
.
sleep
(
5
*
count
*
count
)
wait_time
=
5
*
count
*
count
print
(
'
Waiting %s s...
'
%
wait_time
)
time
.
sleep
(
wait_time
)
count
+=
1
count
+=
1
print
(
"
Attempt: %s
"
%
str
(
count
))
print
(
"
Attempt: %s
"
%
str
(
count
))
test_env
=
dict
(
os
.
environ
)
if
env
:
test_env
.
update
(
env
)
p
=
subprocess
.
run
(
p
=
subprocess
.
run
(
command
,
command
,
env
=
test_env
,
stdin
=
subprocess
.
DEVNULL
,
stdin
=
subprocess
.
DEVNULL
,
stdout
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
stderr
=
subprocess
.
STDOUT
,
...
...
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