mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Allow --static option to display state runs with highstate output
Fixes #44556
This commit is contained in:
parent
6169b52749
commit
1bbe1abeb2
2 changed files with 67 additions and 0 deletions
|
@ -142,6 +142,17 @@ def get_printout(out, opts=None, **kwargs):
|
|||
# See Issue #29796 for more information.
|
||||
out = opts['output']
|
||||
|
||||
# Handle setting the output when --static is passed.
|
||||
if not out and opts.get('static'):
|
||||
if opts.get('output'):
|
||||
out = opts['output']
|
||||
elif opts.get('fun', '').split('.')[0] == 'state':
|
||||
# --static doesn't have an output set at this point, but if we're
|
||||
# running a state function and "out" hasn't already been set, we
|
||||
# should set the out variable to "highstate". Otherwise state runs
|
||||
# are set to "nested" below. See Issue #44556 for more information.
|
||||
out = 'highstate'
|
||||
|
||||
if out == 'text':
|
||||
out = 'txt'
|
||||
elif out is None or out == '':
|
||||
|
|
|
@ -106,6 +106,62 @@ class OutputReturnTest(integration.ShellCase):
|
|||
trace = traceback.format_exc()
|
||||
self.assertEqual(trace, '')
|
||||
|
||||
def test_output_highstate(self):
|
||||
'''
|
||||
Regression tests for the highstate outputter. Calls a basic state with various
|
||||
flags. Each comparison should be identical when successful.
|
||||
'''
|
||||
# Test basic highstate output. No frills.
|
||||
expected = ['minion:', ' ID: simple-ping', ' Function: module.run',
|
||||
' Name: test.ping', ' Result: True',
|
||||
' Comment: Module function test.ping executed',
|
||||
' Changes: ', ' ret:', ' True',
|
||||
'Summary for minion', 'Succeeded: 1 (changed=1)', 'Failed: 0',
|
||||
'Total states run: 1']
|
||||
state_run = self.run_salt('"minion" state.sls simple-ping')
|
||||
|
||||
for expected_item in expected:
|
||||
self.assertIn(expected_item, state_run)
|
||||
|
||||
# Test highstate output while also passing --out=highstate.
|
||||
# This is a regression test for Issue #29796
|
||||
state_run = self.run_salt('"minion" state.sls simple-ping --out=highstate')
|
||||
|
||||
for expected_item in expected:
|
||||
self.assertIn(expected_item, state_run)
|
||||
|
||||
# Test highstate output when passing --static and running a state function.
|
||||
# See Issue #44556.
|
||||
state_run = self.run_salt('"minion" state.sls simple-ping --static')
|
||||
|
||||
for expected_item in expected:
|
||||
self.assertIn(expected_item, state_run)
|
||||
|
||||
# Test highstate output when passing --static and --out=highstate.
|
||||
# See Issue #44556.
|
||||
state_run = self.run_salt('"minion" state.sls simple-ping --static --out=highstate')
|
||||
|
||||
for expected_item in expected:
|
||||
self.assertIn(expected_item, state_run)
|
||||
|
||||
def test_output_highstate_falls_back_nested(self):
|
||||
'''
|
||||
Tests outputter when passing --out=highstate with a non-state call. This should
|
||||
fall back to "nested" output.
|
||||
'''
|
||||
expected = ['minion:', ' True']
|
||||
ret = self.run_salt('"minion" test.ping --out=highstate')
|
||||
self.assertEqual(ret, expected)
|
||||
|
||||
def test_static_simple(self):
|
||||
'''
|
||||
Tests passing the --static option with a basic test.ping command. This
|
||||
should be the "nested" output.
|
||||
'''
|
||||
expected = ['minion:', ' True']
|
||||
ret = self.run_salt('"minion" test.ping --static')
|
||||
self.assertEqual(ret, expected)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
Loading…
Add table
Reference in a new issue