From a3bd035bade6da1f0822c851fdca916b50dc57fc Mon Sep 17 00:00:00 2001 From: Lukasz Nowak <luke@nexedi.com> Date: Thu, 28 Jun 2018 17:03:48 +0200 Subject: [PATCH] slapos.test.software: Emit more information in case of problems Whenever there is a problem while building software or instantiation, emit verbose information for further analysis. --- software/caddy-frontend/test/utils.py | 38 ++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/software/caddy-frontend/test/utils.py b/software/caddy-frontend/test/utils.py index 1f9218fe1..a254738a9 100644 --- a/software/caddy-frontend/test/utils.py +++ b/software/caddy-frontend/test/utils.py @@ -31,6 +31,7 @@ import socket import subprocess from contextlib import closing import logging +import StringIO import json from BaseHTTPServer import HTTPServer from BaseHTTPServer import BaseHTTPRequestHandler @@ -164,20 +165,43 @@ class SlapOSInstanceTestCase(unittest.TestCase): @classmethod def runSoftwareRelease(cls): - cls.software_status_dict = cls.slapos_controler.runSoftwareRelease( - cls.config, environment=os.environ) - # TODO: log more details in this case - assert cls.software_status_dict['status_code'] == 0 + + logger = logging.getLogger() + logger.level = logging.DEBUG + stream = StringIO.StringIO() + stream_handler = logging.StreamHandler(stream) + logger.addHandler(stream_handler) + + try: + cls.software_status_dict = cls.slapos_controler.runSoftwareRelease( + cls.config, environment=os.environ) + stream.seek(0) + stream.flush() + assert cls.software_status_dict['status_code'] == 0, stream.read() + finally: + logger.removeHandler(stream_handler) + del stream @classmethod def runComputerPartition(cls): + logger = logging.getLogger() + logger.level = logging.DEBUG + stream = StringIO.StringIO() + stream_handler = logging.StreamHandler(stream) + logger.addHandler(stream_handler) + instance_parameter_dict = cls.getInstanceParameterDict() - cls.instance_status_dict = cls.slapos_controler.runComputerPartition( + try: + cls.instance_status_dict = cls.slapos_controler.runComputerPartition( cls.config, cluster_configuration=instance_parameter_dict, environment=os.environ) - # TODO: log more details in this case - assert cls.instance_status_dict['status_code'] == 0 + stream.seek(0) + stream.flush() + assert cls.instance_status_dict['status_code'] == 0, stream.read() + finally: + logger.removeHandler(stream_handler) + del stream # FIXME: similar to test node, only one (root) partition is really # supported for now. -- 2.30.9