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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
fdd15b4c
Commit
fdd15b4c
authored
Sep 19, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testnode: refuse to erase an instance directory if supervisor is already runnning there
parent
8c33379a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
0 deletions
+50
-0
erp5/tests/testERP5TestNode.py
erp5/tests/testERP5TestNode.py
+34
-0
erp5/util/testnode/Utils.py
erp5/util/testnode/Utils.py
+15
-0
setup.py
setup.py
+1
-0
No files found.
erp5/tests/testERP5TestNode.py
View file @
fdd15b4c
import
unittest
import
mock
from
unittest
import
TestCase
from
contextlib
import
contextmanager
...
...
@@ -1138,3 +1139,36 @@ shared = true
RunnerClass
.
updateDictionaryFile
=
original_updateDictionaryFile
RunnerClass
.
_createInstance
=
original__createInstance
RunnerClass
.
_waitInstanceCreation
=
original__waitInstanceCreation
def
test_cleanup_supervisord_from_previous_run
(
self
):
test_node
=
self
.
getTestNode
()
runner
=
test_type_registry
[
'UnitTest'
](
test_node
)
node_test_suite
=
test_node
.
getNodeTestSuite
(
'foo'
)
# XXX this have to be cleaned up
host
,
port
=
'127.0.0.1'
,
1234
# XXX
test_node
.
config
[
'ipv4_address'
]
=
host
test_node
.
config
[
'ipv6_address'
]
=
'::1'
# TODO
test_node
.
config
[
'proxy_host'
]
=
host
test_node
.
config
[
'proxy_port'
]
=
port
test_node
.
config
[
'master_url'
]
=
"http://{proxy_host}:{proxy_port}"
.
format
(
**
test_node
.
config
)
test_node
.
config
[
'slapos_binary'
]
=
'/usr/bin/slapos'
# XXX must be in path (and not be the slaprunner wrapper !)
test_node
.
config
[
'partition_reference'
]
=
self
.
id
()
test_node
.
config
[
'environment'
]
=
os
.
environ
test_node
.
config
[
"software_list"
]
=
[]
self
.
addCleanup
(
test_node
.
process_manager
.
killPreviousRun
)
with
mock
.
patch
(
'erp5.util.testnode.UnitTestRunner.SlapOSControler.runSoftwareRelease'
,
return_value
=
{
'status_code'
:
0
}):
# start slapos node's supervisord
runner
.
prepareSlapOSForTestSuite
(
node_test_suite
)
# Here we are in a state where supervisor is started, maybe by human
# logged in on test node, maybe an unexpected error in previous run.
# preparing slapos again should report this as an error and refuse starting.
# XXX or maybe just terminate the previous supervisor and start ?
with
self
.
assertRaisesRegexp
(
RuntimeError
,
'Supervisord is already running'
):
runner
.
prepareSlapOSForTestSuite
(
node_test_suite
)
erp5/util/testnode/Utils.py
View file @
fdd15b4c
import
os
import
stat
import
shutil
import
psutil
import
logging
def
rmtree
(
path
):
"""Delete a path recursively.
...
...
@@ -30,6 +32,19 @@ def createFolder(folder, clean=False):
if
os
.
path
.
exists
(
folder
):
if
not
clean
:
return
# before removing, check that we don't have a supervisord left here,
# and refuse to erase this directory in that case.
supervisord_pid_file
=
os
.
path
.
join
(
folder
,
'var/run/supervisord.pid'
)
if
os
.
path
.
exists
(
supervisord_pid_file
):
with
open
(
supervisord_pid_file
,
'r'
)
as
f
:
pid
=
int
(
f
.
read
().
strip
())
supervisord
=
psutil
.
Process
(
pid
)
if
supervisord
.
cmdline
()[
-
1
].
endswith
(
"supervisor.supervisord.main()"
):
logger
=
logging
.
getLogger
()
logger
.
error
(
"Supervisord is already running in this directory ( pid: %s )"
,
pid
)
# XXX terminate ?
# supervisord.terminate()
raise
RuntimeError
(
"Supervisord is already running"
)
rmtree
(
folder
)
os
.
mkdir
(
folder
)
...
...
setup.py
View file @
fdd15b4c
...
...
@@ -81,6 +81,7 @@ setup(name=name,
test_suite
=
'erp5.tests'
,
tests_require
=
[
'slapos.core'
,
'mock'
,
'xml_marshaller'
,
'psutil >= 0.5.0'
,
],
...
...
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