Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profusion-mobi.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fOl6DiwZJFSe5CcTRUIPYk/WTajmvxOecgN8WbZqmzE=; b=tdgYe5stXQfVxT/bZ8N7ivu4dNrcIH3Bovh2Jbcq+Vh5hq5kIQLwlm08zw5Byy9r8Y 9fWx4JDx/AEGHSHfP6Xufh1lzsh5UVIfxsfzrf9gZW3IFSNEzIWwhw0enpob+aeHNpEc JBSK3rNe+RGnuP40eRRMl3btcqjScZO3Eg3ue++J5IzEDkpoAtj+KhteKRs9EKyB3B4z Kpt7G7nnjr5D/QmKBHqJ0BSHswEVCUzUVNVK7SIhoYimPqLogkS2jSX4/UbVYsQHWWwn kEZAJUcq5hqfpbsy5ZAS1HFYpnQBRxggKEsxhLRdNCdKNhcSQE05EoDILOfIvnL+CtIn mBhg== From: Guilherme Campos Camargo Date: Wed, 7 Mar 2018 16:54:54 -0300 Message-Id: <20180307195459.16757-7-guicc@profusion.mobi> In-Reply-To: <20180307195459.16757-1-guicc@profusion.mobi> References: <20180307195459.16757-1-guicc@profusion.mobi> Subject: [Fuego] [PATCH 06/11] Properly check install return code and abort in case of failure List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org 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 --- 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