Skip to content

Commit

Permalink
Dev: behave: functional test change for using logging in crmsh
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxin1300 committed Sep 7, 2021
1 parent 490005e commit 582894a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions test/features/bootstrap_options.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions test/features/steps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 582894a

Please sign in to comment.