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
Sven Franck
erp5
Commits
89d983cc
Commit
89d983cc
authored
Jun 05, 2013
by
Benjamin Blanc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change structure of testnode files
parent
1392ba2e
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
436 additions
and
84 deletions
+436
-84
erp5/tests/testERP5TestNode.py
erp5/tests/testERP5TestNode.py
+1
-1
erp5/util/testnode/NodeTestSuite.py
erp5/util/testnode/NodeTestSuite.py
+101
-0
erp5/util/testnode/ScalabilityTestRunner.py
erp5/util/testnode/ScalabilityTestRunner.py
+49
-0
erp5/util/testnode/SlapOSControler.py
erp5/util/testnode/SlapOSControler.py
+96
-2
erp5/util/testnode/UnitTestRunner.py
erp5/util/testnode/UnitTestRunner.py
+69
-0
erp5/util/testnode/Updater.py
erp5/util/testnode/Updater.py
+1
-1
erp5/util/testnode/__init__.py
erp5/util/testnode/__init__.py
+3
-0
erp5/util/testnode/testnode.py
erp5/util/testnode/testnode.py
+116
-80
No files found.
erp5/tests/testERP5TestNode.py
View file @
89d983cc
from
unittest
import
TestCase
from
erp5.util.testnode.testnode
import
TestNode
from
erp5.util.testnode.
testnod
e
import
SlapOSInstance
from
erp5.util.testnode.
NodeTestSuit
e
import
SlapOSInstance
from
erp5.util.testnode.ProcessManager
import
ProcessManager
,
SubprocessError
from
erp5.util.testnode.SlapOSControler
import
SlapOSControler
...
...
erp5/util/testnode/NodeTestSuite.py
0 → 100644
View file @
89d983cc
##############################################################################
#
# Copyright (c) 2011 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
datetime
import
datetime
,
timedelta
import
os
import
subprocess
import
sys
import
time
import
glob
import
SlapOSControler
import
json
import
time
import
shutil
import
logging
import
string
import
random
from
ProcessManager
import
SubprocessError
,
ProcessManager
,
CancellationError
from
subprocess
import
CalledProcessError
from
Updater
import
Updater
from
erp5.util
import
taskdistribution
class
SlapOSInstance
(
object
):
def
__init__
(
self
):
self
.
retry_software_count
=
0
self
.
retry
=
False
def
edit
(
self
,
**
kw
):
self
.
__dict__
.
update
(
**
kw
)
self
.
_checkData
()
def
_checkData
(
self
):
pass
class
NodeTestSuite
(
SlapOSInstance
):
def
__init__
(
self
,
reference
):
super
(
NodeTestSuite
,
self
).
__init__
()
self
.
reference
=
reference
def
edit
(
self
,
**
kw
):
super
(
NodeTestSuite
,
self
).
edit
(
**
kw
)
def
_checkData
(
self
):
if
getattr
(
self
,
"working_directory"
,
None
)
is
not
None
:
if
not
(
self
.
working_directory
.
endswith
(
os
.
path
.
sep
+
self
.
reference
)):
self
.
working_directory
=
os
.
path
.
join
(
self
.
working_directory
,
self
.
reference
)
SlapOSControler
.
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'
,
None
)
repository_id
=
buildout_section_id
or
\
vcs_repository
.
get
(
'url'
).
split
(
'/'
)[
-
1
].
split
(
'.'
)[
0
]
repository_path
=
os
.
path
.
join
(
self
.
working_directory
,
repository_id
)
vcs_repository
[
'repository_id'
]
=
repository_id
vcs_repository
[
'repository_path'
]
=
repository_path
def
createSuiteLog
(
self
):
# /srv/slapgrid/slappartXX/srv/var/log/testnode/az-mlksjfmlk234Sljssdflkj23KSdfslj/suite.log
alphabets
=
string
.
digits
+
string
.
letters
rand_part
=
''
.
join
(
random
.
choice
(
alphabets
)
for
i
in
xrange
(
32
))
random_suite_folder_id
=
'%s-%s'
%
(
self
.
reference
,
rand_part
)
suite_log_directory
=
os
.
path
.
join
(
self
.
log_directory
,
random_suite_folder_id
)
SlapOSControler
.
createFolders
(
suite_log_directory
)
self
.
suite_log_path
=
os
.
path
.
join
(
suite_log_directory
,
'suite.log'
)
return
self
.
getSuiteLogPath
(),
random_suite_folder_id
def
getSuiteLogPath
(
self
):
return
getattr
(
self
,
"suite_log_path"
,
None
)
erp5/util/testnode/ScalabilityTestRunner.py
0 → 100644
View file @
89d983cc
##############################################################################
#
# Copyright (c) 2011 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
datetime
import
datetime
,
timedelta
import
os
import
subprocess
import
sys
import
time
import
glob
import
SlapOSControler
import
json
import
time
import
shutil
import
logging
import
string
import
random
from
ProcessManager
import
SubprocessError
,
ProcessManager
,
CancellationError
from
subprocess
import
CalledProcessError
from
Updater
import
Updater
from
erp5.util
import
taskdistribution
class
ScalabilityTestRunner
(
object
):
def
__init__
(
self
):
pass
erp5/util/testnode/SlapOSControler.py
View file @
89d983cc
...
...
@@ -56,16 +56,110 @@ def createFile(path, mode, content):
# error
pass
class
SlapOSControler
(
object
):
class
GenericSlapOSControler
(
object
):
def
__init__
(
self
,
working_directory
,
config
,
log
):
self
.
config
=
config
self
.
software_root
=
os
.
path
.
join
(
working_directory
,
'soft'
)
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'
)
self
.
log
=
log
def
_resetSoftware
(
self
):
pass
def
initializeSlapOSControler
(
self
):
pass
def
runSoftwareRelease
(
self
):
pass
def
runComputerPartition
(
self
):
pass
class
SlapOSControlerCluster
(
GenericSlapOSControler
):
def
__init__
(
self
,
working_directory
,
config
,
log
,
configuration_path_file
):
GenericSlapOSControler
.
__init__
(
self
,
working_directory
,
config
,
log
)
self
.
configuration_path_file
=
configuration_path_file
def
initializeSlapOSControler
(
software_path_list
=
None
,
computer_guid
=
None
):
"""
Supply several softwares from a list on a node
Ex :
slapos_controler.initializeSlapOSControler(['kvm.cfg', 'ok.cfg'], 'COMP-726')
"""
for
software_path
in
software_path_list
:
self
.
_supply
(
software_path
,
computer_guid
)
def
_supply
(
self
,
software_url
,
computer_id
):
"""
Ex :
slapos_controler._supply('kvm.cfg', 'COMP-726')
"""
# TODO : remove return
return
self
.
log
(
'SlapOSControler : _supply'
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"configuration_file"
)
parser
.
add_argument
(
"software_url"
)
parser
.
add_argument
(
"node"
)
if
os
.
path
.
exists
(
configuration_file_path
):
args
=
parser
.
parse_args
([
self
.
configuration_file_path
,
software_url
,
computer_id
])
config
=
client
.
Config
(
args
,
args
.
configuration_file
)
client
.
_supply
(
args
.
software_url
,
args
.
node
,
client
.
init
(
config
))
else
:
raise
ValueError
(
"Configuration file not found."
)
def
_request
(
self
,
reference
,
software_url
,
software_type
,
software_configuration
,
computer_guid
=
None
):
"""
configuration_file_path (slapos acount)
reference : instance title
software_url
software_type : cluster/single
software_configuration : dict { "_" : "{'toto' : 'titi'}" }
Ex :
slapos_controler._request('Instance16h34Ben',
'kvm.cfg', 'cluster', { "_" : "{'toto' : 'titi'}" } )
"""
# TODO : remove return
return
self
.
log
(
'SlapOSControler : _request'
)
filter_kw
=
None
if
computer_guid
!=
None
:
filter_kw
=
{
"computer_guid"
:
computer_guid
}
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"configuration_file"
)
args
=
parser
.
parse_args
([
self
.
configuration_file_path
])
config
=
client
.
Config
(
args
,
args
.
configuration_file
)
local
=
client
.
init
(
config
)
partition
=
local
[
'slap'
].
registerOpenOrder
().
request
(
software_release
=
software_url
,
partition_reference
=
reference
,
partition_parameter_kw
=
software_configuration
,
software_type
=
software_type
,
filter_kw
=
filter_kw
)
# print "Instance requested.\nState is : %s." % partition.getState()
# Is it possible to have the true state of the instance with getState() ?
class
SlapOSControler
(
GenericSlapOSControler
):
def
__init__
(
self
,
working_directory
,
config
,
log
):
GenericSlapOSControler
.
__init__
(
self
,
working_directory
,
config
,
log
)
self
.
proxy_database
=
os
.
path
.
join
(
working_directory
,
'proxy.db'
)
def
_resetSoftware
(
self
):
self
.
log
(
'SlapOSControler : GOING TO RESET ALL SOFTWARE : %r'
%
(
self
.
software_root
,))
...
...
erp5/util/testnode/UnitTestRunner.py
0 → 100644
View file @
89d983cc
##############################################################################
#
# Copyright (c) 2011 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
datetime
import
datetime
,
timedelta
import
os
import
subprocess
import
sys
import
time
import
glob
import
SlapOSControler
import
json
import
time
import
shutil
import
logging
import
string
import
random
from
ProcessManager
import
SubprocessError
,
ProcessManager
,
CancellationError
from
subprocess
import
CalledProcessError
from
Updater
import
Updater
from
erp5.util
import
taskdistribution
class
UnitTestRunner
(
object
):
def
__init__
(
self
,
testnode
):
pass
erp5/util/testnode/Updater.py
View file @
89d983cc
...
...
@@ -31,7 +31,7 @@ import subprocess
import
sys
import
threading
from
testnode
import
SubprocessError
from
ProcessManager
import
SubprocessError
SVN_UP_REV
=
re
.
compile
(
r'^(?:At|Updated to) revision (\
d+).$
')
SVN_CHANGED_REV = re.compile(r'
^
Last
Changed
Rev
.
*
:
\
s
*
(
\
d
+
)
', re.MULTILINE)
...
...
erp5/util/testnode/__init__.py
View file @
89d983cc
...
...
@@ -108,5 +108,8 @@ def main(*args):
CONFIG
[
'software_list'
]
=
filter
(
None
,
config
.
get
(
"software_list"
,
"path_list"
).
split
(
","
))
# Here : can we know the test type (scalability or unittest) ?
# If it's possible, :
# testnode = Testnode / ScalabilityTestNode
testnode
=
TestNode
(
logger
.
info
,
CONFIG
)
testnode
.
run
()
erp5/util/testnode/testnode.py
View file @
89d983cc
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