diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index bba937cd78..338e966b44 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -593,14 +593,15 @@ class ModuleCase(TestCase, SaltClientTestCaseMixIn): ''' return self.run_function(_function, args, **kw) - def run_function(self, function, arg=(), minion_tgt='minion', **kwargs): + def run_function(self, function, arg=(), minion_tgt='minion', timeout=90, + **kwargs): ''' Run a single salt function and condition the return down to match the behavior of the raw function call ''' know_to_return_none = ('file.chown', 'file.chgrp') orig = self.client.cmd( - minion_tgt, function, arg, timeout=90, kwarg=kwargs + minion_tgt, function, arg, timeout=timeout, kwarg=kwargs ) if minion_tgt not in orig: @@ -967,31 +968,46 @@ class SaltReturnAssertsMixIn(object): try: self.assertTrue(self.__getWithinSaltReturn(ret, 'result')) except AssertionError: - raise AssertionError( - '{result} is not True. Salt Comment:\n{comment}'.format( - **(ret.values()[0]) + try: + raise AssertionError( + '{result} is not True. Salt Comment:\n{comment}'.format( + **(ret.values()[0]) + ) + ) + except AttributeError: + raise AssertionError( + 'Failed to get result. Salt Returned: {0}'.format(ret) ) - ) def assertSaltFalseReturn(self, ret): try: self.assertFalse(self.__getWithinSaltReturn(ret, 'result')) except AssertionError: - raise AssertionError( - '{result} is not False. Salt Comment:\n{comment}'.format( - **(ret.values()[0]) + try: + raise AssertionError( + '{result} is not False. Salt Comment:\n{comment}'.format( + **(ret.values()[0]) + ) + ) + except AttributeError: + raise AssertionError( + 'Failed to get result. Salt Returned: {0}'.format(ret) ) - ) def assertSaltNoneReturn(self, ret): try: self.assertIsNone(self.__getWithinSaltReturn(ret, 'result')) except AssertionError: - raise AssertionError( - '{result} is not None. Salt Comment:\n{comment}'.format( - **(ret.values()[0]) + try: + raise AssertionError( + '{result} is not None. Salt Comment:\n{comment}'.format( + **(ret.values()[0]) + ) + ) + except AttributeError: + raise AssertionError( + 'Failed to get result. Salt Returned: {0}'.format(ret) ) - ) def assertInSaltComment(self, ret, in_comment): return self.assertIn( diff --git a/tests/integration/modules/state.py b/tests/integration/modules/state.py index a7d2a81708..748abf9d7f 100644 --- a/tests/integration/modules/state.py +++ b/tests/integration/modules/state.py @@ -140,15 +140,19 @@ fi os.unlink(testfile) # Create the file - ret = self.run_function('state.sls', mods='issue-1879') + ret = self.run_function('state.sls', mods='issue-1879', timeout=120) self.assertSaltTrueReturn(ret) # The first append - ret = self.run_function('state.sls', mods='issue-1879.step-1') + ret = self.run_function( + 'state.sls', mods='issue-1879.step-1', timeout=120 + ) self.assertSaltTrueReturn(ret) # The second append - ret = self.run_function('state.sls', mods='issue-1879.step-2') + ret = self.run_function( + 'state.sls', mods='issue-1879.step-2', timeout=120 + ) self.assertSaltTrueReturn(ret) # Does it match? @@ -158,10 +162,14 @@ fi salt.utils.fopen(testfile, 'r').read() ) # Make sure we don't re-append existing text - ret = self.run_function('state.sls', mods='issue-1879.step-1') + ret = self.run_function( + 'state.sls', mods='issue-1879.step-1', timeout=120 + ) self.assertSaltTrueReturn(ret) - ret = self.run_function('state.sls', mods='issue-1879.step-2') + ret = self.run_function( + 'state.sls', mods='issue-1879.step-2', timeout=120 + ) self.assertSaltTrueReturn(ret) self.assertMultiLineEqual( contents, @@ -222,7 +230,8 @@ fi try: ret = self.run_function( - 'state.sls', mods='issue-2068-template-str-no-dot' + 'state.sls', mods='issue-2068-template-str-no-dot', + timeout=120 ) self.assertSaltTrueReturn(ret) finally: @@ -238,7 +247,9 @@ fi template = salt.utils.fopen(template_path, 'r').read() try: - ret = self.run_function('state.template_str', [template]) + ret = self.run_function( + 'state.template_str', [template], timeout=120 + ) self.assertSaltTrueReturn(ret) self.assertTrue( @@ -250,7 +261,9 @@ fi # Now using state.template try: - ret = self.run_function('state.template', [template_path]) + ret = self.run_function( + 'state.template', [template_path], timeout=120 + ) self.assertSaltTrueReturn(ret) finally: if os.path.isdir(venv_dir): @@ -259,7 +272,7 @@ fi # Now the problematic #2068 including dot's try: ret = self.run_function( - 'state.sls', mods='issue-2068-template-str' + 'state.sls', mods='issue-2068-template-str', timeout=120 ) self.assertSaltTrueReturn(ret) finally: @@ -275,7 +288,9 @@ fi template = salt.utils.fopen(template_path, 'r').read() try: - ret = self.run_function('state.template_str', [template]) + ret = self.run_function( + 'state.template_str', [template], timeout=120 + ) self.assertSaltTrueReturn(ret) self.assertTrue( @@ -287,7 +302,9 @@ fi # Now using state.template try: - ret = self.run_function('state.template', [template_path]) + ret = self.run_function( + 'state.template', [template_path], timeout=120 + ) self.assertSaltTrueReturn(ret) finally: if os.path.isdir(venv_dir): diff --git a/tests/integration/states/file.py b/tests/integration/states/file.py index a09df59b21..6fe8206f06 100644 --- a/tests/integration/states/file.py +++ b/tests/integration/states/file.py @@ -504,14 +504,17 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): ] template = '\n'.join(template_lines) try: - ret = self.run_function('state.template_str', [template]) - + ret = self.run_function( + 'state.template_str', [template], timeout=120 + ) self.assertSaltTrueReturn(ret) self.assertNotInSaltComment(ret, 'Pattern already commented') self.assertInSaltComment(ret, 'Commented lines successfully') # This next time, it is already commented. - ret = self.run_function('state.template_str', [template]) + ret = self.run_function( + 'state.template_str', [template], timeout=120 + ) self.assertSaltTrueReturn(ret) self.assertInSaltComment(ret, 'Pattern already commented')