Commit e6a0c09e 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 69095b74
...@@ -357,6 +357,14 @@ class StandaloneSlapOS(object): ...@@ -357,6 +357,14 @@ class StandaloneSlapOS(object):
self._slapos_commands = { self._slapos_commands = {
'slapos-node-software': { 'slapos-node-software': {
'command':
'{self._slapos_bin} 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': 'command':
'{self._slapos_bin} node software --cfg {self._slapos_config} --all {debug_args}', '{self._slapos_bin} node software --cfg {self._slapos_config} --all {debug_args}',
'debug_args': 'debug_args':
...@@ -366,7 +374,7 @@ class StandaloneSlapOS(object): ...@@ -366,7 +374,7 @@ class StandaloneSlapOS(object):
}, },
'slapos-node-instance': { 'slapos-node-instance': {
'command': 'command':
'{self._slapos_bin} node instance --cfg {self._slapos_config} --all {debug_args}', '{self._slapos_bin} node instance --cfg {self._slapos_config} {debug_args}',
'debug_args': 'debug_args':
'-v --buildout-debug', '-v --buildout-debug',
'stdout_logfile': 'stdout_logfile':
...@@ -678,7 +686,7 @@ class StandaloneSlapOS(object): ...@@ -678,7 +686,7 @@ class StandaloneSlapOS(object):
raise RuntimeError( raise RuntimeError(
"Could not terminate some processes: {}".format(alive)) "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. """Synchronously install or uninstall all softwares previously supplied/removed.
This method retries on errors. If after `max_retry` times there's This method retries on errors. If after `max_retry` times there's
...@@ -688,12 +696,16 @@ class StandaloneSlapOS(object): ...@@ -688,12 +696,16 @@ class StandaloneSlapOS(object):
If `debug` is true, buildout is executed in the foreground, with flags to If `debug` is true, buildout is executed in the foreground, with flags to
drop in a debugger session if error occurs. 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: Error cases:
* `SlapOSNodeCommandError` when buildout error while installing software. * `SlapOSNodeCommandError` when buildout error while installing software.
* Unexpected `Exception` if unable to connect to embedded slap server. * Unexpected `Exception` if unable to connect to embedded slap server.
""" """
return self._runSlapOSCommand( return self._runSlapOSCommand(
'slapos-node-software', 'slapos-node-software-all' if install_all else 'slapos-node-software',
max_retry=max_retry, max_retry=max_retry,
debug=debug, debug=debug,
error_lines=error_lines, error_lines=error_lines,
......
...@@ -321,6 +321,7 @@ class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase): ...@@ -321,6 +321,7 @@ class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase):
[instance] [instance]
recipe = plone.recipe.command==1.1 recipe = plone.recipe.command==1.1
command = touch ${buildout:directory}/instance.cfg command = touch ${buildout:directory}/instance.cfg
update-command = touch ${buildout:directory}/updated
''').encode()) ''').encode())
f.flush() f.flush()
self.standalone.supply(f.name) self.standalone.supply(f.name)
...@@ -341,6 +342,19 @@ class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase): ...@@ -341,6 +342,19 @@ class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase):
os.path.exists( os.path.exists(
os.path.join(software_installation_path, 'instance.cfg'))) 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 # destroy
self.standalone.supply(f.name, state='destroyed') self.standalone.supply(f.name, state='destroyed')
self.standalone.waitForSoftware() 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