mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #50085 from dwoz/win_pkg_redux
Fix `test_win_pkg` yet again
This commit is contained in:
commit
0ece06ef66
2 changed files with 15 additions and 5 deletions
|
@ -134,16 +134,26 @@ def check_file_list_cache(opts, form, list_cache, w_lock):
|
|||
# st_time can have a greater precision than time, removing
|
||||
# float precision makes sure age will never be a negative
|
||||
# number.
|
||||
age = int(time.time()) - int(cache_stat.st_mtime)
|
||||
current_time = int(time.time())
|
||||
file_mtime = int(cache_stat.st_mtime)
|
||||
if file_mtime > current_time:
|
||||
log.debug(
|
||||
'Cache file modified time is in the future, ignoring. '
|
||||
'file=%s mtime=%s current_time=%s',
|
||||
list_cache, current_time, file_mtime
|
||||
)
|
||||
age = 0
|
||||
else:
|
||||
age = current_time - file_mtime
|
||||
else:
|
||||
# if filelist does not exists yet, mark it as expired
|
||||
age = opts.get('fileserver_list_cache_time', 20) + 1
|
||||
if age < opts.get('fileserver_list_cache_time', 20):
|
||||
# Young enough! Load this sucker up!
|
||||
with salt.utils.files.fopen(list_cache, 'rb') as fp_:
|
||||
log.trace(
|
||||
'Returning file_lists cache data from %s',
|
||||
list_cache
|
||||
log.debug(
|
||||
"Returning file list from cache: age=%s cache_time=%s %s",
|
||||
age, opts.get('fileserver_list_cache_time', 20), list_cache
|
||||
)
|
||||
return salt.utils.data.decode(serial.load(fp_).get(form, [])), False, False
|
||||
elif _lock_cache(w_lock):
|
||||
|
|
|
@ -38,7 +38,7 @@ class WinPKGTest(ModuleCase):
|
|||
refresh = self.run_function('pkg.refresh_db')
|
||||
self.assertEqual(check_refresh, refresh['total'],
|
||||
msg='total returned {0}. Expected return {1}'.format(refresh['total'], check_refresh))
|
||||
repo_data = self.run_function('pkg.get_repo_data', timeout=300)
|
||||
repo_data = self.run_function('pkg.get_repo_data')
|
||||
repo_cache = os.path.join(RUNTIME_VARS.TMP, 'rootdir', 'cache', 'files', 'base', 'win', 'repo-ng')
|
||||
for pkg in pkgs:
|
||||
if exists:
|
||||
|
|
Loading…
Add table
Reference in a new issue