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
dcbd597f
Commit
dcbd597f
authored
Oct 30, 2012
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5testnode: unit test constructProfile
parent
cde3df5c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
20 deletions
+48
-20
erp5/tests/testERP5TestNode.py
erp5/tests/testERP5TestNode.py
+39
-5
erp5/util/testnode/testnode.py
erp5/util/testnode/testnode.py
+9
-15
No files found.
erp5/tests/testERP5TestNode.py
View file @
dcbd597f
...
...
@@ -30,8 +30,12 @@ class ERP5TestNode(TestCase):
def
setUp
(
self
):
self
.
_tempdir
=
tempfile
.
mkdtemp
()
self
.
software_root
=
os
.
path
.
join
(
self
.
_tempdir
,
'software'
)
self
.
instance_root
=
os
.
path
.
join
(
self
.
_tempdir
,
'instance'
)
self
.
working_directory
=
os
.
path
.
join
(
self
.
_tempdir
,
'testnode'
)
self
.
slapos_directory
=
os
.
path
.
join
(
self
.
_tempdir
,
'slapos'
)
os
.
mkdir
(
self
.
working_directory
)
os
.
mkdir
(
self
.
slapos_directory
)
self
.
remote_repository1
=
os
.
path
.
join
(
self
.
_tempdir
,
'rep1'
)
self
.
remote_repository2
=
os
.
path
.
join
(
self
.
_tempdir
,
'rep2'
)
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
_tempdir
,
True
)
...
...
@@ -39,6 +43,19 @@ class ERP5TestNode(TestCase):
def
getTestNode
(
self
):
return
TestNode
(
None
,
None
)
def
updateNodeTestSuiteData
(
self
,
node_test_suite
):
node_test_suite
.
edit
(
working_directory
=
self
.
working_directory
,
test_suite
=
"Foo"
,
project_title
=
"Foo"
,
test_suite_title
=
"Foo-Test"
,
vcs_repository_list
=
[
{
'url'
:
self
.
remote_repository1
,
'profile_path'
:
'software.cfg'
,
'branch'
:
'master'
},
{
'url'
:
self
.
remote_repository2
,
'buildout_section_id'
:
'foo'
,
'branch'
:
'master'
}])
def
test_01_GetDelNodeTestSuite
(
self
):
"""
We should be able to get/delete NodeTestSuite objects inside test_node
...
...
@@ -58,8 +75,25 @@ class ERP5TestNode(TestCase):
"""
test_node
=
self
.
getTestNode
()
node_test_suite
=
test_node
.
getNodeTestSuite
(
'foo'
)
node_test_suite
.
edit
(
working_directory
=
"some_path"
)
self
.
assertEquals
(
"some_path/foo"
,
node_test_suite
.
working_directory
)
node_test_suite
.
edit
(
working_directory
=
self
.
working_directory
)
self
.
assertEquals
(
"%s/foo"
%
self
.
working_directory
,
node_test_suite
.
working_directory
)
def
test_03_constructProfile
(
self
):
pass
test_node
=
self
.
getTestNode
()
node_test_suite
=
test_node
.
getNodeTestSuite
(
'foo'
)
self
.
updateNodeTestSuiteData
(
node_test_suite
)
test_node
.
constructProfile
(
node_test_suite
)
self
.
assertEquals
(
"%s/software.cfg"
%
(
node_test_suite
.
working_directory
,),
node_test_suite
.
custom_profile_path
)
profile
=
open
(
node_test_suite
.
custom_profile_path
,
'r'
)
expected_profile
=
"""
[buildout]
extends = %s/testnode/foo/rep1/software.cfg
[foo]
repository = %s/testnode/foo/foo
branch = master
"""
%
(
self
.
_tempdir
,
self
.
_tempdir
)
self
.
assertEquals
(
expected_profile
,
profile
.
read
())
profile
.
close
()
erp5/util/testnode/testnode.py
View file @
dcbd597f
...
...
@@ -69,6 +69,9 @@ class NodeTestSuite(SlapOSInstance):
if
kw
.
has_key
(
"working_directory"
):
kw
[
"working_directory"
]
=
os
.
path
.
join
(
kw
[
"working_directory"
],
self
.
reference
)
SlapOSControler
.
createFolder
(
kw
[
"working_directory"
])
kw
[
"custom_profile_path"
]
=
os
.
path
.
join
(
kw
[
'working_directory'
],
'software.cfg'
)
super
(
NodeTestSuite
,
self
).
edit
(
**
kw
)
class
TestNode
(
object
):
...
...
@@ -81,7 +84,7 @@ class TestNode(object):
# hack until slapos.cookbook is updated
if
self
.
config
.
get
(
'working_directory'
,
''
).
endswith
(
"slapos/"
):
self
.
config
[
'working_directory'
]
=
self
.
config
[
'working_directory'
][:
-
(
len
(
"slapos/"
))]
'working_directory'
][:
-
(
len
(
"slapos/"
))]
+
"/testnode"
def
checkOldTestSuite
(
self
,
test_suite_data
):
config
=
self
.
config
...
...
@@ -108,15 +111,6 @@ class TestNode(object):
if
self
.
node_test_suite_dict
.
has_key
(
reference
):
self
.
node_test_suite_dict
.
pop
(
reference
)
def
updateConfigForTestSuite
(
self
,
test_suite
,
node_test_suite
):
config
=
self
.
config
node_test_suite
.
edit
(
**
test_suite
),
config
[
'working_directory'
]
=
os
.
path
.
join
(
config
[
'slapos_directory'
],
node_test_suite
.
reference
)
SlapOSControler
.
createFolder
(
config
[
'working_directory'
])
custom_profile_path
=
os
.
path
.
join
(
config
[
'working_directory'
],
'software.cfg'
)
config
[
'custom_profile_path'
]
=
custom_profile_path
def
constructProfile
(
self
,
node_test_suite
):
config
=
self
.
config
profile_content
=
''
...
...
@@ -161,7 +155,7 @@ branch = %(branch)s
'branch'
:
vcs_repository
.
get
(
'branch'
,
'master'
)}
if
not
profile_path_count
:
raise
ValueError
(
PROFILE_PATH_KEY
+
' not defined'
)
custom_profile
=
open
(
config
[
'custom_profile_path'
]
,
'w'
)
custom_profile
=
open
(
node_test_suite
.
custom_profile_path
,
'w'
)
custom_profile
.
write
(
profile_content
)
custom_profile
.
close
()
config
[
'repository_path'
]
=
repository_path
...
...
@@ -234,6 +228,8 @@ 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
.
process_manager
.
supervisord_pid_file
=
os
.
path
.
join
(
\
slapos_controler
.
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)
method_list
=
[
"runSoftwareRelease"
]
if
create_partition
:
method_list
.
append
(
"runComputerPartition"
)
...
...
@@ -262,7 +258,7 @@ branch = %(branch)s
def
prepareSlapOSForTestSuite
(
self
,
node_test_suite
):
return
self
.
_prepareSlapOS
(
node_test_suite
.
working_directory
,
node_test_suite
,
software_path_list
=
[
self
.
config
.
get
(
"custom_profile_path"
)
])
software_path_list
=
[
node_test_suite
.
custom_profile_path
])
def
_dealShebang
(
self
,
run_test_suite_path
):
line
=
open
(
run_test_suite_path
,
'r'
).
readline
()
...
...
@@ -346,10 +342,8 @@ branch = %(branch)s
test_suite
[
"test_suite_reference"
])
node_test_suite
.
edit
(
working_directory
=
self
.
config
[
'working_directory'
])
self
.
updateConfigForTestSuite
(
test_suite
,
node_
test_suite
)
node_test_suite
.
edit
(
**
test_suite
)
run_software
=
True
self
.
process_manager
.
supervisord_pid_file
=
os
.
path
.
join
(
\
slapos_controler
.
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)
# Write our own software.cfg to use the local repository
self
.
constructProfile
(
node_test_suite
)
# kill processes from previous loop if any
...
...
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