13
13
14
14
# Import Salt Testing libs
15
15
from tests .support .case import ModuleCase
16
- from tests .support .helpers import with_tempdir , flaky
16
+ from tests .support .helpers import with_tempdir
17
17
from tests .support .unit import skipIf
18
18
from tests .support .paths import BASE_FILES , TMP , TMP_PILLAR_TREE , TMP_STATE_TREE
19
19
from tests .support .mixins import SaltReturnAssertsMixin
@@ -1764,7 +1764,7 @@ def test_retry_option_success(self):
1764
1764
'''
1765
1765
test a state with the retry option that should return True immedietly (i.e. no retries)
1766
1766
'''
1767
- testfile = os .path .join (TMP , 'retry_file ' )
1767
+ testfile = os .path .join (TMP , 'retry_file_option_success ' )
1768
1768
state_run = self .run_function (
1769
1769
'state.sls' ,
1770
1770
mods = 'retry.retry_success'
@@ -1773,29 +1773,35 @@ def test_retry_option_success(self):
1773
1773
retry_state = 'file_|-file_test_|-{0}_|-exists' .format (testfile )
1774
1774
self .assertNotIn ('Attempt' , state_run [retry_state ]['comment' ])
1775
1775
1776
- def run_create (self ):
1776
+ def run_create (self , testfile ):
1777
1777
'''
1778
1778
helper function to wait 30 seconds and then create the temp retry file
1779
1779
'''
1780
- testfile = os .path .join (TMP , 'retry_file' )
1780
+ # Wait for the requisite stae 'file_test_a' to complete before creating
1781
+ # test_file
1782
+ while True :
1783
+ if os .path .exists (testfile + '_a' ):
1784
+ break
1785
+ time .sleep (1 )
1781
1786
time .sleep (30 )
1782
1787
with salt .utils .files .fopen (testfile , 'a' ):
1783
1788
pass
1784
1789
1785
- @flaky
1786
1790
def test_retry_option_eventual_success (self ):
1787
1791
'''
1788
1792
test a state with the retry option that should return True after at least 4 retry attmempt
1789
1793
but never run 15 attempts
1790
1794
'''
1791
- testfile = os .path .join (TMP , 'retry_file' )
1792
- create_thread = threading .Thread (target = self .run_create )
1795
+ testfile = os .path .join (TMP , 'retry_file_eventual_success' )
1796
+ assert not os .path .exists (testfile + '_a' )
1797
+ assert not os .path .exists (testfile )
1798
+ create_thread = threading .Thread (target = self .run_create , args = (testfile ,))
1793
1799
create_thread .start ()
1794
1800
state_run = self .run_function (
1795
1801
'state.sls' ,
1796
1802
mods = 'retry.retry_success2'
1797
1803
)
1798
- retry_state = 'file_|-file_test_ |-{0}_|-exists' .format (testfile )
1804
+ retry_state = 'file_|-file_test_b_ |-{0}_|-exists' .format (testfile )
1799
1805
self .assertIn ('Attempt 1:' , state_run [retry_state ]['comment' ])
1800
1806
self .assertIn ('Attempt 2:' , state_run [retry_state ]['comment' ])
1801
1807
self .assertIn ('Attempt 3:' , state_run [retry_state ]['comment' ])
0 commit comments