From 582894ae443d1ef4514af20b594faf5321a08726 Mon Sep 17 00:00:00 2001 From: liangxin1300 Date: Wed, 25 Aug 2021 09:00:17 +0800 Subject: [PATCH] Dev: behave: functional test change for using logging in crmsh --- test/features/bootstrap_options.feature | 6 +++--- test/features/steps/utils.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/features/bootstrap_options.feature b/test/features/bootstrap_options.feature index 67545cde35..728cac694a 100644 --- a/test/features/bootstrap_options.feature +++ b/test/features/bootstrap_options.feature @@ -22,11 +22,11 @@ Feature: crmsh bootstrap process - options Then Output is the same with expected "crm cluster add" help output When Run "crm cluster remove -h" on "hanode1" Then Output is the same with expected "crm cluster remove" help output - When Run "crm cluster geo-init -h" on "hanode1" + When Run "crm cluster geo_init -h" on "hanode1" Then Output is the same with expected "crm cluster geo-init" help output - When Run "crm cluster geo-join -h" on "hanode1" + When Run "crm cluster geo_join -h" on "hanode1" Then Output is the same with expected "crm cluster geo-join" help output - When Run "crm cluster geo-init-arbitrator -h" on "hanode1" + When Run "crm cluster geo_init_arbitrator -h" on "hanode1" Then Output is the same with expected "crm cluster geo-init-arbitrator" help output @clean diff --git a/test/features/steps/utils.py b/test/features/steps/utils.py index 794e07d251..12e92495e1 100644 --- a/test/features/steps/utils.py +++ b/test/features/steps/utils.py @@ -38,13 +38,14 @@ def run_command(context, cmd, err_record=False): rc, out, err = utils.get_stdout_stderr(cmd) if rc != 0 and err: if err_record: - context.command_error_output = err - return rc, out + res = re.sub(r'\x1b\[[0-9]+m', '', err) + context.command_error_output = res + return rc, re.sub(r'\x1b\[[0-9]+m', '', out) if out: context.logger.info("\n{}\n".format(out)) context.logger.error("\n{}\n".format(err)) context.failed = True - return rc, out + return rc, re.sub(r'\x1b\[[0-9]+m', '', out) def run_command_local_or_remote(context, cmd, addr, err_record=False): @@ -56,7 +57,7 @@ def run_command_local_or_remote(context, cmd, addr, err_record=False): results = parallax.parallax_call(addr.split(','), cmd) except ValueError as err: if err_record: - context.command_error_output = str(err) + context.command_error_output = re.sub(r'\x1b\[[0-9]+m', '', str(err)) return context.logger.error("\n{}\n".format(err)) context.failed = True