Add orchestration tests when target exists or not

This commit is contained in:
Ch3LL 2017-11-10 12:00:12 -05:00
parent 4f3a79df07
commit f3ec6df76e
No known key found for this signature in database
GPG key ID: 132B55A7C13EFA73
3 changed files with 85 additions and 0 deletions

View file

@ -0,0 +1,17 @@
core:
salt.state:
- tgt: 'doesnotexist*'
- sls:
- core
test-state:
salt.state:
- tgt: '*'
- sls:
- include-test
cmd.run:
salt.function:
- tgt: '*'
- arg:
- echo test

View file

@ -0,0 +1,17 @@
core:
salt.state:
- tgt: 'minion*'
- sls:
- core
test-state:
salt.state:
- tgt: '*'
- sls:
- include-test
cmd.run:
salt.function:
- tgt: '*'
- arg:
- echo test

View file

@ -80,6 +80,57 @@ class StateRunnerTest(ShellCase):
self.assertFalse(os.path.exists('/tmp/ewu-2016-12-13'))
self.assertNotEqual(code, 0)
def test_orchestrate_target_exists(self):
'''
test orchestration when target exists
while using multiple states
'''
ret = self.run_run('state.orchestrate orch.target-exists')
first = [' ID: core',
' Function: salt.state',
' Result: True']
second = [' ID: test-state',
' Function: salt.state',
' Result: True']
third = [' ID: cmd.run',
' Function: salt.function',
' Result: True']
ret_out = [first, second, third]
for out in ret_out:
for item in out:
self.assertIn(item, ret)
def test_orchestrate_target_doesnt_exists(self):
'''
test orchestration when target doesnt exist
while using multiple states
'''
ret = self.run_run('state.orchestrate orch.target-doesnt-exists')
first = ['No minions matched the target. No command was sent, no jid was assigned.',
' ID: core',
' Function: salt.state',
' Result: False']
second = [' ID: test-state',
' Function: salt.state',
' Result: True']
third = [' ID: cmd.run',
' Function: salt.function',
' Result: True']
ret_out = [first, second, third]
for out in ret_out:
for item in out:
self.assertIn(item, ret)
def test_state_event(self):
'''
test to ensure state.event