Merge pull request #50085 from dwoz/win_pkg_redux

Fix `test_win_pkg` yet again
This commit is contained in:
Daniel Wozniak 2018-10-19 11:16:15 -07:00 committed by GitHub
commit 0ece06ef66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View file

@ -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):

View file

@ -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: