Add additional asserts to help investigate test_win_pkg failure

This commit is contained in:
Ch3LL 2018-09-27 14:23:01 -04:00
parent 85478cd2b3
commit 18e9a2831a
No known key found for this signature in database
GPG key ID: 132B55A7C13EFA73

View file

@ -15,7 +15,8 @@ from tests.support.runtests import RUNTIME_VARS
import salt.utils.files
import salt.utils.platform
CURL = os.path.join(RUNTIME_VARS.FILES, 'file', 'base', 'win', 'repo-ng', 'curl.sls')
REPO_DIR = os.path.join(RUNTIME_VARS.FILES, 'file', 'base', 'win', 'repo-ng')
CURL = os.path.join(REPO_DIR, 'curl.sls')
@skipIf(not salt.utils.platform.is_windows(), 'windows test only')
@ -33,8 +34,24 @@ class WinPKGTest(ModuleCase):
Test add and removing a new pkg sls
in the windows software repository
'''
def _check_pkg(pkgs, exists=True):
self.run_function('pkg.refresh_db')
def _check_pkg(pkgs, exists=True, check_refresh=None):
refresh = self.run_function('pkg.refresh_db')
if check_refresh:
count = 2
while count != 0:
try:
self.assertEqual(0, refresh['failed'],
msg='failed returned {0}. Expected return: 0'.format(refresh['failed']))
self.assertEqual(check_refresh, refresh['total'],
msg='total returned {0}. Expected return {1}'.format(check_refresh, refresh['total']))
self.assertEqual(check_refresh, refresh['success'],
msg='success returned {0}. Expected return {1}'.format(check_refresh, refresh['success']))
count = 0
except AssertionError as err:
if count == 1:
raise AssertionError(err)
count = count -1
refresh = self.run_function('pkg.refresh_db')
repo_data = self.run_function('pkg.get_repo_data', timeout=300)
repo_cache = os.path.join(RUNTIME_VARS.TMP, 'rootdir', 'cache', 'files', 'base', 'win', 'repo-ng')
for pkg in pkgs:
@ -74,7 +91,9 @@ class WinPKGTest(ModuleCase):
'''))
# now check if curl is also in cache and repo query
pkgs.append('curl')
_check_pkg(pkgs)
for pkg in pkgs:
self.assertIn(pkg + '.sls', os.listdir(REPO_DIR))
_check_pkg(pkgs, check_refresh=3)
# remove curl sls and check its not in cache and repo query
os.remove(CURL)