Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
francois
erp5
Commits
d8c7bf4e
Commit
d8c7bf4e
authored
Nov 14, 2012
by
Pere Cortes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5testnode: getSupportedParameterList & runTestSuite Unit Tests
parent
de259398
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
4 deletions
+90
-4
erp5/tests/testERP5TestNode.py
erp5/tests/testERP5TestNode.py
+72
-1
erp5/util/testnode/ProcessManager.py
erp5/util/testnode/ProcessManager.py
+6
-0
erp5/util/testnode/SlapOSControler.py
erp5/util/testnode/SlapOSControler.py
+3
-1
erp5/util/testnode/testnode.py
erp5/util/testnode/testnode.py
+9
-2
No files found.
erp5/tests/testERP5TestNode.py
View file @
d8c7bf4e
...
...
@@ -22,6 +22,8 @@ sys.path.extend([
])
from
erp5.util.testnode
import
TestNode
from
erp5.util.testnode.ProcessManager
import
ProcessManager
from
erp5.util.testnode.SlapOSControler
import
SlapOSControler
import
os
import
shutil
import
subprocess
...
...
@@ -33,11 +35,13 @@ class ERP5TestNode(TestCase):
self
.
_temp_dir
=
tempfile
.
mkdtemp
()
self
.
working_directory
=
os
.
path
.
join
(
self
.
_temp_dir
,
'testnode'
)
self
.
slapos_directory
=
os
.
path
.
join
(
self
.
_temp_dir
,
'slapos'
)
self
.
test_suite_directory
=
os
.
path
.
join
(
self
.
_temp_dir
,
'test_suite'
)
self
.
remote_repository0
=
os
.
path
.
join
(
self
.
_temp_dir
,
'rep0'
)
self
.
remote_repository1
=
os
.
path
.
join
(
self
.
_temp_dir
,
'rep1'
)
self
.
remote_repository2
=
os
.
path
.
join
(
self
.
_temp_dir
,
'rep2'
)
os
.
mkdir
(
self
.
working_directory
)
os
.
mkdir
(
self
.
slapos_directory
)
os
.
mkdir
(
self
.
test_suite_directory
)
os
.
mkdir
(
self
.
remote_repository0
)
os
.
mkdir
(
self
.
remote_repository1
)
os
.
mkdir
(
self
.
remote_repository2
)
...
...
@@ -52,7 +56,10 @@ class ERP5TestNode(TestCase):
# XXX how to get property the git path ?
config
=
{}
config
[
"git_binary"
]
=
"/srv/slapgrid/slappart80/srv/runner/software/ba1e09f3364989dc92da955b64e72f8d/parts/git/bin/git"
config
[
"working_directory"
]
=
self
.
working_directory
config
[
"slapos_directory"
]
=
config
[
"working_directory"
]
=
self
.
working_directory
config
[
"node_quantity"
]
=
3
config
[
"test_suite_directory"
]
=
self
.
test_suite_directory
return
TestNode
(
log
,
config
)
def
getTestSuiteData
(
self
,
add_third_repository
=
False
):
...
...
@@ -267,3 +274,67 @@ branch = foo
set
(
os
.
listdir
(
self
.
working_directory
)))
test_node
.
checkOldTestSuite
(
test_suite_data
)
self
.
assertEquals
([
'foo'
],
os
.
listdir
(
self
.
working_directory
))
def
test_08_getSupportedParamaterSet
(
self
):
original_spawn
=
ProcessManager
.
spawn
try
:
def
get_help
(
self
,
*
args
,
**
kw
):
return
{
'stdout'
:
"""My Program
--foo foo
--bar bar"""
}
ProcessManager
.
spawn
=
get_help
process_manager
=
ProcessManager
(
log
=
None
)
parameter_list
=
[
'--foo'
,
'--baz'
]
expected_suported_parameter_set
=
set
([
'--foo'
])
supported_parameter_set
=
process_manager
.
getSupportedParameterSet
(
"dummy_program_path"
,
parameter_list
)
self
.
assertEquals
(
expected_suported_parameter_set
,
supported_parameter_set
)
finally
:
ProcessManager
.
spawn
=
original_spawn
def
test_09_runTestSuite
(
self
):
"""
Check parameters passed to runTestSuite
Also make sure that --firefox_bin and --xvfb_bin are passed when needed
"""
def
_createPath
(
path_to_create
,
end_path
):
os
.
makedirs
(
path_to_create
)
return
os
.
close
(
os
.
open
(
os
.
path
.
join
(
path_to_create
,
end_path
),
os
.
O_CREAT
))
def
get_parameters
(
self
,
*
args
,
**
kw
):
call_parameter_list
.
append
({
'args'
:
[
x
for
x
in
args
],
'kw'
:
kw
})
def
patch_getSupportedParameterSet
(
self
,
run_test_suite_path
,
parameter_list
,):
if
'--firefox_bin'
and
'--xvfb_bin'
in
parameter_list
:
return
set
([
'--firefox_bin'
,
'--xvfb_bin'
])
else
:
return
[]
test_node
=
self
.
getTestNode
()
test_node
.
slapos_controler
=
SlapOSControler
(
self
.
working_directory
,
test_node
.
config
,
test_node
.
log
)
node_test_suite
=
test_node
.
getNodeTestSuite
(
'foo'
)
self
.
updateNodeTestSuiteData
(
node_test_suite
)
node_test_suite
.
revision
=
'dummy'
run_test_suite_path
=
_createPath
(
os
.
path
.
join
(
test_node
.
slapos_controler
.
instance_root
,
'a/bin'
),
'runTestSuite'
)
def
checkRunTestSuiteParameters
(
additional_parameter_list
=
None
):
ProcessManager
.
getSupportedParameterSet
=
patch_getSupportedParameterSet
ProcessManager
.
spawn
=
get_parameters
test_node
.
runTestSuite
(
node_test_suite
,
"http://foo.bar"
)
expected_parameter_list
=
[
'%s/a/bin/runTestSuite'
%
(
test_node
.
slapos_controler
.
instance_root
),
'--test_suite'
,
'Foo'
,
'--revision'
,
'dummy'
,
'--test_suite_title'
,
'Foo-Test'
,
'--node_quantity'
,
3
,
'--master_url'
,
'http://foo.bar'
]
if
additional_parameter_list
:
expected_parameter_list
.
extend
(
additional_parameter_list
)
self
.
assertEqual
(
call_parameter_list
[
0
][
'args'
],
expected_parameter_list
)
call_parameter_list
=
[]
checkRunTestSuiteParameters
()
_createPath
(
os
.
path
.
join
(
test_node
.
config
[
'slapos_directory'
],
'soft/a/parts/firefox'
),
'firefox-slapos'
)
_createPath
(
os
.
path
.
join
(
test_node
.
config
[
'slapos_directory'
],
'soft/a/parts/xserver/bin'
),
'Xvfb'
)
call_parameter_list
=
[]
checkRunTestSuiteParameters
(
additional_parameter_list
=
[
'--firefox_bin'
,
'%s/soft/a/parts/firefox/firefox-slapos'
%
(
test_node
.
config
[
'slapos_directory'
]),
'--xvfb_bin'
,
'%s/soft/a/parts/xserver/bin/Xvfb'
%
(
test_node
.
config
[
'slapos_directory'
])])
erp5/util/testnode/ProcessManager.py
View file @
d8c7bf4e
...
...
@@ -131,6 +131,12 @@ class ProcessManager(object):
raise
SubprocessError
(
result
)
return
result
def
getSupportedParameterSet
(
self
,
program_path
,
parameter_list
):
help_string
=
self
.
spawn
(
*
[
program_path
,
'--help'
])[
'stdout'
]
help_words
=
set
(
help_string
.
split
())
return
help_words
.
intersection
(
set
(
parameter_list
))
def
killPreviousRun
(
self
,
cancellation
=
False
):
self
.
log
(
'ProcessManager killPreviousRun, going to kill %r'
%
(
self
.
process_pid_set
,))
if
cancellation
:
...
...
erp5/util/testnode/SlapOSControler.py
View file @
d8c7bf4e
...
...
@@ -53,7 +53,9 @@ class SlapOSControler(object):
self
.
instance_root
=
os
.
path
.
join
(
working_directory
,
'inst'
)
self
.
slapos_config
=
os
.
path
.
join
(
working_directory
,
'slapos.cfg'
)
self
.
proxy_database
=
os
.
path
.
join
(
working_directory
,
'proxy.db'
)
slapos_config_dict
=
config
.
copy
()
def
initializeSlapOSControler
(
self
):
slapos_config_dict
=
self
.
config
.
copy
()
slapos_config_dict
.
update
(
software_root
=
self
.
software_root
,
instance_root
=
self
.
instance_root
,
proxy_database
=
self
.
proxy_database
)
...
...
erp5/util/testnode/testnode.py
View file @
d8c7bf4e
...
...
@@ -233,6 +233,7 @@ branch = %(branch)s
working_directory
,
self
.
config
,
log
=
self
.
log
,
slapproxy_log
=
slapproxy_log
,
process_manager
=
self
.
process_manager
,
reset_software
=
reset_software
,
software_path_list
=
software_path_list
)
self
.
slapos_controler
.
initializeSlapOSControler
()
self
.
process_manager
.
supervisord_pid_file
=
os
.
path
.
join
(
\
self
.
slapos_controler
.
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)
method_list
=
[
"runSoftwareRelease"
]
...
...
@@ -274,7 +275,7 @@ branch = %(branch)s
def
runTestSuite
(
self
,
node_test_suite
,
portal_url
):
config
=
self
.
config
parameter_list
=
[]
run_test_suite_path_list
=
glob
.
glob
(
"%s/*/bin/runTestSuite"
%
\
self
.
slapos_controler
.
instance_root
)
if
not
len
(
run_test_suite_path_list
):
...
...
@@ -292,10 +293,16 @@ branch = %(branch)s
firefox_bin_list
=
glob
.
glob
(
"%s/soft/*/parts/firefox/firefox-slapos"
%
\
config
[
"slapos_directory"
])
if
len
(
firefox_bin_list
):
invocation_list
.
extend
([
"--firefox_bin"
,
firefox_bin_list
[
0
]]
)
parameter_list
.
append
(
'--firefox_bin'
)
xvfb_bin_list
=
glob
.
glob
(
"%s/soft/*/parts/xserver/bin/Xvfb"
%
\
config
[
"slapos_directory"
])
if
len
(
xvfb_bin_list
):
parameter_list
.
append
(
'--xvfb_bin'
)
supported_paramater_set
=
self
.
process_manager
.
getSupportedParameterSet
(
run_test_suite_path
,
parameter_list
)
if
'--firefox_bin'
in
supported_paramater_set
:
invocation_list
.
extend
([
"--firefox_bin"
,
firefox_bin_list
[
0
]])
if
'--xvfb_bin'
in
supported_paramater_set
:
invocation_list
.
extend
([
"--xvfb_bin"
,
xvfb_bin_list
[
0
]])
bt5_path_list
=
config
.
get
(
"bt5_path"
)
if
bt5_path_list
not
in
(
''
,
None
,):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment