Commit 0a7f1128 authored by Jérome Perrin's avatar Jérome Perrin

standalone: don't use --all in waitForSoftware / waitForInstance

Until now, standalone was running slapos node software/instance with --all flag
which force installing software or processing software, unlike "normal" slapos
node which no longer install on software once they are completed and only process
instances when they are requested with different parameters or when they have
failing promises.

We stop using the --all flag, to behave like a normal slapos node.

This reveal missing promises in some softwares, after this change, waitForInstance
can return faster. This reveal test failures with some softwares where the
instanciation step request other instances, but without having a promise to wait
for their requests to have been sucessfully processed; in this case waitForInstance
return too early.

We keep an "install_all" API to force reinstalling software, this can be useful
for scenarios like erp5testnode, or software release development.
parent 42d332c8
Pipeline #14953 failed with stage
in 0 seconds
......@@ -348,6 +348,14 @@ class StandaloneSlapOS(object):
self._slapos_commands = {
'slapos-node-software': {
'command':
'slapos node software --cfg {self._slapos_config} {debug_args}',
'debug_args':
'-v --buildout-debug',
'stdout_logfile':
'{self._log_directory}/slapos-node-software.log',
},
'slapos-node-software-all': {
'command':
'slapos node software --cfg {self._slapos_config} --all {debug_args}',
'debug_args':
......@@ -357,7 +365,7 @@ class StandaloneSlapOS(object):
},
'slapos-node-instance': {
'command':
'slapos node instance --cfg {self._slapos_config} --all {debug_args}',
'slapos node instance --cfg {self._slapos_config} {debug_args}',
'debug_args':
'-v --buildout-debug',
'stdout_logfile':
......@@ -669,7 +677,7 @@ class StandaloneSlapOS(object):
raise RuntimeError(
"Could not terminate some processes: {}".format(alive))
def waitForSoftware(self, max_retry=0, debug=False, error_lines=30):
def waitForSoftware(self, max_retry=0, debug=False, error_lines=30, install_all=False):
"""Synchronously install or uninstall all softwares previously supplied/removed.
This method retries on errors. If after `max_retry` times there's
......@@ -679,12 +687,16 @@ class StandaloneSlapOS(object):
If `debug` is true, buildout is executed in the foreground, with flags to
drop in a debugger session if error occurs.
If `install_all` is true, all softwares will be installed, even the ones
for which the installation was already completed. This is equivalent to
running `slapos node software --all`.
Error cases:
* `SlapOSNodeCommandError` when buildout error while installing software.
* Unexpected `Exception` if unable to connect to embedded slap server.
"""
return self._runSlapOSCommand(
'slapos-node-software',
'slapos-node-software-all' if install_all else 'slapos-node-software',
max_retry=max_retry,
debug=debug,
error_lines=error_lines,
......
......@@ -321,6 +321,7 @@ class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase):
[instance]
recipe = plone.recipe.command==1.1
command = touch ${buildout:directory}/instance.cfg
update-command = touch ${buildout:directory}/updated
''').encode())
f.flush()
self.standalone.supply(f.name)
......@@ -341,6 +342,19 @@ class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase):
os.path.exists(
os.path.join(software_installation_path, 'instance.cfg')))
# install respect the .completed file, once software is installed,
# waitForSoftware will not process again software
self.standalone.waitForSoftware()
self.assertFalse(
os.path.exists(
os.path.join(software_installation_path, 'updated')))
# waitForSoftware has a way to "force" reinstalling all software
self.standalone.waitForSoftware(install_all=True)
self.assertTrue(
os.path.exists(
os.path.join(software_installation_path, 'updated')))
# destroy
self.standalone.supply(f.name, state='destroyed')
self.standalone.waitForSoftware()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment