mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #39648 from twangboy/win_fix_loader_tests
Fix ext_grains and ext_modules tests for Windows
This commit is contained in:
commit
1926e90d47
4 changed files with 71 additions and 42 deletions
|
@ -653,17 +653,16 @@ def grains(opts, force_refresh=False, proxy=None):
|
|||
except (IOError, OSError):
|
||||
pass
|
||||
else:
|
||||
if force_refresh:
|
||||
log.debug('Grains refresh requested. Refreshing grains.')
|
||||
else:
|
||||
log.debug('Grains cache last modified {0} seconds ago and '
|
||||
'cache expiration is set to {1}. '
|
||||
'Grains cache expired. Refreshing.'.format(
|
||||
grains_cache_age,
|
||||
opts.get('grains_cache_expiration', 300)
|
||||
))
|
||||
log.debug('Grains cache last modified {0} seconds ago and '
|
||||
'cache expiration is set to {1}. '
|
||||
'Grains cache expired. Refreshing.'.format(
|
||||
grains_cache_age,
|
||||
opts.get('grains_cache_expiration', 300)
|
||||
))
|
||||
else:
|
||||
log.debug('Grains cache file does not exist.')
|
||||
else:
|
||||
log.debug('Grains refresh requested. Refreshing grains.')
|
||||
|
||||
if opts.get('skip_grains', False):
|
||||
return {}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import time
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.unit import skipIf
|
||||
|
@ -15,7 +17,6 @@ from tests.support.unit import skipIf
|
|||
# Import salt libs
|
||||
import tests.integration as integration
|
||||
from salt.config import minion_config
|
||||
|
||||
from salt.loader import grains
|
||||
|
||||
|
||||
|
@ -30,6 +31,18 @@ class LoaderGrainsTest(integration.ModuleCase):
|
|||
# self.opts['grains'] = grains(self.opts)
|
||||
|
||||
def test_grains_overwrite(self):
|
||||
# To avoid a race condition on Windows, we need to make sure the
|
||||
# `test_custom_grain2.py` file is present in the _grains directory
|
||||
# before trying to get the grains. This test may execute before the
|
||||
# minion has finished syncing down the files it needs.
|
||||
module = os.path.join(integration.TMP, 'rootdir', 'cache', 'files',
|
||||
'base', '_grains', 'test_custom_grain2.py')
|
||||
tries = 0
|
||||
while not os.path.exists(module):
|
||||
tries += 1
|
||||
if tries > 60:
|
||||
break
|
||||
time.sleep(1)
|
||||
grains = self.run_function('grains.items')
|
||||
|
||||
# Check that custom grains are overwritten
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import time
|
||||
|
||||
# Import Salt Testing libs
|
||||
import tests.integration as integration
|
||||
|
@ -19,6 +21,19 @@ import tests.integration as integration
|
|||
class LoaderOverridesTest(integration.ModuleCase):
|
||||
|
||||
def test_overridden_internal(self):
|
||||
# To avoid a race condition on Windows, we need to make sure the
|
||||
# `override_test.py` file is present in the _modules directory before
|
||||
# trying to list all functions. This test may execute before the
|
||||
# minion has finished syncing down the files it needs.
|
||||
module = os.path.join(integration.TMP, 'rootdir', 'cache', 'files',
|
||||
'base', '_modules', 'override_test.py')
|
||||
tries = 0
|
||||
while not os.path.exists(module):
|
||||
tries += 1
|
||||
if tries > 60:
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
funcs = self.run_function('sys.list_functions')
|
||||
|
||||
# We placed a test module under _modules.
|
||||
|
|
|
@ -1,35 +1,37 @@
|
|||
integration.client.runner
|
||||
integration.client.standard
|
||||
integration.fileserver.fileclient_test
|
||||
integration.fileserver.roots_test
|
||||
integration.loader.globals
|
||||
integration.loader.interfaces
|
||||
integration.loader.loader
|
||||
integration.modules.aliases
|
||||
integration.modules.beacons
|
||||
integration.modules.config
|
||||
integration.modules.cp
|
||||
integration.modules.data
|
||||
integration.modules.disk
|
||||
integration.modules.git
|
||||
integration.modules.grains
|
||||
integration.modules.hosts
|
||||
integration.modules.mine
|
||||
integration.modules.pillar
|
||||
integration.modules.pkg
|
||||
integration.modules.publish
|
||||
integration.modules.state
|
||||
integration.modules.sysmod
|
||||
integration.modules.test
|
||||
integration.modules.useradd
|
||||
integration.client.test_runner
|
||||
integration.client.test_standard
|
||||
integration.fileserver.test_fileclient
|
||||
integration.fileserver.test_roots
|
||||
integration.loader.test_ext_grains
|
||||
integration.loader.test_ext_modules
|
||||
integration.loader.test_globals
|
||||
integration.loader.test_interfaces
|
||||
integration.loader.test_loader
|
||||
integration.modules.test_aliases
|
||||
integration.modules.test_beacons
|
||||
integration.modules.test_config
|
||||
integration.modules.test_cp
|
||||
integration.modules.test_data
|
||||
integration.modules.test_disk
|
||||
integration.modules.test_git
|
||||
integration.modules.test_grains
|
||||
integration.modules.test_hosts
|
||||
integration.modules.test_mine
|
||||
integration.modules.test_pillar
|
||||
integration.modules.test_pkg
|
||||
integration.modules.test_publish
|
||||
integration.modules.test_state
|
||||
integration.modules.test_sysmod
|
||||
integration.modules.test_test
|
||||
integration.modules.test_useradd
|
||||
integration.returners.test_librato_return
|
||||
integration.returners.test_local_cache
|
||||
integration.runners.jobs
|
||||
integration.runners.salt
|
||||
integration.runners.winrepo
|
||||
integration.runners.test_jobs
|
||||
integration.runners.test_salt
|
||||
integration.runners.test_winrepo
|
||||
integration.sdb.test_env
|
||||
integration.states.host
|
||||
integration.states.renderers
|
||||
integration.utils.testprogram
|
||||
integration.wheel.client
|
||||
integration.wheel.key
|
||||
integration.states.test_host
|
||||
integration.states.test_renderers
|
||||
integration.utils.test_testprogram
|
||||
integration.wheel.test_client
|
||||
integration.wheel.test_key
|
||||
|
|
Loading…
Add table
Reference in a new issue