Skip to content

Commit

Permalink
Merge pull request #34069 from rallytime/test-minion-return-message
Browse files Browse the repository at this point in the history
Add a test to check for disconnected minion messaging
  • Loading branch information
thatch45 committed Jun 16, 2016
2 parents 3119693 + 60561ac commit 1b76de1
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tests/integration/client/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_cli(self):
assert num_ret > 0

# ping a minion that doesn't exist, to make sure that it doesn't hang forever
# create fake mininion
# create fake minion
key_file = os.path.join(self.master_opts['pki_dir'], 'minions', 'footest')
# touch the file
salt.utils.fopen(key_file, 'a').close()
Expand Down Expand Up @@ -116,6 +116,37 @@ def test_full_returns(self):
ret['minion']
)

def test_disconnected_return(self):
'''
Test return/messaging on a disconnected minion
'''
test_ret = {'ret': 'Minion did not return. [Not connected]', 'out': 'no_return'}

# Create a minion key, but do not start the "fake" minion. This mimics
# a disconnected minion.
key_file = os.path.join(self.master_opts['pki_dir'], 'minions', 'disconnected')
salt.utils.fopen(key_file, 'a').close()

# ping disconnected minion and ensure it times out and returns with correct message
try:
cmd_iter = self.client.cmd_cli(
'disconnected',
'test.ping',
show_timeout=True
)
num_ret = 0
for ret in cmd_iter:
num_ret += 1
self.assertEqual(ret['disconnected']['ret'], test_ret['ret'])
self.assertEqual(ret['disconnected']['out'], test_ret['out'])

# Ensure that we entered the loop above
self.assertEqual(num_ret, 1)

finally:
os.unlink(key_file)


if __name__ == '__main__':
from integration import run_tests
run_tests(StdTest)

0 comments on commit 1b76de1

Please sign in to comment.