Commit f906e42e 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 "slapos node software --all" API to force reinstalling software, this
can be useful for scenarios like erp5testnode, or software release development.

We also keep an hidden "slapos node instance --all" API, so that we can keep
running tests for software releases with missing promises.
parent b17d95f7
Pipeline #16580 failed with stage
in 0 seconds
...@@ -346,6 +346,10 @@ class StandaloneSlapOS(object): ...@@ -346,6 +346,10 @@ class StandaloneSlapOS(object):
Extends the existing `IRequester` and `ISupply`, with the special behavior that Extends the existing `IRequester` and `ISupply`, with the special behavior that
`IRequester.request` and `ISupply.supply` will only use the embedded computer. `IRequester.request` and `ISupply.supply` will only use the embedded computer.
""" """
# an "hidden" flag to run slapos node instance and software with --all, for
# test suites for softwares with missing promises.
_force_slapos_node_instance_all = False
def __init__( def __init__(
self, self,
base_directory, base_directory,
...@@ -400,6 +404,14 @@ class StandaloneSlapOS(object): ...@@ -400,6 +404,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':
...@@ -408,6 +420,14 @@ class StandaloneSlapOS(object): ...@@ -408,6 +420,14 @@ class StandaloneSlapOS(object):
'{self._log_directory}/slapos-node-software.log', '{self._log_directory}/slapos-node-software.log',
}, },
'slapos-node-instance': { 'slapos-node-instance': {
'command':
'{self._slapos_bin} node instance --cfg {self._slapos_config} {debug_args}',
'debug_args':
'-v --buildout-debug',
'stdout_logfile':
'{self._log_directory}/slapos-node-instance.log',
},
'slapos-node-instance-all': {
'command': 'command':
'{self._slapos_bin} node instance --cfg {self._slapos_config} --all {debug_args}', '{self._slapos_bin} node instance --cfg {self._slapos_config} --all {debug_args}',
'debug_args': 'debug_args':
...@@ -734,7 +754,7 @@ class StandaloneSlapOS(object): ...@@ -734,7 +754,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
...@@ -744,12 +764,16 @@ class StandaloneSlapOS(object): ...@@ -744,12 +764,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,
...@@ -770,7 +794,7 @@ class StandaloneSlapOS(object): ...@@ -770,7 +794,7 @@ class StandaloneSlapOS(object):
* 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-instance', 'slapos-node-instance-all' if self._force_slapos_node_instance_all else 'slapos-node-instance',
max_retry=max_retry, max_retry=max_retry,
debug=debug, debug=debug,
error_lines=error_lines, error_lines=error_lines,
......
...@@ -346,6 +346,7 @@ class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase): ...@@ -346,6 +346,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)
...@@ -366,6 +367,19 @@ class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase): ...@@ -366,6 +367,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