Skip to content

Commit

Permalink
integration tests: add undeduplicated output test
Browse files Browse the repository at this point in the history
* The case of undeduplicated output, like when there is only one target
  host, was not tested by the integration tests. Adding a test to cover
  that use case too.

Bug: T275210
Change-Id: Ib204f16ebb8c60685da67fd1f59a7ad27b1f28e0
  • Loading branch information
volans- committed Feb 23, 2021
1 parent 6b99d13 commit c33c192
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cumin/tests/integration/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'100.0% (2/2) success ratio (>= 100.0% threshold) of nodes successfully executed all commands.',
'all_success_threshold':
'100.0% (5/5) success ratio (>= 50.0% threshold) of nodes successfully executed all commands.',
'one_success': '100.0% (1/1) success ratio (>= 100.0% threshold) of nodes successfully executed all commands.',
'all_failure':
'0.0% (0/5) success ratio (< 100.0% threshold) of nodes successfully executed all commands. Aborting.',
'all_failure_threshold':
Expand Down Expand Up @@ -116,6 +117,9 @@
# Expected output for the -o/--out json option for one node
_JSON_EXPECTED_SINGLE_OUTPUT = 'First\nSecond\nThird'

# Expected output for the 'uname' command to stdout
_UNAME_OUTPUT = "\x1b[34m----- OUTPUT of 'uname' -----\x1b[39m\nLinux\n\x1b[34m================\x1b[39m\n"


def make_method(name, commands_set):
"""Method generator with a dynamic name and docstring."""
Expand Down Expand Up @@ -436,3 +440,16 @@ def test_out_json(self, capsys):
expected_out = {self.nodes_prefix + str(i): _JSON_EXPECTED_SINGLE_OUTPUT for i in range(1, 6)}

assert json.loads(out.split(cli.OUTPUT_SEPARATOR + '\n')[1]) == expected_out

def test_undeduplicated_output(self, capsys):
"""Executing a command without output deduplication (1 target host) should work as expected."""
params = [self._get_nodes('1'), 'uname']
rc = cli.main(argv=self.default_params + params)
out, err = capsys.readouterr()
sys.stdout.write(out)
sys.stderr.write(err)
assert _UNAME_OUTPUT == out
assert _EXPECTED_LINES['one_success'] in err, _EXPECTED_LINES['one_success']
assert _EXPECTED_LINES['failed'] not in err, _EXPECTED_LINES['failed']
assert _EXPECTED_LINES['global_timeout'] not in err, _EXPECTED_LINES['global_timeout']
assert rc == 0

0 comments on commit c33c192

Please sign in to comment.