[Fuego] [PATCH 06/11] Properly check install return code and abort in case of failure
Guilherme Campos Camargo
guicc at profusion.mobi
Wed Mar 7 19:54:54 UTC 2018
A new method 'install()' has been added to 'FuegoContainer' and the all
the docker_setup steps have been moved from the class __init__() to this
new method.
This will allow the 'main' function to check if install has failed
simply by inspecting its return.
Signed-off-by: Guilherme Campos Camargo <guicc at profusion.mobi>
---
engine/tests/Functional.fuegotest/test_run.py | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/engine/tests/Functional.fuegotest/test_run.py b/engine/tests/Functional.fuegotest/test_run.py
index e3fcb68..d6bec0c 100755
--- a/engine/tests/Functional.fuegotest/test_run.py
+++ b/engine/tests/Functional.fuegotest/test_run.py
@@ -160,14 +160,17 @@ class FuegoContainer:
self.container_name = container_name
self.jenkins_port = jenkins_port
- self.docker_client = docker.APIClient()
- self.container = self.setup_docker()
-
def __del__(self):
if self.container:
LOGGER.debug('Removing Container')
self.container.remove(force=True)
+ def install(self):
+ self.docker_client = docker.APIClient()
+ self.container = self.setup_docker()
+
+ return self.container
+
def stop(self):
self.container.remove(force=True)
self.container = None
@@ -191,7 +194,8 @@ class FuegoContainer:
inspect_container(container_id)['Mounts']
for mount in mounts:
- LOGGER.debug(' Trying to find %s mountpoint in the host', mount['source'])
+ LOGGER.debug(' Trying to find %s mountpoint in the host',
+ mount['source'])
for host_mount in host_mounts:
if mount['source'].startswith(host_mount['Destination']):
mount['source'] = mount['source'].\
@@ -207,6 +211,9 @@ class FuegoContainer:
LOGGER.debug('Running \'%s\' to install the docker image. '
'This may take a while....', cmd)
status = subprocess.call(cmd, shell=True)
+
+ LOGGER.debug('Install output code: %s', status)
+
if status != 0:
return None
@@ -453,6 +460,8 @@ def main():
container = FuegoContainer(args.install_script, args.image_name,
args.container_name, args.jenkins_port)
+ if not container.install():
+ return 1
pexpect_session = PexpectContainerSession(container, args.start_script,
args.timeout)
--
2.16.2
More information about the Fuego
mailing list