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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
d9a5ecd8
Commit
d9a5ecd8
authored
Dec 21, 2017
by
Julien Muchembled
Committed by
Klaus Wölfel
Sep 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testnode: more code clean up
parent
19ea2d81
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
144 additions
and
197 deletions
+144
-197
erp5/tests/testERP5TestNode.py
erp5/tests/testERP5TestNode.py
+62
-85
erp5/util/testnode/NodeTestSuite.py
erp5/util/testnode/NodeTestSuite.py
+11
-21
erp5/util/testnode/SlapOSControler.py
erp5/util/testnode/SlapOSControler.py
+1
-7
erp5/util/testnode/UnitTestRunner.py
erp5/util/testnode/UnitTestRunner.py
+11
-9
erp5/util/testnode/__init__.py
erp5/util/testnode/__init__.py
+6
-9
erp5/util/testnode/testnode.py
erp5/util/testnode/testnode.py
+53
-66
No files found.
erp5/tests/testERP5TestNode.py
View file @
d9a5ecd8
This diff is collapsed.
Click to expand it.
erp5/util/testnode/NodeTestSuite.py
View file @
d9a5ecd8
...
@@ -37,38 +37,28 @@ class SlapOSInstance(object):
...
@@ -37,38 +37,28 @@ class SlapOSInstance(object):
Base of an software instance,
Base of an software instance,
store variables used during software installation
store variables used during software installation
"""
"""
def
__init__
(
self
):
def
__init__
(
self
,
working_directory
):
self
.
retry_software_count
=
0
self
.
retry_software_count
=
0
self
.
retry
=
False
self
.
retry
=
False
self
.
working_directory
=
working_directory
def
edit
(
self
,
**
kw
):
self
.
__dict__
.
update
(
**
kw
)
self
.
_checkData
()
def
_checkData
(
self
):
pass
class
NodeTestSuite
(
SlapOSInstance
):
class
NodeTestSuite
(
SlapOSInstance
):
"""
"""
"""
"""
def
__init__
(
self
,
reference
):
def
__init__
(
self
,
reference
,
working_directory
):
super
(
NodeTestSuite
,
self
).
__init__
()
d
=
os
.
path
.
join
(
working_directory
,
reference
)
super
(
NodeTestSuite
,
self
).
__init__
(
d
)
self
.
reference
=
reference
self
.
reference
=
reference
self
.
cluster_configuration
=
{}
self
.
cluster_configuration
=
{}
self
.
test_suite_directory
=
os
.
path
.
join
(
d
,
'test_suite'
)
self
.
custom_profile_path
=
os
.
path
.
join
(
d
,
'software.cfg'
)
createFolder
(
d
)
def
_checkData
(
self
):
def
edit
(
self
,
**
kw
):
if
getattr
(
self
,
"working_directory"
,
None
)
is
not
None
:
self
.
__dict__
.
update
(
**
kw
)
if
not
(
self
.
working_directory
.
endswith
(
os
.
path
.
sep
+
self
.
reference
)):
for
vcs_repository
in
kw
.
get
(
'vcs_repository_list'
,
()):
self
.
working_directory
=
os
.
path
.
join
(
self
.
working_directory
,
self
.
reference
)
createFolder
(
self
.
working_directory
)
self
.
test_suite_directory
=
os
.
path
.
join
(
self
.
working_directory
,
"test_suite"
)
self
.
custom_profile_path
=
os
.
path
.
join
(
self
.
working_directory
,
'software.cfg'
)
if
getattr
(
self
,
"vcs_repository_list"
,
None
)
is
not
None
:
for
vcs_repository
in
self
.
vcs_repository_list
:
buildout_section_id
=
vcs_repository
.
get
(
'buildout_section_id'
)
buildout_section_id
=
vcs_repository
.
get
(
'buildout_section_id'
)
repository_id
=
buildout_section_id
or
\
repository_id
=
buildout_section_id
or
\
vcs_repository
.
get
(
'url'
).
split
(
'/'
)[
-
1
].
split
(
'.'
)[
0
]
vcs_repository
.
get
(
'url'
).
split
(
'/'
)[
-
1
].
split
(
'.'
)[
0
]
...
...
erp5/util/testnode/SlapOSControler.py
View file @
d9a5ecd8
...
@@ -99,12 +99,6 @@ class SlapOSControler(object):
...
@@ -99,12 +99,6 @@ class SlapOSControler(object):
else
:
else
:
raise
ValueError
(
"Configuration file not found."
)
raise
ValueError
(
"Configuration file not found."
)
def
getInstanceRequestedState
(
self
,
reference
):
try
:
return
self
.
instance_config
[
reference
][
'requested_state'
]
except
Exception
:
raise
ValueError
(
"Instance '%s' not exist"
%
self
.
instance_config
[
reference
])
def
request
(
self
,
reference
,
software_url
,
software_type
=
None
,
def
request
(
self
,
reference
,
software_url
,
software_type
=
None
,
software_configuration
=
None
,
computer_guid
=
None
,
state
=
'started'
):
software_configuration
=
None
,
computer_guid
=
None
,
state
=
'started'
):
"""
"""
...
@@ -219,7 +213,7 @@ class SlapOSControler(object):
...
@@ -219,7 +213,7 @@ class SlapOSControler(object):
self
.
software_path_list
=
software_path_list
self
.
software_path_list
=
software_path_list
self
.
log
(
'SlapOSControler, initialize, reset_software: %r'
,
reset_software
)
self
.
log
(
'SlapOSControler, initialize, reset_software: %r'
,
reset_software
)
config
=
self
.
config
config
=
self
.
config
slapos_config_dict
=
self
.
config
.
copy
()
slapos_config_dict
=
config
.
copy
()
slapos_config_dict
.
update
(
software_root
=
self
.
software_root
,
slapos_config_dict
.
update
(
software_root
=
self
.
software_root
,
instance_root
=
self
.
instance_root
,
instance_root
=
self
.
instance_root
,
proxy_database
=
self
.
proxy_database
)
proxy_database
=
self
.
proxy_database
)
...
...
erp5/util/testnode/UnitTestRunner.py
View file @
d9a5ecd8
...
@@ -102,7 +102,7 @@ class UnitTestRunner(object):
...
@@ -102,7 +102,7 @@ class UnitTestRunner(object):
# report-url, report-project and suite-url are required to seleniumrunner
# report-url, report-project and suite-url are required to seleniumrunner
# instance. This is a hack which must be removed.
# instance. This is a hack which must be removed.
config
=
self
.
testnode
.
config
config
=
self
.
testnode
.
config
return
self
.
_prepareSlapOS
(
config
[
'slapos_directory'
]
,
return
self
.
_prepareSlapOS
(
test_node_slapos
.
working_directory
,
test_node_slapos
,
self
.
testnode
.
log
,
create_partition
=
0
,
test_node_slapos
,
self
.
testnode
.
log
,
create_partition
=
0
,
software_path_list
=
config
.
get
(
"software_list"
),
software_path_list
=
config
.
get
(
"software_list"
),
cluster_configuration
=
{
cluster_configuration
=
{
...
@@ -120,16 +120,18 @@ class UnitTestRunner(object):
...
@@ -120,16 +120,18 @@ class UnitTestRunner(object):
software_path_list
=
[
node_test_suite
.
custom_profile_path
],
software_path_list
=
[
node_test_suite
.
custom_profile_path
],
cluster_configuration
=
{
'_'
:
json
.
dumps
(
node_test_suite
.
cluster_configuration
)})
cluster_configuration
=
{
'_'
:
json
.
dumps
(
node_test_suite
.
cluster_configuration
)})
def
getInstanceRoot
(
self
,
node_test_suite
):
return
self
.
_getSlapOSControler
(
node_test_suite
.
working_directory
).
instance_root
def
runTestSuite
(
self
,
node_test_suite
,
portal_url
,
log
=
None
):
def
runTestSuite
(
self
,
node_test_suite
,
portal_url
,
log
=
None
):
config
=
self
.
testnode
.
config
config
=
self
.
testnode
.
config
parameter_list
=
[]
run_test_suite_path_list
=
glob
.
glob
(
slapos_controler
=
self
.
_getSlapOSControler
(
self
.
testnode
.
working_directory
)
self
.
getInstanceRoot
(
node_test_suite
)
+
"/*/bin/runTestSuite"
)
run_test_suite_path_list
=
sorted
(
glob
.
glob
(
"%s/*/bin/runTestSuite"
%
\
try
:
slapos_controler
.
instance_root
)
)
run_test_suite_path
=
min
(
run_test_suite_path_list
)
if
not
len
(
run_test_suite_path_list
)
:
except
ValueError
:
raise
ValueError
(
'No runTestSuite provided in installed partitions.'
)
raise
ValueError
(
'No runTestSuite provided in installed partitions.'
)
run_test_suite_path
=
run_test_suite_path_list
[
0
]
run_test_suite_revision
=
node_test_suite
.
revision
# Deal with Shebang size limitation
# Deal with Shebang size limitation
invocation_list
=
dealShebang
(
run_test_suite_path
)
invocation_list
=
dealShebang
(
run_test_suite_path
)
invocation_list
+=
(
run_test_suite_path
,
invocation_list
+=
(
run_test_suite_path
,
...
@@ -172,4 +174,4 @@ class UnitTestRunner(object):
...
@@ -172,4 +174,4 @@ class UnitTestRunner(object):
Used by the method testnode.constructProfile() to know
Used by the method testnode.constructProfile() to know
if the software.cfg have to use relative path or not.
if the software.cfg have to use relative path or not.
"""
"""
return
False
return
False
\ No newline at end of file
erp5/util/testnode/__init__.py
View file @
d9a5ecd8
...
@@ -29,14 +29,8 @@ import argparse
...
@@ -29,14 +29,8 @@ import argparse
import
logging
import
logging
import
logging.handlers
import
logging.handlers
import
os
import
os
import
pkg_resources
from
testnode
import
TestNode
from
.testnode
import
TestNode
CONFIG
=
{
'computer_id'
:
'COMPUTER'
,
'partition_reference'
:
'test0'
,
}
def
main
(
*
args
):
def
main
(
*
args
):
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
@@ -54,6 +48,10 @@ def main(*args):
...
@@ -54,6 +48,10 @@ def main(*args):
logging
.
basicConfig
(
level
=
logging
.
INFO
,
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
logger_format
)
format
=
logger_format
)
logger
=
logging
.
getLogger
(
'erp5testnode'
)
logger
=
logging
.
getLogger
(
'erp5testnode'
)
CONFIG
=
{
'logger'
:
logger
.
info
,
'partition_reference'
:
'test0'
,
}
if
parsed_argument
.
console
or
parsed_argument
.
logfile
:
if
parsed_argument
.
console
or
parsed_argument
.
logfile
:
if
parsed_argument
.
console
:
if
parsed_argument
.
console
:
logger
.
addHandler
(
logging
.
StreamHandler
())
logger
.
addHandler
(
logging
.
StreamHandler
())
...
@@ -64,11 +62,10 @@ def main(*args):
...
@@ -64,11 +62,10 @@ def main(*args):
maxBytes
=
20000000
,
backupCount
=
4
)
maxBytes
=
20000000
,
backupCount
=
4
)
file_handler
.
setFormatter
(
formatter
)
file_handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
file_handler
)
logger
.
addHandler
(
file_handler
)
logger
.
info
(
'Activated logfile %r output'
%
parsed_argument
.
logfile
)
logger
.
info
(
'Activated logfile %r output'
,
parsed_argument
.
logfile
)
CONFIG
[
'log_file'
]
=
parsed_argument
.
logfile
CONFIG
[
'log_file'
]
=
parsed_argument
.
logfile
else
:
else
:
logger
.
addHandler
(
logging
.
NullHandler
())
logger
.
addHandler
(
logging
.
NullHandler
())
CONFIG
[
'logger'
]
=
logger
.
info
config
=
ConfigParser
.
SafeConfigParser
()
config
=
ConfigParser
.
SafeConfigParser
()
# do not change case of option keys
# do not change case of option keys
config
.
optionxform
=
str
config
.
optionxform
=
str
...
...
erp5/util/testnode/testnode.py
View file @
d9a5ecd8
This diff is collapsed.
Click to expand it.
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