From 2f2132350dbd942f3a29fce2d9723642dff2de80 Mon Sep 17 00:00:00 2001 From: Stan Lagun Date: Mon, 29 Aug 2016 09:58:40 -0700 Subject: [PATCH] TestFixture mocks were updated Core library was updated as part of the multi-region support effort. FormatVersion of the core library was incremented and, as a result $dict.key expressions started to work as they are in yaql 1.0 rather than in 0.2 and the presence of the key become mandatory. However Network mock in the TextFixture used to return empty dictionary and it caused Instance class to fail. The commit adds missing keys to the dictionary returned by the joinInstance() method. Also the test runner was improved to print the stack trace upon failures so that it is possible to identify where the error happened. Change-Id: Ia7b0f61370effe4f13fed4ec85e806f3b0fdb80b --- meta/io.murano/Classes/test/TestFixture.yaml | 7 ++++-- murano/cmd/test_runner.py | 23 +++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/meta/io.murano/Classes/test/TestFixture.yaml b/meta/io.murano/Classes/test/TestFixture.yaml index 83c1634b..c099408a 100644 --- a/meta/io.murano/Classes/test/TestFixture.yaml +++ b/meta/io.murano/Classes/test/TestFixture.yaml @@ -43,11 +43,14 @@ Methods: Contract: - $.class(std:SharedIp) Body: - - Return: {} + - Return: + template: {} + portRef: + instanceFipOutput: generateSecurityGroupManager: Body: - - Return: new(sys:DummySecurityGroupManager) + - Return: new(sys:DummySecurityGroupManager, $this) describe: Body: diff --git a/murano/cmd/test_runner.py b/murano/cmd/test_runner.py index 52730dd9..91e07b2d 100644 --- a/murano/cmd/test_runner.py +++ b/murano/cmd/test_runner.py @@ -31,6 +31,7 @@ from murano import version from murano.common.i18n import _, _LE from murano.common import config from murano.common import engine +from murano.dsl import dsl_exception from murano.dsl import dsl_types from murano.dsl import exceptions from murano.dsl import executor @@ -277,11 +278,20 @@ class MuranoTestRunner(object): sys.stdout.flush() except Exception as e: error_count += 1 - msg = '{0}{1}: {2}{3}\n'.format(FAIL_COLOR, - 'FAIL!', - e, - END_COLOR) + msg = ''.join(( + FAIL_COLOR, 'FAIL!', END_COLOR, '\n')) sys.stdout.write(msg) + if isinstance(e, dsl_exception.MuranoPlException): + tb = e.format() + else: + tb = traceback.format_exc() + + sys.stdout.write(''.join(( + FAIL_COLOR, + tb, + END_COLOR, + '\n' + ))) sys.stdout.flush() LOG.exception('Test {0} failed'.format(test_name)) @@ -364,7 +374,10 @@ def main(): exit_code = test_runner.run_tests() sys.exit(exit_code) except Exception as e: - tb = traceback.format_exc() + if isinstance(e, dsl_exception.MuranoPlException): + tb = e.format() + else: + tb = traceback.format_exc() err_msg = _LE("Command failed: {0}\n{1}").format(e, tb) LOG.error(err_msg) sys.exit(err_msg)