2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-05-17 05:00:01 +00:00
|
|
|
'''
|
|
|
|
tests for host state
|
|
|
|
'''
|
2013-06-27 12:34:48 +00:00
|
|
|
|
2014-03-29 13:03:36 +00:00
|
|
|
# Import python libs
|
2018-01-24 20:47:14 +00:00
|
|
|
from __future__ import absolute_import, unicode_literals, print_function
|
2014-03-29 13:03:36 +00:00
|
|
|
|
2013-06-27 12:34:48 +00:00
|
|
|
# Import Salt Testing libs
|
2017-04-03 16:04:09 +00:00
|
|
|
from tests.support.case import ModuleCase
|
2012-05-17 05:00:01 +00:00
|
|
|
|
2018-08-08 14:36:56 +00:00
|
|
|
# Import Salt libs
|
2018-08-10 17:15:53 +00:00
|
|
|
import salt.utils.platform
|
2018-08-08 14:36:56 +00:00
|
|
|
|
|
|
|
# Import 3rd-Party libs
|
|
|
|
HAS_LSB_RELEASE = True
|
|
|
|
try:
|
|
|
|
import lsb_release
|
|
|
|
except ImportError:
|
|
|
|
HAS_LSB_RELEASE = False
|
|
|
|
|
2012-05-29 16:40:20 +00:00
|
|
|
|
2017-04-03 16:04:09 +00:00
|
|
|
class CompileTest(ModuleCase):
|
2012-05-17 05:00:01 +00:00
|
|
|
'''
|
|
|
|
Validate the state compiler
|
|
|
|
'''
|
|
|
|
def test_multi_state(self):
|
|
|
|
'''
|
|
|
|
Test the error with multiple states of the same type
|
|
|
|
'''
|
|
|
|
ret = self.run_function('state.sls', mods='fuzz.multi_state')
|
|
|
|
# Verify that the return is a list, aka, an error
|
2012-07-23 19:00:54 +00:00
|
|
|
self.assertIsInstance(ret, list)
|
2012-07-20 06:21:01 +00:00
|
|
|
|
2014-01-29 01:02:31 +00:00
|
|
|
def test_jinja_deep_error(self):
|
|
|
|
'''
|
|
|
|
Test when we have an error in a execution module
|
|
|
|
called by jinja
|
|
|
|
'''
|
2018-08-10 17:15:53 +00:00
|
|
|
if salt.utils.platform.is_linux() and HAS_LSB_RELEASE:
|
2018-08-08 14:36:56 +00:00
|
|
|
release = lsb_release.get_distro_information()
|
2018-08-08 22:29:14 +00:00
|
|
|
if release.get('ID') == 'Debian' and int(release.get('RELEASE', '0')[0]) < 9:
|
2018-08-08 14:36:56 +00:00
|
|
|
self.skipTest('This test is flaky on Debian 8. Skipping.')
|
|
|
|
|
2014-01-29 01:02:31 +00:00
|
|
|
ret = self.run_function('state.sls', ['issue-10010'])
|
|
|
|
self.assertTrue(
|
|
|
|
', in jinja_error' in ret[0].strip())
|
|
|
|
self.assertTrue(
|
|
|
|
ret[0].strip().endswith('Exception: hehehe'))
|