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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
erp5
Commits
bac6a51f
Commit
bac6a51f
authored
Jul 22, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert from recipe to tool.
Use argparse and configparser in order to being able to pass parameters.
parent
e813bca5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
121 deletions
+69
-121
erp5/util/testnode/__init__.py
erp5/util/testnode/__init__.py
+68
-119
erp5/util/testnode/testnode.py
erp5/util/testnode/testnode.py
+1
-2
No files found.
erp5/util/testnode/__init__.py
View file @
bac6a51f
##############################################################################
##############################################################################
#
#
# Copyright (c) 2010
Vifib SARL
and Contributors. All Rights Reserved.
# Copyright (c) 2010
Nexedi SA
and Contributors. All Rights Reserved.
#
#
# WARNING: This program as such is intended to be used by professional
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advi
c
ed to contract a Free Software
# guarantees and support are strongly advi
s
ed to contract a Free Software
# Service Company
# Service Company
#
#
# This program is Free Software; you can redistribute it and/or
# This program is Free Software; you can redistribute it and/or
...
@@ -24,136 +24,85 @@
...
@@ -24,136 +24,85 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
##############################################################################
##############################################################################
from
slapos.recipe.librecipe
import
BaseSlapRecipe
import
ConfigParser
import
argparse
import
os
import
os
import
pkg_resources
import
pkg_resources
import
zc.buildout
import
zc.recipe.egg
import
sys
import
sys
import
testnode
CONFIG
=
dict
(
CONFIG
=
dict
(
proxy_port
=
'5000'
,
computer_id
=
'COMPUTER'
,
computer_id
=
'COMPUTER'
,
partition_reference
=
'test0'
,
partition_reference
=
'test0'
,
)
)
class
Recipe
(
BaseSlapRecipe
):
def
main
(
*
args
):
def
__init__
(
self
,
buildout
,
name
,
options
):
parser
=
argparse
.
ArgumentParser
()
self
.
egg
=
zc
.
recipe
.
egg
.
Egg
(
buildout
,
options
[
'recipe'
],
options
)
parser
.
add_argument
(
"configuration_file"
,
nargs
=
1
,
type
=
argparse
.
FileType
(),
BaseSlapRecipe
.
__init__
(
self
,
buildout
,
name
,
options
)
help
=
"Configuration file."
)
if
args
:
def
installSlapOs
(
self
):
parsed_argument
=
parser
.
parse_args
(
list
(
args
))
CONFIG
[
'slapos_directory'
]
=
self
.
createDataDirectory
(
'slapos'
)
else
:
CONFIG
[
'working_directory'
]
=
self
.
createDataDirectory
(
'testnode'
)
parsed_argument
=
parser
.
parse_args
()
CONFIG
[
'software_root'
]
=
os
.
path
.
join
(
CONFIG
[
'slapos_directory'
],
config
=
ConfigParser
.
SafeConfigParser
()
config
.
readfp
(
parsed_argument
.
configuration_file
[
0
])
def
geto
(
o
):
return
config
.
get
(
'testnode'
,
o
)
CONFIG
[
'slapos_directory'
]
=
geto
(
'slapos_directory'
)
CONFIG
[
'working_directory'
]
=
geto
(
'working_directory'
)
for
d
in
CONFIG
[
'slapos_directory'
],
CONFIG
[
'working_directory'
]:
if
not
os
.
path
.
isdir
(
d
):
raise
ValueError
(
'Directory %r does not exists.'
%
d
)
CONFIG
[
'software_root'
]
=
os
.
path
.
join
(
CONFIG
[
'slapos_directory'
],
'software'
)
'software'
)
CONFIG
[
'instance_root'
]
=
os
.
path
.
join
(
CONFIG
[
'slapos_directory'
],
CONFIG
[
'instance_root'
]
=
os
.
path
.
join
(
CONFIG
[
'slapos_directory'
],
'instance'
)
'instance'
)
CONFIG
[
'proxy_database'
]
=
os
.
path
.
join
(
CONFIG
[
'slapos_directory'
],
for
d
in
CONFIG
[
'software_root'
],
CONFIG
[
'instance_root'
]:
if
not
os
.
path
.
lexists
(
d
):
os
.
mkdir
(
d
)
CONFIG
[
'proxy_database'
]
=
os
.
path
.
join
(
CONFIG
[
'slapos_directory'
],
'proxy.db'
)
'proxy.db'
)
CONFIG
[
'proxy_host'
]
=
self
.
getLocalIPv4Address
()
CONFIG
[
'proxy_host'
]
=
geto
(
'proxy_host'
)
CONFIG
[
'master_url'
]
=
'http://%s:%s'
%
(
CONFIG
[
'proxy_host'
],
CONFIG
[
'proxy_port'
]
=
geto
(
'proxy_port'
)
CONFIG
[
'master_url'
]
=
'http://%s:%s'
%
(
CONFIG
[
'proxy_host'
],
CONFIG
[
'proxy_port'
])
CONFIG
[
'proxy_port'
])
self
.
_createDirectory
(
CONFIG
[
'software_root'
])
slapos_config
=
pkg_resources
.
resource_string
(
'erp5.util.testnode'
,
self
.
_createDirectory
(
CONFIG
[
'instance_root'
])
'template/slapos.cfg.in'
)
CONFIG
[
'slapos_config'
]
=
self
.
createConfigurationFile
(
'slapos.cfg'
,
slapos_config
=
slapos_config
%
CONFIG
self
.
substituteTemplate
(
pkg_resources
.
resource_filename
(
__name__
,
CONFIG
[
'slapos_config'
]
=
os
.
path
.
join
(
CONFIG
[
'slapos_directory'
],
'template/slapos.cfg.in'
),
CONFIG
))
'slapos.cfg'
)
self
.
path_list
.
append
(
CONFIG
[
'slapos_config'
])
open
(
CONFIG
[
'slapos_config'
],
'w'
).
write
(
slapos_config
)
CONFIG
[
'git_binary'
]
=
geto
(
'git_binary'
)
def
setupRunningWrapper
(
self
):
CONFIG
[
'zip_binary'
]
=
geto
(
'zip_binary'
)
self
.
path_list
.
extend
(
zc
.
buildout
.
easy_install
.
scripts
([(
CONFIG
[
'runUnitTest'
]
=
os
.
path
.
join
(
CONFIG
[
'instance_root'
],
'testnode'
,
CONFIG
[
'partition_reference'
],
'bin'
,
'runUnitTest'
)
__name__
+
'.testnode'
,
'run'
)],
self
.
ws
,
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
dict
(
computer_id
=
CONFIG
[
'computer_id'
],
instance_dict
=
eval
(
self
.
parameter_dict
.
get
(
'instance_dict'
,
'{}'
)),
instance_root
=
CONFIG
[
'instance_root'
],
ipv4_address
=
self
.
getLocalIPv4Address
(),
ipv6_address
=
self
.
getGlobalIPv6Address
(),
master_url
=
CONFIG
[
'master_url'
],
profile_path
=
self
.
parameter_dict
[
'profile_path'
],
proxy_database
=
CONFIG
[
'proxy_database'
],
proxy_port
=
CONFIG
[
'proxy_port'
],
slapgrid_partition_binary
=
self
.
options
[
'slapgrid_partition_binary'
],
slapgrid_software_binary
=
self
.
options
[
'slapgrid_software_binary'
],
slapos_config
=
CONFIG
[
'slapos_config'
],
slapproxy_binary
=
self
.
options
[
'slapproxy_binary'
],
git_binary
=
self
.
options
[
'git_binary'
],
software_root
=
CONFIG
[
'software_root'
],
working_directory
=
CONFIG
[
'working_directory'
],
vcs_repository_list
=
eval
(
self
.
parameter_dict
.
get
(
'vcs_repository_list'
),),
node_quantity
=
self
.
parameter_dict
.
get
(
'node_quantity'
,
'1'
),
test_suite_master_url
=
self
.
parameter_dict
.
get
(
'test_suite_master_url'
,
None
),
test_suite
=
self
.
parameter_dict
.
get
(
'test_suite'
),
test_suite_title
=
self
.
parameter_dict
.
get
(
'test_suite_title'
),
test_node_title
=
self
.
parameter_dict
.
get
(
'test_node_title'
),
project_title
=
self
.
parameter_dict
.
get
(
'project_title'
),
bin_directory
=
self
.
bin_directory
,
# botenvironemnt is splittable string of key=value to substitute
# environment of running bot
bot_environment
=
self
.
parameter_dict
.
get
(
'bot_environment'
,
''
),
partition_reference
=
CONFIG
[
'partition_reference'
],
environment
=
dict
(
PATH
=
os
.
environ
[
'PATH'
]),
vcs_authentication_list
=
eval
(
self
.
parameter_dict
.
get
(
'vcs_authentication_list'
,
'None'
)),
)
]))
def
installLocalGit
(
self
):
git_dict
=
dict
(
git_binary
=
self
.
options
[
'git_binary'
])
git_dict
.
update
(
self
.
parameter_dict
)
double_slash_end_position
=
1
# XXX, this should be provided by slapos
print
"bin_directory : %r"
%
self
.
bin_directory
home_directory
=
os
.
path
.
join
(
*
os
.
path
.
split
(
self
.
bin_directory
)[
0
:
-
1
])
print
"home_directory : %r"
%
home_directory
git_dict
.
setdefault
(
"git_server_name"
,
"git.erp5.org"
)
if
git_dict
.
get
(
'vcs_authentication_list'
,
None
)
is
not
None
:
vcs_authentication_list
=
eval
(
git_dict
[
'vcs_authentication_list'
])
netrc_file
=
open
(
os
.
path
.
join
(
home_directory
,
'.netrc'
),
'w'
)
for
vcs_authentication_dict
in
vcs_authentication_list
:
netrc_file
.
write
(
"""
machine %(host)s
login %(user_name)s
password %(password)s
"""
%
vcs_authentication_dict
)
netrc_file
.
close
()
def
installLocalRepository
(
self
):
self
.
installLocalGit
()
def
installLocalZip
(
self
):
zip
=
os
.
path
.
join
(
self
.
bin_directory
,
'zip'
)
if
os
.
path
.
lexists
(
zip
):
os
.
unlink
(
zip
)
os
.
symlink
(
self
.
options
[
'zip_binary'
],
zip
)
def
installLocalPython
(
self
):
# generate vcs_repository_list
"""Installs local python fully featured with eggs"""
vcs_repository_list
=
[]
self
.
path_list
.
extend
(
zc
.
buildout
.
easy_install
.
scripts
([],
self
.
ws
,
for
section
in
config
.
sections
():
sys
.
executable
,
self
.
bin_directory
,
scripts
=
None
,
if
section
.
startswith
(
'vcs_repository'
):
interpreter
=
'python'
))
vcs_repository_list
.
append
(
dict
(
config
.
items
(
section
)))
CONFIG
[
'vcs_repository_list'
]
=
vcs_repository_list
def
installLocalRunUnitTest
(
self
):
CONFIG
[
'profile_path'
]
=
geto
(
'profile_path'
)
link
=
os
.
path
.
join
(
self
.
bin_directory
,
'runUnitTest'
)
CONFIG
[
'test_suite_title'
]
=
geto
(
'test_suite_title'
)
destination
=
os
.
path
.
join
(
CONFIG
[
'instance_root'
],
CONFIG
[
'test_node_title'
]
=
geto
(
'test_node_title'
)
CONFIG
[
'partition_reference'
],
'bin'
,
'runUnitTest'
)
CONFIG
[
'test_suite'
]
=
geto
(
'test_suite'
)
if
os
.
path
.
lexists
(
link
):
CONFIG
[
'project_title'
]
=
geto
(
'project_title'
)
if
not
os
.
readlink
(
link
)
!=
destination
:
CONFIG
[
'node_quantity'
]
=
geto
(
'node_quantity'
)
os
.
unlink
(
link
)
CONFIG
[
'ipv4_address'
]
=
geto
(
'ipv4_address'
)
if
not
os
.
path
.
lexists
(
link
):
CONFIG
[
'ipv6_address'
]
=
geto
(
'ipv6_address'
)
os
.
symlink
(
destination
,
link
)
CONFIG
[
'test_suite_master_url'
]
=
geto
(
'test_suite_master_url'
)
CONFIG
[
'slapgrid_partition_binary'
]
=
geto
(
'slapgrid_partition_binary'
)
CONFIG
[
'slapgrid_software_binary'
]
=
geto
(
'slapgrid_software_binary'
)
bot_environment
=
{}
if
'bot_environment'
in
config
.
sections
():
bot_environment
=
dict
(
config
.
items
(
'bot_environment'
))
CONFIG
[
'bot_environment'
]
=
bot_environment
environment
=
{}
if
'environment'
in
config
.
sections
():
environment
=
dict
(
config
.
items
(
'environment'
))
CONFIG
[
'environment'
]
=
environment
def
_install
(
self
):
testnode
.
run
(
CONFIG
)
self
.
requirements
,
self
.
ws
=
self
.
egg
.
working_set
()
self
.
path_list
=
[]
self
.
installSlapOs
()
self
.
setupRunningWrapper
()
self
.
installLocalRepository
()
self
.
installLocalZip
()
self
.
installLocalPython
()
self
.
installLocalRunUnitTest
()
return
self
.
path_list
erp5/util/testnode/testnode.py
View file @
bac6a51f
...
@@ -67,8 +67,7 @@ def getInputOutputFileList(config, command_name):
...
@@ -67,8 +67,7 @@ def getInputOutputFileList(config, command_name):
slapos_controler
=
None
slapos_controler
=
None
def
run
(
args
):
def
run
(
config
):
config
=
args
[
0
]
slapgrid
=
None
slapgrid
=
None
supervisord_pid_file
=
os
.
path
.
join
(
config
[
'instance_root'
],
'var'
,
'run'
,
supervisord_pid_file
=
os
.
path
.
join
(
config
[
'instance_root'
],
'var'
,
'run'
,
'supervisord.pid'
)
'supervisord.pid'
)
...
...
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